diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-24 17:07:22 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-24 17:07:22 +0000 |
commit | 1375e3ab50fc27bfc67d8e16bc12022dad3ab7d2 (patch) | |
tree | cf5db38665e6a7ddef5ae41a894d52c7b781ca49 | |
parent | c29bdcf3f973fcc76fec6b9038a7891e472b7f2f (diff) | |
download | chromium_src-1375e3ab50fc27bfc67d8e16bc12022dad3ab7d2.zip chromium_src-1375e3ab50fc27bfc67d8e16bc12022dad3ab7d2.tar.gz chromium_src-1375e3ab50fc27bfc67d8e16bc12022dad3ab7d2.tar.bz2 |
Move printing messages to their own file.
TBR=thestig
Review URL: http://codereview.chromium.org/6731014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79286 0039d316-1c4b-4281-b951-d872f2087c98
27 files changed, 387 insertions, 704 deletions
diff --git a/chrome/browser/printing/print_dialog_cloud.cc b/chrome/browser/printing/print_dialog_cloud.cc index c021f42..7510d0a1 100644 --- a/chrome/browser/printing/print_dialog_cloud.cc +++ b/chrome/browser/printing/print_dialog_cloud.cc @@ -17,7 +17,7 @@ #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/browser_dialogs.h" #include "chrome/common/pref_names.h" -#include "chrome/common/render_messages_params.h" +#include "chrome/common/print_messages.h" #include "chrome/common/url_constants.h" #include "content/browser/browser_thread.h" #include "content/browser/renderer_host/render_view_host.h" @@ -112,7 +112,7 @@ bool GetDoubleOrInt(const DictionaryValue& dictionary, // From the JSON parsed value, get the entries for the page setup // parameters. bool GetPageSetupParameters(const std::string& json, - ViewMsg_Print_Params& parameters) { + PrintMsg_Print_Params& parameters) { scoped_ptr<Value> parsed_value(base::JSONReader::Read(json, false)); DLOG_IF(ERROR, (!parsed_value.get() || !parsed_value->IsType(Value::TYPE_DICTIONARY))) @@ -369,7 +369,7 @@ void CloudPrintFlowHandler::HandleSetPageParameters(const ListValue* args) { const double kMinPageShrink = 1.25; const double kMaxPageShrink = 2.0; - ViewMsg_Print_Params default_settings; + PrintMsg_Print_Params default_settings; default_settings.printable_size = gfx::Size(kWidth, kHeight); default_settings.dpi = kDPI; default_settings.min_shrink = kMinPageShrink; diff --git a/chrome/browser/printing/print_preview_message_handler.cc b/chrome/browser/printing/print_preview_message_handler.cc index b050888..e6c2c25 100644 --- a/chrome/browser/printing/print_preview_message_handler.cc +++ b/chrome/browser/printing/print_preview_message_handler.cc @@ -11,8 +11,7 @@ #include "chrome/browser/ui/webui/print_preview_handler.h" #include "chrome/browser/ui/webui/print_preview_ui.h" #include "chrome/browser/ui/webui/print_preview_ui_html_source.h" -#include "chrome/common/render_messages.h" -#include "chrome/common/render_messages_params.h" +#include "chrome/common/print_messages.h" #include "content/browser/browser_thread.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/tab_contents/tab_contents.h" @@ -38,8 +37,8 @@ TabContents* PrintPreviewMessageHandler::GetPrintPreviewTab() { } void PrintPreviewMessageHandler::OnPagesReadyForPreview( - const ViewHostMsg_DidPreviewDocument_Params& params) { - // Always need to stop the worker and send ViewMsg_PrintingDone. + const PrintHostMsg_DidPreviewDocument_Params& params) { + // Always need to stop the worker and send PrintMsg_PrintingDone. PrintJobManager* print_job_manager = g_browser_process->print_job_manager(); scoped_refptr<printing::PrinterQuery> printer_query; print_job_manager->PopPrinterQuery(params.document_cookie, &printer_query); @@ -51,7 +50,7 @@ void PrintPreviewMessageHandler::OnPagesReadyForPreview( } RenderViewHost* rvh = tab_contents()->render_view_host(); - rvh->Send(new ViewMsg_PrintingDone(rvh->routing_id(), + rvh->Send(new PrintMsg_PrintingDone(rvh->routing_id(), params.document_cookie, true)); @@ -91,11 +90,11 @@ bool PrintPreviewMessageHandler::OnMessageReceived( const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(PrintPreviewMessageHandler, message) - IPC_MESSAGE_HANDLER(ViewHostMsg_PagesReadyForPreview, + IPC_MESSAGE_HANDLER(PrintHostMsg_PagesReadyForPreview, OnPagesReadyForPreview) - IPC_MESSAGE_HANDLER(ViewHostMsg_PrintPreviewNodeUnderContextMenu, + IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewNodeUnderContextMenu, OnPrintPreviewNodeUnderContextMenu) - IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptInitiatedPrintPreview, + IPC_MESSAGE_HANDLER(PrintHostMsg_ScriptInitiatedPrintPreview, OnScriptInitiatedPrintPreview) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() diff --git a/chrome/browser/printing/print_preview_message_handler.h b/chrome/browser/printing/print_preview_message_handler.h index c889afb..6bddf6d 100644 --- a/chrome/browser/printing/print_preview_message_handler.h +++ b/chrome/browser/printing/print_preview_message_handler.h @@ -8,7 +8,7 @@ #include "content/browser/tab_contents/tab_contents_observer.h" -struct ViewHostMsg_DidPreviewDocument_Params; +struct PrintHostMsg_DidPreviewDocument_Params; namespace printing { @@ -28,7 +28,7 @@ class PrintPreviewMessageHandler : public TabContentsObserver { TabContents* GetPrintPreviewTab(); void OnPagesReadyForPreview( - const ViewHostMsg_DidPreviewDocument_Params& params); + const PrintHostMsg_DidPreviewDocument_Params& params); void OnPrintPreviewNodeUnderContextMenu(); void OnScriptInitiatedPrintPreview(); diff --git a/chrome/browser/printing/print_view_manager.cc b/chrome/browser/printing/print_view_manager.cc index c60aa4e..e315187 100644 --- a/chrome/browser/printing/print_view_manager.cc +++ b/chrome/browser/printing/print_view_manager.cc @@ -10,8 +10,7 @@ #include "chrome/browser/printing/print_job.h" #include "chrome/browser/printing/print_job_manager.h" #include "chrome/browser/printing/printer_query.h" -#include "chrome/common/render_messages.h" -#include "chrome/common/render_messages_params.h" +#include "chrome/common/print_messages.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/tab_contents/navigation_entry.h" #include "content/browser/tab_contents/tab_contents.h" @@ -95,7 +94,7 @@ void PrintViewManager::OnDidGetPrintedPagesCount(int cookie, int number_pages) { } void PrintViewManager::OnDidPrintPage( - const ViewHostMsg_DidPrintPage_Params& params) { + const PrintHostMsg_DidPrintPage_Params& params) { if (!OpportunisticallyCreatePrintJob(params.document_cookie)) return; @@ -157,9 +156,9 @@ void PrintViewManager::OnDidPrintPage( bool PrintViewManager::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(PrintViewManager, message) - IPC_MESSAGE_HANDLER(ViewHostMsg_DidGetPrintedPagesCount, + IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPrintedPagesCount, OnDidGetPrintedPagesCount) - IPC_MESSAGE_HANDLER(ViewHostMsg_DidPrintPage, OnDidPrintPage) + IPC_MESSAGE_HANDLER(PrintHostMsg_DidPrintPage, OnDidPrintPage) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; diff --git a/chrome/browser/printing/print_view_manager.h b/chrome/browser/printing/print_view_manager.h index aacfaf9..29747d7 100644 --- a/chrome/browser/printing/print_view_manager.h +++ b/chrome/browser/printing/print_view_manager.h @@ -15,7 +15,7 @@ class RenderViewHost; class TabContents; -struct ViewHostMsg_DidPrintPage_Params; +struct PrintHostMsg_DidPrintPage_Params; namespace printing { @@ -53,7 +53,7 @@ class PrintViewManager : public NotificationObserver, private: void OnDidGetPrintedPagesCount(int cookie, int number_pages); - void OnDidPrintPage(const ViewHostMsg_DidPrintPage_Params& params); + void OnDidPrintPage(const PrintHostMsg_DidPrintPage_Params& params); // Processes a NOTIFY_PRINT_JOB_EVENT notification. void OnNotifyPrintJobEvent(const JobEventDetails& event_details); diff --git a/chrome/browser/printing/printing_message_filter.cc b/chrome/browser/printing/printing_message_filter.cc index 3ccf491..c4519c3 100644 --- a/chrome/browser/printing/printing_message_filter.cc +++ b/chrome/browser/printing/printing_message_filter.cc @@ -8,7 +8,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/printing/printer_query.h" #include "chrome/browser/printing/print_job_manager.h" -#include "chrome/common/render_messages.h" +#include "chrome/common/print_messages.h" #include "content/common/view_messages.h" #if defined(OS_CHROMEOS) @@ -38,7 +38,7 @@ static base::LazyInstance<PrintingSequencePathMap> #endif void RenderParamsFromPrintSettings(const printing::PrintSettings& settings, - ViewMsg_Print_Params* params) { + PrintMsg_Print_Params* params) { params->page_size = settings.page_setup_device_units().physical_size(); params->printable_size.SetSize( settings.page_setup_device_units().content_area().width(), @@ -76,8 +76,8 @@ PrintingMessageFilter::~PrintingMessageFilter() { void PrintingMessageFilter::OverrideThreadForMessage( const IPC::Message& message, BrowserThread::ID* thread) { #if defined(OS_CHROMEOS) - if (message.type() == ViewHostMsg_AllocateTempFileForPrinting::ID || - message.type() == ViewHostMsg_TempFileForPrintingWritten::ID) { + if (message.type() == PrintHostMsg_AllocateTempFileForPrinting::ID || + message.type() == PrintHostMsg_TempFileForPrintingWritten::ID) { *thread = BrowserThread::FILE; } #endif @@ -91,15 +91,15 @@ bool PrintingMessageFilter::OnMessageReceived(const IPC::Message& message, IPC_MESSAGE_HANDLER(ViewHostMsg_DuplicateSection, OnDuplicateSection) #endif #if defined(OS_CHROMEOS) - IPC_MESSAGE_HANDLER(ViewHostMsg_AllocateTempFileForPrinting, + IPC_MESSAGE_HANDLER(PrintHostMsg_AllocateTempFileForPrinting, OnAllocateTempFileForPrinting) - IPC_MESSAGE_HANDLER(ViewHostMsg_TempFileForPrintingWritten, + IPC_MESSAGE_HANDLER(PrintHostMsg_TempFileForPrintingWritten, OnTempFileForPrintingWritten) #endif - IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetDefaultPrintSettings, + IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_GetDefaultPrintSettings, OnGetDefaultPrintSettings) - IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_ScriptedPrint, OnScriptedPrint) - IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_UpdatePrintSettings, + IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_ScriptedPrint, OnScriptedPrint) + IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_UpdatePrintSettings, OnUpdatePrintSettings) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -199,7 +199,7 @@ void PrintingMessageFilter::OnGetDefaultPrintSettings(IPC::Message* reply_msg) { void PrintingMessageFilter::OnGetDefaultPrintSettingsReply( scoped_refptr<printing::PrinterQuery> printer_query, IPC::Message* reply_msg) { - ViewMsg_Print_Params params; + PrintMsg_Print_Params params; if (!printer_query.get() || printer_query->last_status() != printing::PrintingContext::OK) { memset(¶ms, 0, sizeof(params)); @@ -207,7 +207,7 @@ void PrintingMessageFilter::OnGetDefaultPrintSettingsReply( RenderParamsFromPrintSettings(printer_query->settings(), ¶ms); params.document_cookie = printer_query->cookie(); } - ViewHostMsg_GetDefaultPrintSettings::WriteReplyParams(reply_msg, params); + PrintHostMsg_GetDefaultPrintSettings::WriteReplyParams(reply_msg, params); Send(reply_msg); // If printing was enabled. if (printer_query.get()) { @@ -221,7 +221,7 @@ void PrintingMessageFilter::OnGetDefaultPrintSettingsReply( } void PrintingMessageFilter::OnScriptedPrint( - const ViewHostMsg_ScriptedPrint_Params& params, + const PrintHostMsg_ScriptedPrint_Params& params, IPC::Message* reply_msg) { gfx::NativeView host_view = gfx::NativeViewFromIdInBrowser(params.host_window_id); @@ -251,7 +251,7 @@ void PrintingMessageFilter::OnScriptedPrintReply( scoped_refptr<printing::PrinterQuery> printer_query, int routing_id, IPC::Message* reply_msg) { - ViewMsg_PrintPages_Params params; + PrintMsg_PrintPages_Params params; if (printer_query->last_status() != printing::PrintingContext::OK || !printer_query->settings().dpi()) { memset(¶ms, 0, sizeof(params)); @@ -261,7 +261,7 @@ void PrintingMessageFilter::OnScriptedPrintReply( params.pages = printing::PageRange::GetPages(printer_query->settings().ranges); } - ViewHostMsg_ScriptedPrint::WriteReplyParams(reply_msg, params); + PrintHostMsg_ScriptedPrint::WriteReplyParams(reply_msg, params); Send(reply_msg); if (params.params.dpi && params.params.document_cookie) { print_job_manager_->QueuePrinterQuery(printer_query.get()); @@ -288,7 +288,7 @@ void PrintingMessageFilter::OnUpdatePrintSettings( void PrintingMessageFilter::OnUpdatePrintSettingsReply( scoped_refptr<printing::PrinterQuery> printer_query, IPC::Message* reply_msg) { - ViewMsg_PrintPages_Params params; + PrintMsg_PrintPages_Params params; if (printer_query->last_status() != printing::PrintingContext::OK) { memset(¶ms, 0, sizeof(params)); } else { @@ -297,7 +297,7 @@ void PrintingMessageFilter::OnUpdatePrintSettingsReply( params.pages = printing::PageRange::GetPages(printer_query->settings().ranges); } - ViewHostMsg_UpdatePrintSettings::WriteReplyParams(reply_msg, params); + PrintHostMsg_UpdatePrintSettings::WriteReplyParams(reply_msg, params); Send(reply_msg); // If user hasn't cancelled. if (printer_query->cookie() && printer_query->settings().dpi()) diff --git a/chrome/browser/printing/printing_message_filter.h b/chrome/browser/printing/printing_message_filter.h index e2c9c3c..829aba8 100644 --- a/chrome/browser/printing/printing_message_filter.h +++ b/chrome/browser/printing/printing_message_filter.h @@ -13,7 +13,7 @@ #endif class DictionaryValue; -struct ViewHostMsg_ScriptedPrint_Params; +struct PrintHostMsg_ScriptedPrint_Params; namespace printing { class PrinterQuery; @@ -60,7 +60,7 @@ class PrintingMessageFilter : public BrowserMessageFilter { // A javascript code requested to print the current page. The renderer host // have to show to the user the print dialog and returns the selected print // settings. - void OnScriptedPrint(const ViewHostMsg_ScriptedPrint_Params& params, + void OnScriptedPrint(const PrintHostMsg_ScriptedPrint_Params& params, IPC::Message* reply_msg); void OnScriptedPrintReply( scoped_refptr<printing::PrinterQuery> printer_query, diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index 0cd099a..56a69a3 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -42,7 +42,7 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/content_restriction.h" #include "chrome/common/pref_names.h" -#include "chrome/common/render_messages.h" +#include "chrome/common/print_messages.h" #include "chrome/common/url_constants.h" #include "content/browser/child_process_security_policy.h" #include "content/browser/renderer_host/render_view_host.h" @@ -1302,7 +1302,7 @@ void RenderViewContextMenu::ExecuteCommand(int id) { } } else { RenderViewHost* rvh = source_tab_contents_->render_view_host(); - rvh->Send(new ViewMsg_PrintNodeUnderContextMenu(rvh->routing_id())); + rvh->Send(new PrintMsg_PrintNodeUnderContextMenu(rvh->routing_id())); } break; diff --git a/chrome/browser/ui/webui/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview_handler.cc index 863e2d7..ad8e032 100644 --- a/chrome/browser/ui/webui/print_preview_handler.cc +++ b/chrome/browser/ui/webui/print_preview_handler.cc @@ -10,7 +10,7 @@ #include "base/threading/thread.h" #include "base/values.h" #include "chrome/browser/printing/print_preview_tab_controller.h" -#include "chrome/common/render_messages.h" +#include "chrome/common/print_messages.h" #include "content/browser/browser_thread.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/tab_contents/tab_contents.h" @@ -110,7 +110,7 @@ void PrintPreviewHandler::HandlePrint(const ListValue* args) { TabContents* initiator_tab = GetInitiatorTab(web_ui_->tab_contents()); if (initiator_tab) { RenderViewHost* rvh = initiator_tab->render_view_host(); - rvh->Send(new ViewMsg_ResetScriptedPrintCount(rvh->routing_id())); + rvh->Send(new PrintMsg_ResetScriptedPrintCount(rvh->routing_id())); } std::string json_str; diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi index d17f87c..fdbeb6c 100644 --- a/chrome/chrome_common.gypi +++ b/chrome/chrome_common.gypi @@ -204,6 +204,7 @@ 'common/persistent_pref_store.h', 'common/pref_store.cc', 'common/pref_store.h', + 'common/print_messages.h', 'common/remoting/chromoting_host_info.cc', 'common/remoting/chromoting_host_info.h', 'common/render_messages.cc', diff --git a/chrome/common/common_message_generator.h b/chrome/common/common_message_generator.h index 6c7083e..d05d225 100644 --- a/chrome/common/common_message_generator.h +++ b/chrome/common/common_message_generator.h @@ -6,6 +6,7 @@ #include "chrome/common/autofill_messages.h" #include "chrome/common/devtools_messages.h" +#include "chrome/common/print_messages.h" #include "chrome/common/render_messages.h" #include "chrome/common/safebrowsing_messages.h" #include "chrome/common/service_messages.h" diff --git a/chrome/common/print_messages.h b/chrome/common/print_messages.h new file mode 100644 index 0000000..a9fd701 --- /dev/null +++ b/chrome/common/print_messages.h @@ -0,0 +1,207 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// IPC messages for printing. +// Multiply-included message file, hence no include guard. + +#include "base/values.h" +#include "base/shared_memory.h" +#include "ipc/ipc_message_macros.h" +#include "ui/gfx/native_widget_types.h" +#include "ui/gfx/rect.h" + +#define IPC_MESSAGE_START PrintMsgStart + +// Parameters for a render request. +IPC_STRUCT_BEGIN(PrintMsg_Print_Params) + // Physical size of the page, including non-printable margins, + // in pixels according to dpi. + IPC_STRUCT_MEMBER(gfx::Size, page_size) + + // In pixels according to dpi_x and dpi_y. + IPC_STRUCT_MEMBER(gfx::Size, printable_size) + + // The y-offset of the printable area, in pixels according to dpi. + IPC_STRUCT_MEMBER(int, margin_top) + + // The x-offset of the printable area, in pixels according to dpi. + IPC_STRUCT_MEMBER(int, margin_left) + + // Specifies dots per inch. + IPC_STRUCT_MEMBER(double, dpi) + + // Minimum shrink factor. See PrintSettings::min_shrink for more information. + IPC_STRUCT_MEMBER(double, min_shrink) + + // Maximum shrink factor. See PrintSettings::max_shrink for more information. + IPC_STRUCT_MEMBER(double, max_shrink) + + // Desired apparent dpi on paper. + IPC_STRUCT_MEMBER(int, desired_dpi) + + // Cookie for the document to ensure correctness. + IPC_STRUCT_MEMBER(int, document_cookie) + + // Should only print currently selected text. + IPC_STRUCT_MEMBER(bool, selection_only) + + // Does the printer support alpha blending? + IPC_STRUCT_MEMBER(bool, supports_alpha_blend) +IPC_STRUCT_END() + +IPC_STRUCT_BEGIN(PrintMsg_PrintPage_Params) + // Parameters to render the page as a printed page. It must always be the same + // value for all the document. + IPC_STRUCT_MEMBER(PrintMsg_Print_Params, params) + + // The page number is the indicator of the square that should be rendered + // according to the layout specified in PrintMsg_Print_Params. + IPC_STRUCT_MEMBER(int, page_number) +IPC_STRUCT_END() + +IPC_STRUCT_BEGIN(PrintMsg_PrintPages_Params) + // Parameters to render the page as a printed page. It must always be the same + // value for all the document. + IPC_STRUCT_MEMBER(PrintMsg_Print_Params, params) + + // If empty, this means a request to render all the printed pages. + IPC_STRUCT_MEMBER(std::vector<int>, pages) +IPC_STRUCT_END() + +// Parameters to describe a rendered document. +IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewDocument_Params) + // A shared memory handle to metafile data. + IPC_STRUCT_MEMBER(base::SharedMemoryHandle, metafile_data_handle) + + // Size of metafile data. + IPC_STRUCT_MEMBER(uint32, data_size) + + // Cookie for the document to ensure correctness. + IPC_STRUCT_MEMBER(int, document_cookie) + + // Store the expected pages count. + IPC_STRUCT_MEMBER(int, expected_pages_count) +IPC_STRUCT_END() + +// Parameters to describe a rendered page. +IPC_STRUCT_BEGIN(PrintHostMsg_DidPrintPage_Params) + // A shared memory handle to the EMF data. This data can be quite large so a + // memory map needs to be used. + IPC_STRUCT_MEMBER(base::SharedMemoryHandle, metafile_data_handle) + + // Size of the metafile data. + IPC_STRUCT_MEMBER(uint32, data_size) + + // Cookie for the document to ensure correctness. + IPC_STRUCT_MEMBER(int, document_cookie) + + // Page number. + IPC_STRUCT_MEMBER(int, page_number) + + // Shrink factor used to render this page. + IPC_STRUCT_MEMBER(double, actual_shrink) + + // The size of the page the page author specified. + IPC_STRUCT_MEMBER(gfx::Size, page_size) + + // The printable area the page author specified. + IPC_STRUCT_MEMBER(gfx::Rect, content_area) + + // True if the page has visible overlays. + IPC_STRUCT_MEMBER(bool, has_visible_overlays) +IPC_STRUCT_END() + +// Parameters for the IPC message ViewHostMsg_ScriptedPrint +IPC_STRUCT_BEGIN(PrintHostMsg_ScriptedPrint_Params) + IPC_STRUCT_MEMBER(int, routing_id) + IPC_STRUCT_MEMBER(gfx::NativeViewId, host_window_id) + IPC_STRUCT_MEMBER(int, cookie) + IPC_STRUCT_MEMBER(int, expected_pages_count) + IPC_STRUCT_MEMBER(bool, has_selection) + IPC_STRUCT_MEMBER(bool, use_overlays) +IPC_STRUCT_END() + + +// Messages sent from the browser to the renderer. + +IPC_MESSAGE_ROUTED0(PrintMsg_PrintNodeUnderContextMenu) + +// Tells the renderer to print the print preview tab's PDF plugin without +// showing the print dialog. +IPC_MESSAGE_ROUTED1(PrintMsg_PrintForPrintPreview, + DictionaryValue /* settings*/) + +// Tells the render view to switch the CSS to print media type, renders every +// requested pages and switch back the CSS to display media type. +IPC_MESSAGE_ROUTED0(PrintMsg_PrintPages) + +// Tells the render view that printing is done so it can clean up. +IPC_MESSAGE_ROUTED2(PrintMsg_PrintingDone, + int /* document_cookie */, + bool /* success */) + +// Tells the render view to switch the CSS to print media type, renders every +// requested pages for print preview using the given |settngs|. +IPC_MESSAGE_ROUTED1(PrintMsg_PrintPreview, + DictionaryValue /* settings */) + +// Tells a renderer to stop blocking script initiated printing. +IPC_MESSAGE_ROUTED0(PrintMsg_ResetScriptedPrintCount) + + +// Messages sent from the renderer to the browser. + +// Tells the browser that the renderer is done calculating the number of +// rendered pages according to the specified settings. +IPC_MESSAGE_ROUTED2(PrintHostMsg_DidGetPrintedPagesCount, + int /* rendered document cookie */, + int /* number of rendered pages */) + +// Sends back to the browser the rendered "printed page" that was requested by +// a ViewMsg_PrintPage message or from scripted printing. The memory handle in +// this message is already valid in the browser process. +IPC_MESSAGE_ROUTED1(PrintHostMsg_DidPrintPage, + PrintHostMsg_DidPrintPage_Params /* page content */) + +// The renderer wants to know the default print settings. +IPC_SYNC_MESSAGE_ROUTED0_1(PrintHostMsg_GetDefaultPrintSettings, + PrintMsg_Print_Params /* default_settings */) + +// The renderer wants to update the current print settings with new +// |job_settings|. +IPC_SYNC_MESSAGE_ROUTED2_1(PrintHostMsg_UpdatePrintSettings, + int /* document_cookie */, + DictionaryValue /* job_settings */, + PrintMsg_PrintPages_Params /* current_settings */) + +// It's the renderer that controls the printing process when it is generated +// by javascript. This step is about showing UI to the user to select the +// final print settings. The output parameter is the same as +// ViewMsg_PrintPages which is executed implicitly. +IPC_SYNC_MESSAGE_ROUTED1_1(PrintHostMsg_ScriptedPrint, + PrintHostMsg_ScriptedPrint_Params, + PrintMsg_PrintPages_Params + /* settings chosen by the user*/) + +#if defined(USE_X11) +// Asks the browser to create a temporary file for the renderer to fill +// in resulting NativeMetafile in printing. +IPC_SYNC_MESSAGE_CONTROL0_2(PrintHostMsg_AllocateTempFileForPrinting, + base::FileDescriptor /* temp file fd */, + int /* fd in browser*/) +IPC_MESSAGE_CONTROL1(PrintHostMsg_TempFileForPrintingWritten, + int /* fd in browser */) +#endif + +// Asks the browser to do print preview for the node under the context menu. +IPC_MESSAGE_ROUTED0(PrintHostMsg_PrintPreviewNodeUnderContextMenu) + +// Asks the browser to do print preview for window.print(). +IPC_MESSAGE_ROUTED0(PrintHostMsg_ScriptInitiatedPrintPreview) + +// Sends back to the browser the rendered "printed document" for preview that +// was requested by a PrintMsg_PrintPreview message. The memory handle in this +// message is already valid in the browser process. +IPC_MESSAGE_ROUTED1(PrintHostMsg_PagesReadyForPreview, + PrintHostMsg_DidPreviewDocument_Params /* params */) diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 8b7ec51..05eb031 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -229,36 +229,6 @@ IPC_MESSAGE_CONTROL0(ViewMsg_PurgeMemory) // render view responds with a ViewHostMsg_Snapshot. IPC_MESSAGE_ROUTED0(ViewMsg_CaptureSnapshot) -IPC_MESSAGE_ROUTED0(ViewMsg_PrintNodeUnderContextMenu) - -// Tells the renderer to print the print preview tab's PDF plugin without -// showing the print dialog. -IPC_MESSAGE_ROUTED1(ViewMsg_PrintForPrintPreview, - DictionaryValue /* settings*/) - -// Tells the render view to switch the CSS to print media type, renders every -// requested pages and switch back the CSS to display media type. -IPC_MESSAGE_ROUTED0(ViewMsg_PrintPages) - -// Tells the render view that printing is done so it can clean up. -IPC_MESSAGE_ROUTED2(ViewMsg_PrintingDone, - int /* document_cookie */, - bool /* success */) - -// Tells the render view to switch the CSS to print media type, renders every -// requested pages for print preview using the given |settngs|. -IPC_MESSAGE_ROUTED1(ViewMsg_PrintPreview, - DictionaryValue /* settings */) - -// Tells a renderer to stop blocking script initiated printing. -IPC_MESSAGE_ROUTED0(ViewMsg_ResetScriptedPrintCount) - -// Sends back to the browser the rendered "printed document" for preview that -// was requested by a ViewMsg_PrintPreview message. The memory handle in this -// message is already valid in the browser process. -IPC_MESSAGE_ROUTED1(ViewHostMsg_PagesReadyForPreview, - ViewHostMsg_DidPreviewDocument_Params /* params */) - // History system notification that the visited link database has been // replaced. It has one SharedMemoryHandle argument consisting of the table // handle. This handle is valid in the context of the renderer @@ -638,54 +608,6 @@ IPC_SYNC_MESSAGE_ROUTED2_1( GURL /* inquiry url */, ViewHostMsg_GetSearchProviderInstallState_Params /* install */) -// Tells the browser that the renderer is done calculating the number of -// rendered pages according to the specified settings. -IPC_MESSAGE_ROUTED2(ViewHostMsg_DidGetPrintedPagesCount, - int /* rendered document cookie */, - int /* number of rendered pages */) - -// Sends back to the browser the rendered "printed page" that was requested by -// a ViewMsg_PrintPage message or from scripted printing. The memory handle in -// this message is already valid in the browser process. -IPC_MESSAGE_ROUTED1(ViewHostMsg_DidPrintPage, - ViewHostMsg_DidPrintPage_Params /* page content */) - -// The renderer wants to know the default print settings. -IPC_SYNC_MESSAGE_ROUTED0_1(ViewHostMsg_GetDefaultPrintSettings, - ViewMsg_Print_Params /* default_settings */) - -// The renderer wants to update the current print settings with new -// |job_settings|. -IPC_SYNC_MESSAGE_ROUTED2_1(ViewHostMsg_UpdatePrintSettings, - int /* document_cookie */, - DictionaryValue /* job_settings */, - ViewMsg_PrintPages_Params /* current_settings */) - -// It's the renderer that controls the printing process when it is generated -// by javascript. This step is about showing UI to the user to select the -// final print settings. The output parameter is the same as -// ViewMsg_PrintPages which is executed implicitly. -IPC_SYNC_MESSAGE_ROUTED1_1(ViewHostMsg_ScriptedPrint, - ViewHostMsg_ScriptedPrint_Params, - ViewMsg_PrintPages_Params - /* settings chosen by the user*/) - -#if defined(USE_X11) -// Asks the browser to create a temporary file for the renderer to fill -// in resulting NativeMetafile in printing. -IPC_SYNC_MESSAGE_CONTROL0_2(ViewHostMsg_AllocateTempFileForPrinting, - base::FileDescriptor /* temp file fd */, - int /* fd in browser*/) -IPC_MESSAGE_CONTROL1(ViewHostMsg_TempFileForPrintingWritten, - int /* fd in browser */) -#endif - -// Asks the browser to do print preview for the node under the context menu. -IPC_MESSAGE_ROUTED0(ViewHostMsg_PrintPreviewNodeUnderContextMenu) - -// Asks the browser to do print preview for window.print(). -IPC_MESSAGE_ROUTED0(ViewHostMsg_ScriptInitiatedPrintPreview) - // Stores new inspector setting in the profile. IPC_MESSAGE_ROUTED2(ViewHostMsg_UpdateInspectorSetting, std::string, /* key */ diff --git a/chrome/common/render_messages_params.cc b/chrome/common/render_messages_params.cc index caf263e..9dce8f1 100644 --- a/chrome/common/render_messages_params.cc +++ b/chrome/common/render_messages_params.cc @@ -6,102 +6,6 @@ #include "chrome/common/extensions/extension_constants.h" #include "chrome/common/render_messages.h" -#include "net/base/upload_data.h" - -ViewMsg_Print_Params::ViewMsg_Print_Params() - : margin_top(0), - margin_left(0), - dpi(0), - min_shrink(0), - max_shrink(0), - desired_dpi(0), - document_cookie(0), - selection_only(false), - supports_alpha_blend(true) { -} - -ViewMsg_Print_Params::~ViewMsg_Print_Params() { -} - -bool ViewMsg_Print_Params::Equals(const ViewMsg_Print_Params& rhs) const { - return page_size == rhs.page_size && - printable_size == rhs.printable_size && - margin_top == rhs.margin_top && - margin_left == rhs.margin_left && - dpi == rhs.dpi && - min_shrink == rhs.min_shrink && - max_shrink == rhs.max_shrink && - desired_dpi == rhs.desired_dpi && - selection_only == rhs.selection_only && - supports_alpha_blend == rhs.supports_alpha_blend; -} - -bool ViewMsg_Print_Params::IsEmpty() const { - return !document_cookie && !desired_dpi && !max_shrink && !min_shrink && - !dpi && printable_size.IsEmpty() && !selection_only && - page_size.IsEmpty() && !margin_top && !margin_left && - !supports_alpha_blend; -} - -ViewMsg_PrintPage_Params::ViewMsg_PrintPage_Params() - : page_number(0) { -} - -ViewMsg_PrintPage_Params::~ViewMsg_PrintPage_Params() { -} - -ViewMsg_PrintPages_Params::ViewMsg_PrintPages_Params() { -} - -ViewMsg_PrintPages_Params::~ViewMsg_PrintPages_Params() { -} - -ViewHostMsg_DidPreviewDocument_Params::ViewHostMsg_DidPreviewDocument_Params() - : data_size(0), - document_cookie(0), - expected_pages_count(0) { -#if defined(OS_WIN) - // Initialize |metafile_data_handle| only on Windows because it maps - // base::SharedMemoryHandle to HANDLE. We do not need to initialize this - // variable on Posix because it maps base::SharedMemoryHandle to - // FileDescriptior, which has the default constructor. - metafile_data_handle = INVALID_HANDLE_VALUE; -#endif -} - -ViewHostMsg_DidPreviewDocument_Params:: - ~ViewHostMsg_DidPreviewDocument_Params() { -} - -ViewHostMsg_DidPrintPage_Params::ViewHostMsg_DidPrintPage_Params() - : data_size(0), - document_cookie(0), - page_number(0), - actual_shrink(0), - has_visible_overlays(false) { -#if defined(OS_WIN) - // Initialize |metafile_data_handle| only on Windows because it maps - // base::SharedMemoryHandle to HANDLE. We do not need to initialize this - // variable on Posix because it maps base::SharedMemoryHandle to - // FileDescriptior, which has the default constructor. - metafile_data_handle = INVALID_HANDLE_VALUE; -#endif -} - -ViewHostMsg_DidPrintPage_Params::~ViewHostMsg_DidPrintPage_Params() { -} - -ViewHostMsg_ScriptedPrint_Params::ViewHostMsg_ScriptedPrint_Params() - : routing_id(0), - host_window_id(0), - cookie(0), - expected_pages_count(0), - has_selection(false), - use_overlays(false) { -} - -ViewHostMsg_ScriptedPrint_Params::~ViewHostMsg_ScriptedPrint_Params() { -} ViewMsg_ExecuteCode_Params::ViewMsg_ExecuteCode_Params() { } @@ -288,168 +192,6 @@ void ParamTraits<ViewHostMsg_GetSearchProviderInstallState_Params>::Log( LogParam(state, l); } -void ParamTraits<ViewMsg_Print_Params>::Write(Message* m, const param_type& p) { - WriteParam(m, p.page_size); - WriteParam(m, p.printable_size); - WriteParam(m, p.margin_top); - WriteParam(m, p.margin_left); - WriteParam(m, p.dpi); - WriteParam(m, p.min_shrink); - WriteParam(m, p.max_shrink); - WriteParam(m, p.desired_dpi); - WriteParam(m, p.document_cookie); - WriteParam(m, p.selection_only); - WriteParam(m, p.supports_alpha_blend); -} - -bool ParamTraits<ViewMsg_Print_Params>::Read(const Message* m, - void** iter, - param_type* p) { - return ReadParam(m, iter, &p->page_size) && - ReadParam(m, iter, &p->printable_size) && - ReadParam(m, iter, &p->margin_top) && - ReadParam(m, iter, &p->margin_left) && - ReadParam(m, iter, &p->dpi) && - ReadParam(m, iter, &p->min_shrink) && - ReadParam(m, iter, &p->max_shrink) && - ReadParam(m, iter, &p->desired_dpi) && - ReadParam(m, iter, &p->document_cookie) && - ReadParam(m, iter, &p->selection_only) && - ReadParam(m, iter, &p->supports_alpha_blend); -} - -void ParamTraits<ViewMsg_Print_Params>::Log(const param_type& p, - std::string* l) { - l->append("<ViewMsg_Print_Params>"); -} - -void ParamTraits<ViewMsg_PrintPage_Params>::Write(Message* m, - const param_type& p) { - WriteParam(m, p.params); - WriteParam(m, p.page_number); -} - -bool ParamTraits<ViewMsg_PrintPage_Params>::Read(const Message* m, - void** iter, - param_type* p) { - return ReadParam(m, iter, &p->params) && - ReadParam(m, iter, &p->page_number); -} - -void ParamTraits<ViewMsg_PrintPage_Params>::Log(const param_type& p, - std::string* l) { - l->append("<ViewMsg_PrintPage_Params>"); -} - -void ParamTraits<ViewMsg_PrintPages_Params>::Write(Message* m, - const param_type& p) { - WriteParam(m, p.params); - WriteParam(m, p.pages); -} - -bool ParamTraits<ViewMsg_PrintPages_Params>::Read(const Message* m, - void** iter, - param_type* p) { - return ReadParam(m, iter, &p->params) && - ReadParam(m, iter, &p->pages); -} - -void ParamTraits<ViewMsg_PrintPages_Params>::Log(const param_type& p, - std::string* l) { - l->append("<ViewMsg_PrintPages_Params>"); -} - -void ParamTraits<ViewHostMsg_DidPreviewDocument_Params>::Write(Message* m, - const param_type& p) { - WriteParam(m, p.metafile_data_handle); - WriteParam(m, p.data_size); - WriteParam(m, p.document_cookie); - WriteParam(m, p.expected_pages_count); -} - -bool ParamTraits<ViewHostMsg_DidPreviewDocument_Params>::Read(const Message* m, - void** iter, - param_type* p) { - return ReadParam(m, iter, &p->metafile_data_handle) && - ReadParam(m, iter, &p->data_size) && - ReadParam(m, iter, &p->document_cookie) && - ReadParam(m, iter, &p->expected_pages_count); -} - -void ParamTraits<ViewHostMsg_DidPreviewDocument_Params>::Log( - const param_type& p, std::string* l) { - l->append("<ViewHostMsg_DidPreviewDocument_Params>"); -} - -void ParamTraits<ViewHostMsg_DidPrintPage_Params>::Write(Message* m, - const param_type& p) { - WriteParam(m, p.metafile_data_handle); - WriteParam(m, p.data_size); - WriteParam(m, p.document_cookie); - WriteParam(m, p.page_number); - WriteParam(m, p.actual_shrink); - WriteParam(m, p.page_size); - WriteParam(m, p.content_area); - WriteParam(m, p.has_visible_overlays); -} - -bool ParamTraits<ViewHostMsg_DidPrintPage_Params>::Read(const Message* m, - void** iter, - param_type* p) { - return ReadParam(m, iter, &p->metafile_data_handle) && - ReadParam(m, iter, &p->data_size) && - ReadParam(m, iter, &p->document_cookie) && - ReadParam(m, iter, &p->page_number) && - ReadParam(m, iter, &p->actual_shrink) && - ReadParam(m, iter, &p->page_size) && - ReadParam(m, iter, &p->content_area) && - ReadParam(m, iter, &p->has_visible_overlays); -} - -void ParamTraits<ViewHostMsg_DidPrintPage_Params>::Log(const param_type& p, - std::string* l) { - l->append("<ViewHostMsg_DidPrintPage_Params>"); -} - -void ParamTraits<ViewHostMsg_ScriptedPrint_Params>::Write(Message* m, - const param_type& p) { - WriteParam(m, p.routing_id); - WriteParam(m, p.host_window_id); - WriteParam(m, p.cookie); - WriteParam(m, p.expected_pages_count); - WriteParam(m, p.has_selection); - WriteParam(m, p.use_overlays); -} - -bool ParamTraits<ViewHostMsg_ScriptedPrint_Params>::Read(const Message* m, - void** iter, - param_type* p) { - return - ReadParam(m, iter, &p->routing_id) && - ReadParam(m, iter, &p->host_window_id) && - ReadParam(m, iter, &p->cookie) && - ReadParam(m, iter, &p->expected_pages_count) && - ReadParam(m, iter, &p->has_selection) && - ReadParam(m, iter, &p->use_overlays); -} - -void ParamTraits<ViewHostMsg_ScriptedPrint_Params>::Log(const param_type& p, - std::string* l) { - l->append("("); - LogParam(p.routing_id, l); - l->append(", "); - LogParam(p.host_window_id, l); - l->append(", "); - LogParam(p.cookie, l); - l->append(", "); - LogParam(p.expected_pages_count, l); - l->append(", "); - LogParam(p.has_selection, l); - l->append(","); - LogParam(p.use_overlays, l); - l->append(")"); -} - void ParamTraits<ViewMsg_ExecuteCode_Params>::Write(Message* m, const param_type& p) { WriteParam(m, p.request_id); diff --git a/chrome/common/render_messages_params.h b/chrome/common/render_messages_params.h index 31f261f..f7bf677 100644 --- a/chrome/common/render_messages_params.h +++ b/chrome/common/render_messages_params.h @@ -7,30 +7,13 @@ #pragma once #include <string> -#include <vector> -#include "app/surface/transport_dib.h" -#include "base/file_path.h" -#include "base/ref_counted.h" -#include "base/shared_memory.h" -#include "base/time.h" #include "base/values.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_extent.h" #include "chrome/common/extensions/url_pattern.h" -#include "content/common/navigation_types.h" -#include "content/common/page_transition_types.h" -#include "content/common/serialized_script_value.h" #include "googleurl/src/gurl.h" #include "ipc/ipc_param_traits.h" -#include "ui/gfx/native_widget_types.h" -#include "ui/gfx/rect.h" -#include "ui/gfx/size.h" -#include "webkit/glue/password_form.h" -#include "webkit/glue/webaccessibility.h" - -// TODO(erg): Split this file into $1_db_params.h, $1_audio_params.h, -// $1_print_params.h and $1_render_params.h. namespace net { class UploadData; @@ -121,139 +104,6 @@ struct ViewHostMsg_GetSearchProviderInstallState_Params { } }; -// Parameters for a render request. -struct ViewMsg_Print_Params { - ViewMsg_Print_Params(); - ~ViewMsg_Print_Params(); - - // Physical size of the page, including non-printable margins, - // in pixels according to dpi. - gfx::Size page_size; - - // In pixels according to dpi_x and dpi_y. - gfx::Size printable_size; - - // The y-offset of the printable area, in pixels according to dpi. - int margin_top; - - // The x-offset of the printable area, in pixels according to dpi. - int margin_left; - - // Specifies dots per inch. - double dpi; - - // Minimum shrink factor. See PrintSettings::min_shrink for more information. - double min_shrink; - - // Maximum shrink factor. See PrintSettings::max_shrink for more information. - double max_shrink; - - // Desired apparent dpi on paper. - int desired_dpi; - - // Cookie for the document to ensure correctness. - int document_cookie; - - // Should only print currently selected text. - bool selection_only; - - // Does the printer support alpha blending? - bool supports_alpha_blend; - - // Warning: do not compare document_cookie. - bool Equals(const ViewMsg_Print_Params& rhs) const; - - // Checking if the current params is empty. Just initialized after a memset. - bool IsEmpty() const; -}; - -struct ViewMsg_PrintPage_Params { - ViewMsg_PrintPage_Params(); - ~ViewMsg_PrintPage_Params(); - - // Parameters to render the page as a printed page. It must always be the same - // value for all the document. - ViewMsg_Print_Params params; - - // The page number is the indicator of the square that should be rendered - // according to the layout specified in ViewMsg_Print_Params. - int page_number; -}; - -struct ViewMsg_PrintPages_Params { - ViewMsg_PrintPages_Params(); - ~ViewMsg_PrintPages_Params(); - - // Parameters to render the page as a printed page. It must always be the same - // value for all the document. - ViewMsg_Print_Params params; - - // If empty, this means a request to render all the printed pages. - std::vector<int> pages; -}; - -// Parameters to describe a rendered document. -struct ViewHostMsg_DidPreviewDocument_Params { - ViewHostMsg_DidPreviewDocument_Params(); - ~ViewHostMsg_DidPreviewDocument_Params(); - - // A shared memory handle to metafile data. - base::SharedMemoryHandle metafile_data_handle; - - // Size of metafile data. - uint32 data_size; - - // Cookie for the document to ensure correctness. - int document_cookie; - - // Store the expected pages count. - int expected_pages_count; -}; - -// Parameters to describe a rendered page. -struct ViewHostMsg_DidPrintPage_Params { - ViewHostMsg_DidPrintPage_Params(); - ~ViewHostMsg_DidPrintPage_Params(); - - // A shared memory handle to the EMF data. This data can be quite large so a - // memory map needs to be used. - base::SharedMemoryHandle metafile_data_handle; - - // Size of the metafile data. - uint32 data_size; - - // Cookie for the document to ensure correctness. - int document_cookie; - - // Page number. - int page_number; - - // Shrink factor used to render this page. - double actual_shrink; - - // The size of the page the page author specified. - gfx::Size page_size; - - // The printable area the page author specified. - gfx::Rect content_area; - - // True if the page has visible overlays. - bool has_visible_overlays; -}; - -// Parameters for the IPC message ViewHostMsg_ScriptedPrint -struct ViewHostMsg_ScriptedPrint_Params { - ViewHostMsg_ScriptedPrint_Params(); - ~ViewHostMsg_ScriptedPrint_Params(); - - int routing_id; - gfx::NativeViewId host_window_id; - int cookie; - int expected_pages_count; - bool has_selection; - bool use_overlays; -}; - // Allows an extension to execute code in a tab. struct ViewMsg_ExecuteCode_Params { ViewMsg_ExecuteCode_Params(); @@ -351,54 +201,6 @@ struct ParamTraits<ViewHostMsg_GetSearchProviderInstallState_Params> { }; template <> -struct ParamTraits<ViewMsg_Print_Params> { - typedef ViewMsg_Print_Params param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* p); - static void Log(const param_type& p, std::string* l); -}; - -template <> -struct ParamTraits<ViewMsg_PrintPage_Params> { - typedef ViewMsg_PrintPage_Params param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* p); - static void Log(const param_type& p, std::string* l); -}; - -template <> -struct ParamTraits<ViewMsg_PrintPages_Params> { - typedef ViewMsg_PrintPages_Params param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* p); - static void Log(const param_type& p, std::string* l); -}; - -template <> -struct ParamTraits<ViewHostMsg_DidPreviewDocument_Params> { - typedef ViewHostMsg_DidPreviewDocument_Params param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* p); - static void Log(const param_type& p, std::string* l); -}; - -template <> -struct ParamTraits<ViewHostMsg_DidPrintPage_Params> { - typedef ViewHostMsg_DidPrintPage_Params param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* p); - static void Log(const param_type& p, std::string* l); -}; - -template <> -struct ParamTraits<ViewHostMsg_ScriptedPrint_Params> { - typedef ViewHostMsg_ScriptedPrint_Params param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* p); - static void Log(const param_type& p, std::string* l); -}; - -template <> struct ParamTraits<ViewMsg_ExecuteCode_Params> { typedef ViewMsg_ExecuteCode_Params param_type; static void Write(Message* m, const param_type& p); diff --git a/chrome/renderer/mock_printer.cc b/chrome/renderer/mock_printer.cc index 982ab80..5b46804 100644 --- a/chrome/renderer/mock_printer.cc +++ b/chrome/renderer/mock_printer.cc @@ -6,8 +6,7 @@ #include "base/file_util.h" #include "base/shared_memory.h" -#include "chrome/common/render_messages.h" -#include "chrome/common/render_messages_params.h" +#include "chrome/common/print_messages.h" #include "ipc/ipc_message_utils.h" #include "printing/native_metafile_factory.h" #include "printing/native_metafile.h" @@ -53,14 +52,14 @@ void MockPrinter::ResetPrinter() { document_cookie_ = -1; } -void MockPrinter::GetDefaultPrintSettings(ViewMsg_Print_Params* params) { +void MockPrinter::GetDefaultPrintSettings(PrintMsg_Print_Params* params) { // Verify this printer is not processing a job. // Sorry, this mock printer is very fragile. EXPECT_EQ(-1, document_cookie_); // Assign a unit document cookie and set the print settings. document_cookie_ = CreateDocumentCookie(); - memset(params, 0, sizeof(ViewMsg_Print_Params)); + memset(params, 0, sizeof(PrintMsg_Print_Params)); params->dpi = dpi_; params->max_shrink = max_shrink_; params->min_shrink = min_shrink_; @@ -73,7 +72,7 @@ void MockPrinter::GetDefaultPrintSettings(ViewMsg_Print_Params* params) { params->margin_top = margin_top_; } -void MockPrinter::SetDefaultPrintSettings(const ViewMsg_Print_Params& params) { +void MockPrinter::SetDefaultPrintSettings(const PrintMsg_Print_Params& params) { dpi_ = params.dpi; max_shrink_ = params.max_shrink; min_shrink_ = params.min_shrink; @@ -88,11 +87,11 @@ void MockPrinter::SetDefaultPrintSettings(const ViewMsg_Print_Params& params) { void MockPrinter::ScriptedPrint(int cookie, int expected_pages_count, bool has_selection, - ViewMsg_PrintPages_Params* settings) { + PrintMsg_PrintPages_Params* settings) { // Verify the input parameters. EXPECT_EQ(document_cookie_, cookie); - memset(settings, 0, sizeof(ViewMsg_PrintPages_Params)); + memset(settings, 0, sizeof(PrintMsg_PrintPages_Params)); settings->params.dpi = dpi_; settings->params.max_shrink = max_shrink_; settings->params.min_shrink = min_shrink_; @@ -118,7 +117,7 @@ void MockPrinter::SetPrintedPagesCount(int cookie, int number_pages) { pages_.clear(); } -void MockPrinter::PrintPage(const ViewHostMsg_DidPrintPage_Params& params) { +void MockPrinter::PrintPage(const PrintHostMsg_DidPrintPage_Params& params) { // Verify the input parameter and update the printer status so that the // RenderViewTest class can verify the this function finishes without errors. EXPECT_EQ(PRINTER_PRINTING, printer_status_); diff --git a/chrome/renderer/mock_printer.h b/chrome/renderer/mock_printer.h index c1faad0..1eaac1a 100644 --- a/chrome/renderer/mock_printer.h +++ b/chrome/renderer/mock_printer.h @@ -15,9 +15,9 @@ #include "printing/image.h" #include "ui/gfx/size.h" -struct ViewMsg_Print_Params; -struct ViewMsg_PrintPages_Params; -struct ViewHostMsg_DidPrintPage_Params; +struct PrintMsg_Print_Params; +struct PrintMsg_PrintPages_Params; +struct PrintHostMsg_DidPrintPage_Params; // A class which represents an output page used in the MockPrinter class. // The MockPrinter class stores output pages in a vector, so, this class @@ -67,16 +67,16 @@ class MockPrinter { // Functions that changes settings of a pseudo printer. void ResetPrinter(); - void SetDefaultPrintSettings(const ViewMsg_Print_Params& params); + void SetDefaultPrintSettings(const PrintMsg_Print_Params& params); // Functions that handles IPC events. - void GetDefaultPrintSettings(ViewMsg_Print_Params* params); + void GetDefaultPrintSettings(PrintMsg_Print_Params* params); void ScriptedPrint(int cookie, int expected_pages_count, bool has_selection, - ViewMsg_PrintPages_Params* settings); + PrintMsg_PrintPages_Params* settings); void SetPrintedPagesCount(int cookie, int number_pages); - void PrintPage(const ViewHostMsg_DidPrintPage_Params& params); + void PrintPage(const PrintHostMsg_DidPrintPage_Params& params); // Functions that retrieve the output pages. Status GetPrinterStatus() const { return printer_status_; } diff --git a/chrome/renderer/mock_render_thread.cc b/chrome/renderer/mock_render_thread.cc index 8f9d428..335f523 100644 --- a/chrome/renderer/mock_render_thread.cc +++ b/chrome/renderer/mock_render_thread.cc @@ -8,6 +8,7 @@ #include "base/file_util.h" #include "base/process_util.h" +#include "chrome/common/print_messages.h" #include "chrome/common/render_messages.h" #include "chrome/common/url_constants.h" #include "content/common/view_messages.h" @@ -105,14 +106,14 @@ bool MockRenderThread::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWidget, OnMsgCreateWidget) IPC_MESSAGE_HANDLER(ViewHostMsg_OpenChannelToExtension, OnMsgOpenChannelToExtension) - IPC_MESSAGE_HANDLER(ViewHostMsg_GetDefaultPrintSettings, + IPC_MESSAGE_HANDLER(PrintHostMsg_GetDefaultPrintSettings, OnGetDefaultPrintSettings) - IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptedPrint, + IPC_MESSAGE_HANDLER(PrintHostMsg_ScriptedPrint, OnScriptedPrint) #if defined(OS_WIN) || defined(OS_MACOSX) - IPC_MESSAGE_HANDLER(ViewHostMsg_DidGetPrintedPagesCount, + IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPrintedPagesCount, OnDidGetPrintedPagesCount) - IPC_MESSAGE_HANDLER(ViewHostMsg_DidPrintPage, OnDidPrintPage) + IPC_MESSAGE_HANDLER(PrintHostMsg_DidPrintPage, OnDidPrintPage) #endif #if defined(OS_WIN) IPC_MESSAGE_HANDLER(ViewHostMsg_DuplicateSection, OnDuplicateSection) @@ -120,9 +121,9 @@ bool MockRenderThread::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(ViewHostMsg_AllocateSharedMemoryBuffer, OnAllocateSharedMemoryBuffer) #if defined(OS_CHROMEOS) - IPC_MESSAGE_HANDLER(ViewHostMsg_AllocateTempFileForPrinting, + IPC_MESSAGE_HANDLER(PrintHostMsg_AllocateTempFileForPrinting, OnAllocateTempFileForPrinting) - IPC_MESSAGE_HANDLER(ViewHostMsg_TempFileForPrintingWritten, + IPC_MESSAGE_HANDLER(PrintHostMsg_TempFileForPrintingWritten, OnTempFileForPrintingWritten) #endif IPC_MESSAGE_UNHANDLED(handled = false) @@ -186,14 +187,15 @@ void MockRenderThread::OnTempFileForPrintingWritten(int browser_fd) { } #endif // defined(OS_CHROMEOS) -void MockRenderThread::OnGetDefaultPrintSettings(ViewMsg_Print_Params* params) { +void MockRenderThread::OnGetDefaultPrintSettings( + PrintMsg_Print_Params* params) { if (printer_.get()) printer_->GetDefaultPrintSettings(params); } void MockRenderThread::OnScriptedPrint( - const ViewHostMsg_ScriptedPrint_Params& params, - ViewMsg_PrintPages_Params* settings) { + const PrintHostMsg_ScriptedPrint_Params& params, + PrintMsg_PrintPages_Params* settings) { if (print_dialog_user_response_ && printer_.get()) { printer_->ScriptedPrint(params.cookie, params.expected_pages_count, @@ -208,7 +210,7 @@ void MockRenderThread::OnDidGetPrintedPagesCount(int cookie, int number_pages) { } void MockRenderThread::OnDidPrintPage( - const ViewHostMsg_DidPrintPage_Params& params) { + const PrintHostMsg_DidPrintPage_Params& params) { if (printer_.get()) printer_->PrintPage(params); } diff --git a/chrome/renderer/mock_render_thread.h b/chrome/renderer/mock_render_thread.h index ffe695e..b30d31e 100644 --- a/chrome/renderer/mock_render_thread.h +++ b/chrome/renderer/mock_render_thread.h @@ -18,9 +18,9 @@ namespace IPC { class MessageReplyDeserializer; } -struct ViewMsg_Print_Params; -struct ViewMsg_PrintPages_Params; -struct ViewHostMsg_ScriptedPrint_Params; +struct PrintMsg_Print_Params; +struct PrintMsg_PrintPages_Params; +struct PrintHostMsg_ScriptedPrint_Params; // This class is very simple mock of RenderThread. It simulates an IPC channel // which supports only two messages: @@ -117,14 +117,14 @@ class MockRenderThread : public RenderThreadBase { #endif // The RenderView expects default print settings. - void OnGetDefaultPrintSettings(ViewMsg_Print_Params* setting); + void OnGetDefaultPrintSettings(PrintMsg_Print_Params* setting); // The RenderView expects final print settings from the user. - void OnScriptedPrint(const ViewHostMsg_ScriptedPrint_Params& params, - ViewMsg_PrintPages_Params* settings); + void OnScriptedPrint(const PrintHostMsg_ScriptedPrint_Params& params, + PrintMsg_PrintPages_Params* settings); void OnDidGetPrintedPagesCount(int cookie, int number_pages); - void OnDidPrintPage(const ViewHostMsg_DidPrintPage_Params& params); + void OnDidPrintPage(const PrintHostMsg_DidPrintPage_Params& params); IPC::TestSink sink_; diff --git a/chrome/renderer/print_web_view_helper.cc b/chrome/renderer/print_web_view_helper.cc index 43afd70..8a33b9c 100644 --- a/chrome/renderer/print_web_view_helper.cc +++ b/chrome/renderer/print_web_view_helper.cc @@ -11,7 +11,7 @@ #include "base/process_util.h" #include "base/utf_string_conversions.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/render_messages.h" +#include "chrome/common/print_messages.h" #include "content/common/view_messages.h" #include "content/renderer/render_view.h" #include "grit/generated_resources.h" @@ -47,7 +47,7 @@ using WebKit::WebView; namespace { -int GetDPI(const ViewMsg_Print_Params* print_params) { +int GetDPI(const PrintMsg_Print_Params* print_params) { #if defined(OS_MACOSX) // On the Mac, the printable area is in points, don't do any scaling based // on dpi. @@ -57,10 +57,18 @@ int GetDPI(const ViewMsg_Print_Params* print_params) { #endif // defined(OS_MACOSX) } +bool PrintMsg_Print_Params_IsEmpty(const PrintMsg_Print_Params& params) { + return !params.document_cookie && !params.desired_dpi && !params.max_shrink && + !params.min_shrink && !params.dpi && params.printable_size.IsEmpty() && + !params.selection_only && params.page_size.IsEmpty() && + !params.margin_top && !params.margin_left && + !params.supports_alpha_blend; +} + } // namespace PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint( - const ViewMsg_Print_Params& print_params, + const PrintMsg_Print_Params& print_params, WebFrame* frame, WebNode* node, WebView* web_view) @@ -127,7 +135,7 @@ void PrintWebViewHelper::ScriptInitiatedPrint(WebKit::WebFrame* frame) { if (is_preview_) { script_initiated_preview_frame_ = frame; - if (!render_view()->Send(new ViewHostMsg_ScriptInitiatedPrintPreview( + if (!render_view()->Send(new PrintHostMsg_ScriptInitiatedPrintPreview( render_view()->routing_id()))) { NOTREACHED(); return; @@ -140,14 +148,14 @@ void PrintWebViewHelper::ScriptInitiatedPrint(WebKit::WebFrame* frame) { bool PrintWebViewHelper::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(PrintWebViewHelper, message) - IPC_MESSAGE_HANDLER(ViewMsg_PrintForPrintPreview, + IPC_MESSAGE_HANDLER(PrintMsg_PrintForPrintPreview, OnPrintForPrintPreview) - IPC_MESSAGE_HANDLER(ViewMsg_PrintPages, OnPrintPages) - IPC_MESSAGE_HANDLER(ViewMsg_PrintingDone, OnPrintingDone) - IPC_MESSAGE_HANDLER(ViewMsg_PrintPreview, OnPrintPreview) - IPC_MESSAGE_HANDLER(ViewMsg_PrintNodeUnderContextMenu, + IPC_MESSAGE_HANDLER(PrintMsg_PrintPages, OnPrintPages) + IPC_MESSAGE_HANDLER(PrintMsg_PrintingDone, OnPrintingDone) + IPC_MESSAGE_HANDLER(PrintMsg_PrintPreview, OnPrintPreview) + IPC_MESSAGE_HANDLER(PrintMsg_PrintNodeUnderContextMenu, OnPrintNodeUnderContextMenu) - IPC_MESSAGE_HANDLER(ViewMsg_ResetScriptedPrintCount, + IPC_MESSAGE_HANDLER(PrintMsg_ResetScriptedPrintCount, ResetScriptedPrintCount) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -254,7 +262,7 @@ void PrintWebViewHelper::OnPrintNodeUnderContextMenu() { // its |context_menu_node_|. if (is_preview_) { context_menu_preview_node_.reset(new WebNode(context_menu_node)); - if (!render_view()->Send(new ViewHostMsg_PrintPreviewNodeUnderContextMenu( + if (!render_view()->Send(new PrintHostMsg_PrintPreviewNodeUnderContextMenu( render_view()->routing_id()))) { NOTREACHED(); return; @@ -371,10 +379,10 @@ bool PrintWebViewHelper::CopyAndPrint(WebKit::WebFrame* web_frame) { } #if defined(OS_MACOSX) || defined(OS_WIN) -void PrintWebViewHelper::PrintPages(const ViewMsg_PrintPages_Params& params, +void PrintWebViewHelper::PrintPages(const PrintMsg_PrintPages_Params& params, WebFrame* frame, WebNode* node) { - ViewMsg_Print_Params printParams = params.params; + PrintMsg_Print_Params printParams = params.params; UpdatePrintableSizeInPrintParameters(frame, node, &printParams); PrepareFrameAndViewForPrint prep_frame_view(printParams, @@ -383,13 +391,13 @@ void PrintWebViewHelper::PrintPages(const ViewMsg_PrintPages_Params& params, frame->view()); int page_count = prep_frame_view.GetExpectedPageCount(); - render_view()->Send(new ViewHostMsg_DidGetPrintedPagesCount( + render_view()->Send(new PrintHostMsg_DidGetPrintedPagesCount( render_view()->routing_id(), printParams.document_cookie, page_count)); if (!page_count) return; const gfx::Size& canvas_size = prep_frame_view.GetPrintCanvasSize(); - ViewMsg_PrintPage_Params page_params; + PrintMsg_PrintPage_Params page_params; page_params.params = printParams; if (params.pages.empty()) { for (int i = 0; i < page_count; ++i) { @@ -408,7 +416,7 @@ void PrintWebViewHelper::PrintPages(const ViewMsg_PrintPages_Params& params, #endif // OS_MACOSX || OS_WIN void PrintWebViewHelper::didStopLoading() { - ViewMsg_PrintPages_Params* params = print_pages_params_.get(); + PrintMsg_PrintPages_Params* params = print_pages_params_.get(); DCHECK(params != NULL); PrintPages(*params, print_web_view_->mainFrame(), NULL); } @@ -416,7 +424,7 @@ void PrintWebViewHelper::didStopLoading() { void PrintWebViewHelper::GetPageSizeAndMarginsInPoints( WebFrame* frame, int page_index, - const ViewMsg_Print_Params& default_params, + const PrintMsg_Print_Params& default_params, double* content_width_in_points, double* content_height_in_points, double* margin_top_in_points, @@ -492,7 +500,7 @@ void PrintWebViewHelper::GetPageSizeAndMarginsInPoints( void PrintWebViewHelper::UpdatePrintableSizeInPrintParameters( WebFrame* frame, WebNode* node, - ViewMsg_Print_Params* params) { + PrintMsg_Print_Params* params) { double content_width_in_points; double content_height_in_points; double margin_top_in_points; @@ -530,9 +538,9 @@ void PrintWebViewHelper::UpdatePrintableSizeInPrintParameters( bool PrintWebViewHelper::InitPrintSettings(WebKit::WebFrame* frame, WebKit::WebNode* node) { - ViewMsg_PrintPages_Params settings; + PrintMsg_PrintPages_Params settings; - if (!render_view()->Send(new ViewHostMsg_GetDefaultPrintSettings( + if (!render_view()->Send(new PrintHostMsg_GetDefaultPrintSettings( render_view()->routing_id(), &settings.params))) { NOTREACHED(); return false; @@ -540,7 +548,7 @@ bool PrintWebViewHelper::InitPrintSettings(WebKit::WebFrame* frame, // Check if the printer returned any settings, if the settings is empty, we // can safely assume there are no printer drivers configured. So we safely // terminate. - if (settings.params.IsEmpty()) { + if (PrintMsg_Print_Params_IsEmpty(settings.params)) { render_view()->runModalAlertDialog( frame, l10n_util::GetStringUTF16(IDS_DEFAULT_PRINTER_NOT_FOUND_WARNING)); @@ -553,29 +561,29 @@ bool PrintWebViewHelper::InitPrintSettings(WebKit::WebFrame* frame, } UpdatePrintableSizeInPrintParameters(frame, node, &settings.params); settings.pages.clear(); - print_pages_params_.reset(new ViewMsg_PrintPages_Params(settings)); + print_pages_params_.reset(new PrintMsg_PrintPages_Params(settings)); return true; } bool PrintWebViewHelper::UpdatePrintSettings( const DictionaryValue& job_settings) { - ViewMsg_PrintPages_Params settings; - if (!render_view()->Send(new ViewHostMsg_UpdatePrintSettings( + PrintMsg_PrintPages_Params settings; + if (!render_view()->Send(new PrintHostMsg_UpdatePrintSettings( render_view()->routing_id(), print_pages_params_->params.document_cookie, job_settings, &settings))) { NOTREACHED(); return false; } - print_pages_params_.reset(new ViewMsg_PrintPages_Params(settings)); + print_pages_params_.reset(new PrintMsg_PrintPages_Params(settings)); return true; } bool PrintWebViewHelper::GetPrintSettingsFromUser(WebKit::WebFrame* frame, int expected_pages_count, bool use_browser_overlays) { - ViewHostMsg_ScriptedPrint_Params params; - ViewMsg_PrintPages_Params print_settings; + PrintHostMsg_ScriptedPrint_Params params; + PrintMsg_PrintPages_Params print_settings; // The routing id is sent across as it is needed to look up the // corresponding RenderViewHost instance to signal and reset the @@ -591,11 +599,11 @@ bool PrintWebViewHelper::GetPrintSettingsFromUser(WebKit::WebFrame* frame, params.use_overlays = use_browser_overlays; print_pages_params_.reset(); - IPC::SyncMessage* msg = new ViewHostMsg_ScriptedPrint( + IPC::SyncMessage* msg = new PrintHostMsg_ScriptedPrint( render_view()->routing_id(), params, &print_settings); msg->EnableMessagePumping(); if (render_view()->Send(msg)) { - print_pages_params_.reset(new ViewMsg_PrintPages_Params(print_settings)); + print_pages_params_.reset(new PrintMsg_PrintPages_Params(print_settings)); } else { // Send() failed. NOTREACHED(); @@ -606,7 +614,7 @@ bool PrintWebViewHelper::GetPrintSettingsFromUser(WebKit::WebFrame* frame, void PrintWebViewHelper::RenderPagesForPrint(WebKit::WebFrame* frame, WebKit::WebNode* node) { - ViewMsg_PrintPages_Params print_settings = *print_pages_params_; + PrintMsg_PrintPages_Params print_settings = *print_pages_params_; if (print_settings.params.selection_only) { CopyAndPrint(frame); } else { @@ -617,7 +625,7 @@ void PrintWebViewHelper::RenderPagesForPrint(WebKit::WebFrame* frame, void PrintWebViewHelper::RenderPagesForPreview(WebKit::WebFrame* frame, WebKit::WebNode* node) { - ViewMsg_PrintPages_Params print_settings = *print_pages_params_; + PrintMsg_PrintPages_Params print_settings = *print_pages_params_; // TODO(kmadhusu): Handle print selection. CreatePreviewDocument(print_settings, frame, node); } diff --git a/chrome/renderer/print_web_view_helper.h b/chrome/renderer/print_web_view_helper.h index 548f177..c8b44d6 100644 --- a/chrome/renderer/print_web_view_helper.h +++ b/chrome/renderer/print_web_view_helper.h @@ -16,9 +16,9 @@ #include "ui/gfx/size.h" class DictionaryValue; -struct ViewMsg_Print_Params; -struct ViewMsg_PrintPage_Params; -struct ViewMsg_PrintPages_Params; +struct PrintMsg_Print_Params; +struct PrintMsg_PrintPage_Params; +struct PrintMsg_PrintPages_Params; #if defined(USE_X11) namespace skia { @@ -34,7 +34,7 @@ class PrepareFrameAndViewForPrint { public: // Prints |frame|. If |node| is not NULL, then only that node will be // printed. - PrepareFrameAndViewForPrint(const ViewMsg_Print_Params& print_params, + PrepareFrameAndViewForPrint(const PrintMsg_Print_Params& print_params, WebKit::WebFrame* frame, WebKit::WebNode* node, WebKit::WebView* web_view); @@ -143,19 +143,19 @@ class PrintWebViewHelper : public RenderViewObserver , // Prints all the pages listed in |params|. // It will implicitly revert the document to display CSS media type. - void PrintPages(const ViewMsg_PrintPages_Params& params, + void PrintPages(const PrintMsg_PrintPages_Params& params, WebKit::WebFrame* frame, WebKit::WebNode* node); // Prints the page listed in |params|. #if defined(USE_X11) - void PrintPage(const ViewMsg_PrintPage_Params& params, + void PrintPage(const PrintMsg_PrintPage_Params& params, const gfx::Size& canvas_size, WebKit::WebFrame* frame, printing::NativeMetafile* metafile, scoped_ptr<skia::VectorCanvas>* canvas); #else - void PrintPage(const ViewMsg_PrintPage_Params& params, + void PrintPage(const PrintMsg_PrintPage_Params& params, const gfx::Size& canvas_size, WebKit::WebFrame* frame); #endif @@ -167,15 +167,15 @@ class PrintWebViewHelper : public RenderViewObserver , void RenderPagesForPreview(WebKit::WebFrame* frame, WebKit::WebNode* node); // Renders all the pages listed in |params| for preview. - // On success, Send ViewHostMsg_PagesReadyForPreview message with a + // On success, Send PrintHostMsg_PagesReadyForPreview message with a // valid metafile data handle. - void CreatePreviewDocument(const ViewMsg_PrintPages_Params& params, + void CreatePreviewDocument(const PrintMsg_PrintPages_Params& params, WebKit::WebFrame* frame, WebKit::WebNode* node); // Platform specific helper function for rendering page(s) to |metafile|. #if defined(OS_WIN) - void RenderPage(const ViewMsg_Print_Params& params, float* scale_factor, + void RenderPage(const PrintMsg_Print_Params& params, float* scale_factor, int page_number, WebKit::WebFrame* frame, scoped_ptr<printing::NativeMetafile>* metafile); #elif defined(OS_MACOSX) @@ -183,7 +183,7 @@ class PrintWebViewHelper : public RenderViewObserver , const float& scale_factor, int page_number, WebKit::WebFrame* frame, printing::NativeMetafile* metafile); #elif defined(OS_POSIX) - bool RenderPages(const ViewMsg_PrintPages_Params& params, + bool RenderPages(const PrintMsg_PrintPages_Params& params, WebKit::WebFrame* frame, WebKit::WebNode* node, bool send_expected_page_count, @@ -201,7 +201,7 @@ class PrintWebViewHelper : public RenderViewObserver , static void GetPageSizeAndMarginsInPoints( WebKit::WebFrame* frame, int page_index, - const ViewMsg_Print_Params& default_params, + const PrintMsg_Print_Params& default_params, double* content_width_in_points, double* content_height_in_points, double* margin_top_in_points, @@ -211,7 +211,7 @@ class PrintWebViewHelper : public RenderViewObserver , void UpdatePrintableSizeInPrintParameters(WebKit::WebFrame* frame, WebKit::WebNode* node, - ViewMsg_Print_Params* params); + PrintMsg_Print_Params* params); bool GetPrintFrame(WebKit::WebFrame** frame); @@ -236,7 +236,7 @@ class PrintWebViewHelper : public RenderViewObserver , // The node under the context menu to print preview. scoped_ptr<WebKit::WebNode> context_menu_preview_node_; - scoped_ptr<ViewMsg_PrintPages_Params> print_pages_params_; + scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_; base::Time last_cancelled_script_print_; int user_cancelled_scripted_print_count_; bool is_preview_; diff --git a/chrome/renderer/print_web_view_helper_linux.cc b/chrome/renderer/print_web_view_helper_linux.cc index a989880..65370c7 100644 --- a/chrome/renderer/print_web_view_helper_linux.cc +++ b/chrome/renderer/print_web_view_helper_linux.cc @@ -7,7 +7,7 @@ #include "base/file_descriptor_posix.h" #include "base/logging.h" #include "base/scoped_ptr.h" -#include "chrome/common/render_messages.h" +#include "chrome/common/print_messages.h" #include "content/common/view_messages.h" #include "printing/native_metafile_factory.h" #include "printing/native_metafile.h" @@ -23,7 +23,7 @@ using WebKit::WebFrame; using WebKit::WebNode; void PrintWebViewHelper::CreatePreviewDocument( - const ViewMsg_PrintPages_Params& params, WebKit::WebFrame* frame, + const PrintMsg_PrintPages_Params& params, WebKit::WebFrame* frame, WebKit::WebNode* node) { // We only can use PDF in the renderer because Cairo needs to create a // temporary file for a PostScript surface. @@ -38,7 +38,7 @@ void PrintWebViewHelper::CreatePreviewDocument( uint32 buf_size = metafile->GetDataSize(); DCHECK_GT(buf_size, 0u); - ViewHostMsg_DidPreviewDocument_Params preview_params; + PrintHostMsg_DidPreviewDocument_Params preview_params; preview_params.document_cookie = params.params.document_cookie; preview_params.expected_pages_count = page_count; preview_params.data_size = buf_size; @@ -48,10 +48,10 @@ void PrintWebViewHelper::CreatePreviewDocument( preview_params.expected_pages_count = 0; preview_params.data_size = 0; } - Send(new ViewHostMsg_PagesReadyForPreview(routing_id(), preview_params)); + Send(new PrintHostMsg_PagesReadyForPreview(routing_id(), preview_params)); } -void PrintWebViewHelper::PrintPages(const ViewMsg_PrintPages_Params& params, +void PrintWebViewHelper::PrintPages(const PrintMsg_PrintPages_Params& params, WebFrame* frame, WebNode* node) { // We only can use PDF in the renderer because Cairo needs to create a @@ -80,17 +80,17 @@ void PrintWebViewHelper::PrintPages(const ViewMsg_PrintPages_Params& params, base::FileDescriptor fd; // Ask the browser to open a file for us. - if (!Send(new ViewHostMsg_AllocateTempFileForPrinting(&fd, - &sequence_number))) { + if (!Send(new PrintHostMsg_AllocateTempFileForPrinting(&fd, + &sequence_number))) { return; } if (!metafile->SaveToFD(fd)) return; // Tell the browser we've finished writing the file. - Send(new ViewHostMsg_TempFileForPrintingWritten(sequence_number)); + Send(new PrintHostMsg_TempFileForPrintingWritten(sequence_number)); #else - ViewHostMsg_DidPrintPage_Params printed_page_params; + PrintHostMsg_DidPrintPage_Params printed_page_params; printed_page_params.data_size = 0; printed_page_params.document_cookie = params.params.document_cookie; @@ -120,36 +120,36 @@ void PrintWebViewHelper::PrintPages(const ViewMsg_PrintPages_Params& params, if (params.pages.empty()) { // Send the first page with a valid handle. printed_page_params.page_number = 0; - Send(new ViewHostMsg_DidPrintPage(routing_id(), printed_page_params)); + Send(new PrintHostMsg_DidPrintPage(routing_id(), printed_page_params)); // Send the rest of the pages with an invalid metafile handle. printed_page_params.metafile_data_handle.fd = -1; for (int i = 1; i < page_count; ++i) { printed_page_params.page_number = i; - Send(new ViewHostMsg_DidPrintPage(routing_id(), printed_page_params)); + Send(new PrintHostMsg_DidPrintPage(routing_id(), printed_page_params)); } } else { // Send the first page with a valid handle. printed_page_params.page_number = params.pages[0]; - Send(new ViewHostMsg_DidPrintPage(routing_id(), printed_page_params)); + Send(new PrintHostMsg_DidPrintPage(routing_id(), printed_page_params)); // Send the rest of the pages with an invalid metafile handle. printed_page_params.metafile_data_handle.fd = -1; for (size_t i = 1; i < params.pages.size(); ++i) { printed_page_params.page_number = params.pages[i]; - Send(new ViewHostMsg_DidPrintPage(routing_id(), printed_page_params)); + Send(new PrintHostMsg_DidPrintPage(routing_id(), printed_page_params)); } } #endif // defined(OS_CHROMEOS) } -bool PrintWebViewHelper::RenderPages(const ViewMsg_PrintPages_Params& params, +bool PrintWebViewHelper::RenderPages(const PrintMsg_PrintPages_Params& params, WebKit::WebFrame* frame, WebKit::WebNode* node, bool send_expected_page_count, int* page_count, printing::NativeMetafile* metafile) { - ViewMsg_Print_Params printParams = params.params; + PrintMsg_Print_Params printParams = params.params; scoped_ptr<skia::VectorCanvas> canvas; { @@ -164,16 +164,16 @@ bool PrintWebViewHelper::RenderPages(const ViewMsg_PrintPages_Params& params, frame->view()); *page_count = prep_frame_view.GetExpectedPageCount(); if (send_expected_page_count) { - Send(new ViewHostMsg_DidGetPrintedPagesCount(routing_id(), - printParams.document_cookie, - *page_count)); + Send(new PrintHostMsg_DidGetPrintedPagesCount(routing_id(), + printParams.document_cookie, + *page_count)); } if (!*page_count) return false; metafile->Init(); - ViewMsg_PrintPage_Params page_params; + PrintMsg_PrintPage_Params page_params; page_params.params = printParams; const gfx::Size& canvas_size = prep_frame_view.GetPrintCanvasSize(); if (params.pages.empty()) { @@ -194,7 +194,7 @@ bool PrintWebViewHelper::RenderPages(const ViewMsg_PrintPages_Params& params, return true; } -void PrintWebViewHelper::PrintPage(const ViewMsg_PrintPage_Params& params, +void PrintWebViewHelper::PrintPage(const PrintMsg_PrintPage_Params& params, const gfx::Size& canvas_size, WebFrame* frame, printing::NativeMetafile* metafile, diff --git a/chrome/renderer/print_web_view_helper_mac.mm b/chrome/renderer/print_web_view_helper_mac.mm index c75790d..2ef74d3 100644 --- a/chrome/renderer/print_web_view_helper_mac.mm +++ b/chrome/renderer/print_web_view_helper_mac.mm @@ -8,15 +8,14 @@ #include "base/logging.h" #include "base/scoped_ptr.h" -#include "chrome/common/render_messages.h" -#include "chrome/common/render_messages_params.h" +#include "chrome/common/print_messages.h" #include "printing/native_metafile_factory.h" #include "printing/native_metafile.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" using WebKit::WebFrame; -void PrintWebViewHelper::PrintPage(const ViewMsg_PrintPage_Params& params, +void PrintWebViewHelper::PrintPage(const PrintMsg_PrintPage_Params& params, const gfx::Size& canvas_size, WebFrame* frame) { scoped_ptr<printing::NativeMetafile> metafile( @@ -33,7 +32,7 @@ void PrintWebViewHelper::PrintPage(const ViewMsg_PrintPage_Params& params, frame, metafile.get()); metafile->FinishDocument(); - ViewHostMsg_DidPrintPage_Params page_params; + PrintHostMsg_DidPrintPage_Params page_params; page_params.data_size = metafile->GetDataSize(); page_params.page_number = page_number; page_params.document_cookie = params.params.document_cookie; @@ -50,13 +49,13 @@ void PrintWebViewHelper::PrintPage(const ViewMsg_PrintPage_Params& params, page_params.data_size = 0; } - Send(new ViewHostMsg_DidPrintPage(routing_id(), page_params)); + Send(new PrintHostMsg_DidPrintPage(routing_id(), page_params)); } void PrintWebViewHelper::CreatePreviewDocument( - const ViewMsg_PrintPages_Params& params, WebKit::WebFrame* frame, + const PrintMsg_PrintPages_Params& params, WebKit::WebFrame* frame, WebKit::WebNode* node) { - ViewMsg_Print_Params printParams = params.params; + PrintMsg_Print_Params printParams = params.params; UpdatePrintableSizeInPrintParameters(frame, node, &printParams); PrepareFrameAndViewForPrint prep_frame_view(printParams, @@ -88,7 +87,7 @@ void PrintWebViewHelper::CreatePreviewDocument( } metafile->FinishDocument(); - ViewHostMsg_DidPreviewDocument_Params preview_params; + PrintHostMsg_DidPreviewDocument_Params preview_params; preview_params.data_size = metafile->GetDataSize(); preview_params.document_cookie = params.params.document_cookie; preview_params.expected_pages_count = page_count; @@ -99,7 +98,7 @@ void PrintWebViewHelper::CreatePreviewDocument( preview_params.data_size = 0; preview_params.expected_pages_count = 0; } - Send(new ViewHostMsg_PagesReadyForPreview(routing_id(), preview_params)); + Send(new PrintHostMsg_PagesReadyForPreview(routing_id(), preview_params)); } void PrintWebViewHelper::RenderPage( diff --git a/chrome/renderer/print_web_view_helper_win.cc b/chrome/renderer/print_web_view_helper_win.cc index 616c5b0..04da522 100644 --- a/chrome/renderer/print_web_view_helper_win.cc +++ b/chrome/renderer/print_web_view_helper_win.cc @@ -6,7 +6,7 @@ #include "base/logging.h" #include "base/process_util.h" -#include "chrome/common/render_messages.h" +#include "chrome/common/print_messages.h" #include "content/common/view_messages.h" #include "printing/native_metafile_factory.h" #include "printing/native_metafile.h" @@ -67,7 +67,7 @@ int CALLBACK EnhMetaFileProc(HDC dc, } // namespace -void PrintWebViewHelper::PrintPage(const ViewMsg_PrintPage_Params& params, +void PrintWebViewHelper::PrintPage(const PrintMsg_PrintPage_Params& params, const gfx::Size& canvas_size, WebFrame* frame) { // Generate a memory-based metafile. It will use the current screen's DPI. @@ -95,7 +95,7 @@ void PrintWebViewHelper::PrintPage(const ViewMsg_PrintPage_Params& params, uint32 buf_size = metafile->GetDataSize(); DCHECK_GT(buf_size, 128u); - ViewHostMsg_DidPrintPage_Params page_params; + PrintHostMsg_DidPrintPage_Params page_params; page_params.data_size = buf_size; page_params.metafile_data_handle = NULL; page_params.page_number = page_number; @@ -117,14 +117,14 @@ void PrintWebViewHelper::PrintPage(const ViewMsg_PrintPage_Params& params, &page_params.metafile_data_handle))) { NOTREACHED() << "Send message failed."; } - Send(new ViewHostMsg_DidPrintPage(routing_id(), page_params)); + Send(new PrintHostMsg_DidPrintPage(routing_id(), page_params)); } void PrintWebViewHelper::CreatePreviewDocument( - const ViewMsg_PrintPages_Params& params, WebKit::WebFrame* frame, + const PrintMsg_PrintPages_Params& params, WebKit::WebFrame* frame, WebKit::WebNode* node) { int page_count = 0; - ViewMsg_Print_Params print_params = params.params; + PrintMsg_Print_Params print_params = params.params; UpdatePrintableSizeInPrintParameters(frame, node, &print_params); PrepareFrameAndViewForPrint prep_frame_view(print_params, frame, node, frame->view()); @@ -172,7 +172,7 @@ void PrintWebViewHelper::CreatePreviewDocument( uint32 buf_size = metafile->GetDataSize(); DCHECK_GT(buf_size, 128u); - ViewHostMsg_DidPreviewDocument_Params preview_params; + PrintHostMsg_DidPreviewDocument_Params preview_params; preview_params.document_cookie = params.params.document_cookie; preview_params.data_size = buf_size; preview_params.metafile_data_handle = NULL; @@ -189,11 +189,11 @@ void PrintWebViewHelper::CreatePreviewDocument( &preview_params.metafile_data_handle))) { NOTREACHED() << "Send message failed."; } - Send(new ViewHostMsg_PagesReadyForPreview(routing_id(), preview_params)); + Send(new PrintHostMsg_PagesReadyForPreview(routing_id(), preview_params)); } void PrintWebViewHelper::RenderPage( - const ViewMsg_Print_Params& params, float* scale_factor, int page_number, + const PrintMsg_Print_Params& params, float* scale_factor, int page_number, WebFrame* frame, scoped_ptr<printing::NativeMetafile>* metafile) { DCHECK(metafile->get()->context()); diff --git a/chrome/test/render_view_test.cc b/chrome/test/render_view_test.cc index 46f48f9..7166309 100644 --- a/chrome/test/render_view_test.cc +++ b/chrome/test/render_view_test.cc @@ -6,6 +6,7 @@ #include "chrome/browser/extensions/extension_function_dispatcher.h" #include "chrome/common/extensions/extension.h" +#include "chrome/common/print_messages.h" #include "chrome/common/render_messages.h" #include "chrome/renderer/autofill/autofill_agent.h" #include "chrome/renderer/autofill/password_autofill_manager.h" @@ -267,11 +268,11 @@ void RenderViewTest::VerifyPageCount(int count) { #else const IPC::Message* page_cnt_msg = render_thread_.sink().GetUniqueMessageMatching( - ViewHostMsg_DidGetPrintedPagesCount::ID); + PrintHostMsg_DidGetPrintedPagesCount::ID); ASSERT_TRUE(page_cnt_msg); - ViewHostMsg_DidGetPrintedPagesCount::Param post_page_count_param; - ViewHostMsg_DidGetPrintedPagesCount::Read(page_cnt_msg, - &post_page_count_param); + PrintHostMsg_DidGetPrintedPagesCount::Param post_page_count_param; + PrintHostMsg_DidGetPrintedPagesCount::Read(page_cnt_msg, + &post_page_count_param); EXPECT_EQ(count, post_page_count_param.b); #endif // defined(OS_CHROMEOS) } @@ -279,17 +280,17 @@ void RenderViewTest::VerifyPageCount(int count) { void RenderViewTest::VerifyPagesPrinted(bool printed) { #if defined(OS_CHROMEOS) bool did_print_msg = (NULL != render_thread_.sink().GetUniqueMessageMatching( - ViewHostMsg_TempFileForPrintingWritten::ID)); + PrintHostMsg_TempFileForPrintingWritten::ID)); ASSERT_EQ(printed, did_print_msg); #else const IPC::Message* print_msg = render_thread_.sink().GetUniqueMessageMatching( - ViewHostMsg_DidPrintPage::ID); + PrintHostMsg_DidPrintPage::ID); bool did_print_msg = (NULL != print_msg); ASSERT_EQ(printed, did_print_msg); if (printed) { - ViewHostMsg_DidPrintPage::Param post_did_print_page_param; - ViewHostMsg_DidPrintPage::Read(print_msg, &post_did_print_page_param); + PrintHostMsg_DidPrintPage::Param post_did_print_page_param; + PrintHostMsg_DidPrintPage::Read(print_msg, &post_did_print_page_param); EXPECT_EQ(0, post_did_print_page_param.a.page_number); } #endif // defined(OS_CHROMEOS) diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc index b7a13d5..fec5bf1 100644 --- a/content/browser/renderer_host/render_view_host.cc +++ b/content/browser/renderer_host/render_view_host.cc @@ -26,7 +26,7 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/net/url_request_context_getter.h" #include "chrome/common/render_messages.h" -#include "chrome/common/render_messages_params.h" +#include "chrome/common/print_messages.h" #include "chrome/common/safebrowsing_messages.h" #include "chrome/common/thumbnail_score.h" #include "chrome/common/translate_errors.h" @@ -365,17 +365,17 @@ void RenderViewHost::ReloadFrame() { } bool RenderViewHost::PrintPages() { - return Send(new ViewMsg_PrintPages(routing_id())); + return Send(new PrintMsg_PrintPages(routing_id())); } bool RenderViewHost::PrintPreview() { // TODO(thestig) Get settings from the print preview UI. DictionaryValue dummy_dict; - return Send(new ViewMsg_PrintPreview(routing_id(), dummy_dict)); + return Send(new PrintMsg_PrintPreview(routing_id(), dummy_dict)); } void RenderViewHost::PrintingDone(int document_cookie, bool success) { - Send(new ViewMsg_PrintingDone(routing_id(), document_cookie, success)); + Send(new PrintMsg_PrintingDone(routing_id(), document_cookie, success)); } void RenderViewHost::StartFinding(int request_id, @@ -1233,7 +1233,7 @@ void RenderViewHost::ContextMenuClosed( } void RenderViewHost::PrintForPrintPreview(const DictionaryValue& job_settings) { - Send(new ViewMsg_PrintForPrintPreview(routing_id(), job_settings)); + Send(new PrintMsg_PrintForPrintPreview(routing_id(), job_settings)); } void RenderViewHost::OnMsgStartDragging( diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h index ce3aff8..fa504e6 100644 --- a/ipc/ipc_message_utils.h +++ b/ipc/ipc_message_utils.h @@ -83,6 +83,7 @@ enum IPCMessageStart { AudioMsgStart, ChromeMsgStart, DragMsgStart, + PrintMsgStart, LastIPCMsgStart // Must come last. }; |