Skip to content

Commit

Permalink
Move printing related stuff to the root printing project from the bro…
Browse files Browse the repository at this point in the history
…wser project. This simplifies further refactoring and eases understanding of the printing part of Chrome.

Also renamed win_printing_context to printing_context_win (correct naming convention) and added stub implementations for _linux and mac.
Now all but one file is compiling on all platforms.

TEST=none (no functional change).
BUG=none

Review URL: http://codereview.chromium.org/149212

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20086 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
sverrir@google.com committed Jul 7, 2009
1 parent 395f929 commit 8ff1d42
Show file tree
Hide file tree
Showing 42 changed files with 414 additions and 143 deletions.
2 changes: 1 addition & 1 deletion chrome/browser/browser_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
#include "chrome/browser/jankometer.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/browser/printing/printed_document.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/rlz/rlz.h"
#include "chrome/browser/views/user_data_dir_dialog.h"
Expand All @@ -103,6 +102,7 @@
#include "net/base/sdch_manager.h"
#include "net/base/winsock_init.h"
#include "net/http/http_network_layer.h"
#include "printing/printed_document.h"
#include "sandbox/src/sandbox.h"
#include "views/widget/accelerator_handler.h"
#endif // defined(OS_WIN)
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/printing/print_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#include "base/message_loop.h"
#include "base/timer.h"
#include "chrome/browser/printing/print_job_worker.h"
#include "chrome/browser/printing/printed_document.h"
#include "chrome/browser/printing/printed_page.h"
#include "chrome/common/notification_service.h"
#include "printing/printed_document.h"
#include "printing/printed_page.h"

#ifdef _MSC_VER
#pragma warning(disable:4355) // 'this' : used in base member initializer list
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/printing/print_job_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

#include "chrome/browser/printing/print_job.h"
#include "chrome/browser/printing/printer_query.h"
#include "chrome/browser/printing/printed_document.h"
#include "chrome/browser/printing/printed_page.h"
#include "chrome/common/notification_service.h"
#include "printing/printed_document.h"
#include "printing/printed_page.h"

namespace printing {

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/printing/print_job_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include "base/message_loop.h"
#include "chrome/browser/printing/print_job.h"
#include "chrome/browser/printing/print_job_worker.h"
#include "chrome/browser/printing/printed_pages_source.h"
#include "chrome/common/notification_registrar.h"
#include "chrome/common/notification_service.h"
#include "printing/printed_pages_source.h"
#include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest.h"

Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/printing/print_job_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

#include "base/message_loop.h"
#include "chrome/browser/printing/print_job.h"
#include "chrome/browser/printing/printed_document.h"
#include "chrome/browser/printing/printed_page.h"
#include "chrome/common/notification_service.h"
#include "printing/printed_document.h"
#include "printing/printed_page.h"

namespace printing {

Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/printing/print_job_worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#include "base/task.h"
#include "base/thread.h"
#include "chrome/browser/printing/page_number.h"
#include "chrome/browser/printing/win_printing_context.h"
#include "printing/page_number.h"
#include "printing/printing_context.h"

namespace printing {

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/printing/print_job_worker_owner.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_OWNER_H__
#define CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_OWNER_H__

#include "chrome/browser/printing/win_printing_context.h"
#include "printing/printing_context.h"

class MessageLoop;

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/printing/print_view_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/printing/print_job.h"
#include "chrome/browser/printing/print_job_manager.h"
#include "chrome/browser/printing/printed_document.h"
#include "chrome/browser/printing/printer_query.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/tab_contents/navigation_entry.h"
Expand All @@ -18,6 +17,7 @@
#include "chrome/common/render_messages.h"
#include "grit/generated_resources.h"
#include "printing/native_metafile.h"
#include "printing/printed_document.h"

using base::TimeDelta;

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/printing/print_view_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#define CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_

#include "base/ref_counted.h"
#include "chrome/browser/printing/printed_pages_source.h"
#include "chrome/common/notification_registrar.h"
#include "printing/printed_pages_source.h"

class RenderViewHost;
class TabContents;
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/printing/printing_layout_uitest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#include "chrome/test/automation/tab_proxy.h"
#include "chrome/test/automation/window_proxy.h"
#include "chrome/test/ui/ui_test.h"
#include "chrome/browser/printing/printing_test.h"
#include "net/url_request/url_request_unittest.h"
#include "printing/printing_test.h"
#include "printing/native_metafile.h"

namespace {
Expand Down
25 changes: 23 additions & 2 deletions chrome/browser/renderer_host/resource_message_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,27 @@ class WriteClipboardTask : public Task {
scoped_ptr<Clipboard::ObjectMap> objects_;
};

void RenderParamsFromPrintSettings(const printing::PrintSettings& settings,
ViewMsg_Print_Params* params) {
DCHECK(params);
#if defined(OS_WIN)
params->printable_size.SetSize(
settings.page_setup_pixels().content_area().width(),
settings.page_setup_pixels().content_area().height());
params->dpi = settings.dpi();
// Currently hardcoded at 1.25. See PrintSettings' constructor.
params->min_shrink = settings.min_shrink;
// Currently hardcoded at 2.0. See PrintSettings' constructor.
params->max_shrink = settings.max_shrink;
// Currently hardcoded at 72dpi. See PrintSettings' constructor.
params->desired_dpi = settings.desired_dpi;
// Always use an invalid cookie.
params->document_cookie = 0;
params->selection_only = settings.selection_only;
#else
NOTIMPLEMENTED();
#endif
}

} // namespace

Expand Down Expand Up @@ -724,7 +745,7 @@ void ResourceMessageFilter::OnGetDefaultPrintSettingsReply(
if (printer_query->last_status() != printing::PrintingContext::OK) {
memset(&params, 0, sizeof(params));
} else {
printer_query->settings().RenderParams(&params);
RenderParamsFromPrintSettings(printer_query->settings(), &params);
params.document_cookie = printer_query->cookie();
}
ViewHostMsg_GetDefaultPrintSettings::WriteReplyParams(reply_msg, params);
Expand Down Expand Up @@ -781,7 +802,7 @@ void ResourceMessageFilter::OnScriptedPrintReply(
!printer_query->settings().dpi()) {
memset(&params, 0, sizeof(params));
} else {
printer_query->settings().RenderParams(&params.params);
RenderParamsFromPrintSettings(printer_query->settings(), &params.params);
params.params.document_cookie = printer_query->cookie();
params.pages =
printing::PageRange::GetPages(printer_query->settings().ranges);
Expand Down
27 changes: 1 addition & 26 deletions chrome/chrome.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@
'../app/app.gyp:app_resources',
'../media/media.gyp:media',
'../net/net.gyp:net_resources',
'../printing/printing.gyp:printing',
'../skia/skia.gyp:skia',
'../third_party/icu38/icu38.gyp:icui18n',
'../third_party/icu38/icu38.gyp:icuuc',
Expand Down Expand Up @@ -1267,34 +1268,17 @@
'browser/plugin_service.h',
'browser/possible_url_model.cc',
'browser/possible_url_model.h',
'browser/printing/page_number.cc',
'browser/printing/page_number.h',
'browser/printing/page_overlays.cc',
'browser/printing/page_overlays.h',
'browser/printing/page_range.cc',
'browser/printing/page_range.h',
'browser/printing/page_setup.cc',
'browser/printing/page_setup.h',
'browser/printing/print_job.cc',
'browser/printing/print_job.h',
'browser/printing/print_job_manager.cc',
'browser/printing/print_job_manager.h',
'browser/printing/print_job_worker.cc',
'browser/printing/print_job_worker.h',
'browser/printing/print_job_worker_owner.h',
'browser/printing/print_settings.cc',
'browser/printing/print_settings.h',
'browser/printing/print_view_manager.cc',
'browser/printing/print_view_manager.h',
'browser/printing/printed_document.cc',
'browser/printing/printed_document.h',
'browser/printing/printed_page.cc',
'browser/printing/printed_page.h',
'browser/printing/printed_pages_source.h',
'browser/printing/printer_query.cc',
'browser/printing/printer_query.h',
'browser/printing/win_printing_context.cc',
'browser/printing/win_printing_context.h',
'browser/privacy_blacklist/blacklist.h',
'browser/privacy_blacklist/blacklist.cc',
'browser/process_singleton.h',
Expand Down Expand Up @@ -1886,7 +1870,6 @@
'dependencies': [
'../google_update/google_update.gyp:google_update',
'installer/installer.gyp:installer_util',
'../printing/printing.gyp:printing',
'../third_party/cld/cld.gyp:cld',
'../views/views.gyp:views',
'../gears/gears.gyp:gears',
Expand Down Expand Up @@ -3256,7 +3239,6 @@
'browser/media_uitest.cc',
'browser/metrics/metrics_service_uitest.cc',
'browser/printing/printing_layout_uitest.cc',
'browser/printing/printing_test.h',
'browser/renderer_host/resource_dispatcher_host_uitest.cc',
'browser/sanity_uitest.cc',
'browser/session_history_uitest.cc',
Expand Down Expand Up @@ -3551,12 +3533,7 @@
'browser/password_manager/login_database_unittest.cc',
'browser/password_manager/password_form_manager_unittest.cc',
'browser/password_manager/password_store_mac_unittest.cc',
'browser/printing/page_number_unittest.cc',
'browser/printing/page_overlays_unittest.cc',
'browser/printing/page_range_unittest.cc',
'browser/printing/page_setup_unittest.cc',
'browser/printing/print_job_unittest.cc',
'browser/printing/win_printing_context_unittest.cc',
'browser/privacy_blacklist/blacklist_unittest.cc',
'browser/profile_manager_unittest.cc',
'browser/renderer_host/audio_renderer_host_unittest.cc',
Expand Down Expand Up @@ -3779,8 +3756,6 @@
'browser/importer/firefox_importer_unittest.cc',
'browser/importer/importer_unittest.cc',
'browser/login_prompt_unittest.cc',
'browser/printing/page_number_unittest.cc',
'browser/printing/page_overlays_unittest.cc',
'browser/printing/print_job_unittest.cc',
'browser/rlz/rlz_unittest.cc',
'browser/safe_browsing/safe_browsing_blocking_page_unittest.cc',
Expand Down
3 changes: 3 additions & 0 deletions printing/DEPS
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
include_rules = [
"+app/gfx", # Font's are here.
"+app", # win_util::FormatSystemTime/Date.
"+base",
"+skia/ext",
]
6 changes: 3 additions & 3 deletions printing/emf_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef PRINTING_EMF_WIN_H__
#define PRINTING_EMF_WIN_H__
#ifndef PRINTING_EMF_WIN_H_
#define PRINTING_EMF_WIN_H_

#include <windows.h>
#include <vector>
Expand Down Expand Up @@ -178,4 +178,4 @@ class Emf::Enumerator {

} // namespace printing

#endif // PRINTING_EMF_WIN_H__
#endif // PRINTING_EMF_WIN_H_
2 changes: 1 addition & 1 deletion printing/emf_win_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ TEST(EmfTest, DC) {
/*
// DEPS check fails even if include is in a multi line comment:
// #include "chrome/browser/printing/win_printing_context.h"
// #include "printing/printing_context.h"
// #include "chrome/common/chrome_paths.h"
// Disabled if no "UnitTest printer" exist. Useful to reproduce bug 1186598.
Expand Down
10 changes: 7 additions & 3 deletions printing/native_metafile.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef PRINTING_NATIVE_METAFILE_H__
#define PRINTING_NATIVE_METAFILE_H__
#ifndef PRINTING_NATIVE_METAFILE_H_
#define PRINTING_NATIVE_METAFILE_H_

// Define a metafile format for the current platform. We use this platform
// independent define so we can define interfaces in platform agnostic manner.
Expand All @@ -25,12 +25,16 @@ typedef Emf NativeMetafile;
#elif defined(OS_MACOSX)

// TODO(port): Printing using PDF?
// The mock class is here so we can compile.
class NativeMetafile {};

#elif defined(OS_LINUX)

// TODO(port): Printing using PostScript?
// The mock class is here so we can compile.
class NativeMetafile {};

#endif


#endif // PRINTING_NATIVE_METAFILE_H__
#endif // PRINTING_NATIVE_METAFILE_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/printing/page_number.h"
#include "printing/page_number.h"

#include <limits>

#include "base/logging.h"
#include "chrome/browser/printing/print_settings.h"
#include "printing/print_settings.h"

namespace printing {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_PRINTING_PAGE_NUMBER_H__
#define CHROME_BROWSER_PRINTING_PAGE_NUMBER_H__
#ifndef PRINTING_PAGE_NUMBER_H_
#define PRINTING_PAGE_NUMBER_H_

#include <ostream>

#include "chrome/browser/printing/page_range.h"
#include "printing/page_range.h"

namespace printing {

Expand Down Expand Up @@ -70,4 +70,4 @@ inline typename std::basic_ostream<E,T>& operator<<(

} // namespace printing

#endif // CHROME_BROWSER_PRINTING_PAGE_NUMBER_H__
#endif // PRINTING_PAGE_NUMBER_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/printing/page_number.h"
#include "chrome/browser/printing/print_settings.h"
#include "printing/page_number.h"
#include "printing/print_settings.h"
#include "testing/gtest/include/gtest/gtest.h"

TEST(PageNumberTest, Count) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/printing/page_overlays.h"
#include "printing/page_overlays.h"

#include "app/gfx/text_elider.h"
#include "base/logging.h"
#include "base/string_util.h"
#include "chrome/browser/printing/printed_document.h"
#include "chrome/browser/printing/printed_page.h"
#include "printing/printed_document.h"
#include "printing/printed_page.h"

namespace {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_PRINTING_PAGE_OVERLAYS_H__
#define CHROME_BROWSER_PRINTING_PAGE_OVERLAYS_H__
#ifndef PRINTING_PAGE_OVERLAYS_H_
#define PRINTING_PAGE_OVERLAYS_H_

#include <string>

Expand Down Expand Up @@ -77,4 +77,4 @@ class PageOverlays {

} // namespace printing

#endif // CHROME_BROWSER_PRINTING_PAGE_OVERLAYS_H__
#endif // PRINTING_PAGE_OVERLAYS_H_
Loading

0 comments on commit 8ff1d42

Please sign in to comment.