Commit 0fe599e9 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Give PrintHostMsg_DidGetPreviewPageCount a better name.

It really should be called PrintHostMsg_DidStartPreview. Getting the
page count is usually one of the first steps in starting a print
preview, but the IPC message does a bit more than that now.

Change-Id: I001a66c169fa5cf42b238605d6067bf12d58962e
Reviewed-on: https://chromium-review.googlesource.com/1184317Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585298}
parent 8abf4223
...@@ -106,8 +106,8 @@ void PrintPreviewMessageHandler::OnRequestPrintPreview( ...@@ -106,8 +106,8 @@ void PrintPreviewMessageHandler::OnRequestPrintPreview(
PrintPreviewUI::SetInitialParams(GetPrintPreviewDialog(), params); PrintPreviewUI::SetInitialParams(GetPrintPreviewDialog(), params);
} }
void PrintPreviewMessageHandler::OnDidGetPreviewPageCount( void PrintPreviewMessageHandler::OnDidStartPreview(
const PrintHostMsg_DidGetPreviewPageCount_Params& params, const PrintHostMsg_DidStartPreview_Params& params,
const PrintHostMsg_PreviewIds& ids) { const PrintHostMsg_PreviewIds& ids) {
if (params.page_count <= 0) { if (params.page_count <= 0) {
NOTREACHED(); NOTREACHED();
...@@ -119,7 +119,7 @@ void PrintPreviewMessageHandler::OnDidGetPreviewPageCount( ...@@ -119,7 +119,7 @@ void PrintPreviewMessageHandler::OnDidGetPreviewPageCount(
return; return;
print_preview_ui->ClearAllPreviewData(); print_preview_ui->ClearAllPreviewData();
print_preview_ui->OnDidGetPreviewPageCount(params, ids.request_id); print_preview_ui->OnDidStartPreview(params, ids.request_id);
} }
void PrintPreviewMessageHandler::OnDidPreviewPage( void PrintPreviewMessageHandler::OnDidPreviewPage(
...@@ -324,8 +324,7 @@ bool PrintPreviewMessageHandler::OnMessageReceived( ...@@ -324,8 +324,7 @@ bool PrintPreviewMessageHandler::OnMessageReceived(
handled = true; handled = true;
IPC_BEGIN_MESSAGE_MAP(PrintPreviewMessageHandler, message) IPC_BEGIN_MESSAGE_MAP(PrintPreviewMessageHandler, message)
IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPreviewPageCount, IPC_MESSAGE_HANDLER(PrintHostMsg_DidStartPreview, OnDidStartPreview)
OnDidGetPreviewPageCount)
IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewFailed, IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewFailed,
OnPrintPreviewFailed) OnPrintPreviewFailed)
IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetDefaultPageLayout, IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetDefaultPageLayout,
......
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
#include "content/public/browser/web_contents_user_data.h" #include "content/public/browser/web_contents_user_data.h"
class PrintPreviewUI; class PrintPreviewUI;
struct PrintHostMsg_DidGetPreviewPageCount_Params;
struct PrintHostMsg_DidPreviewDocument_Params; struct PrintHostMsg_DidPreviewDocument_Params;
struct PrintHostMsg_DidPreviewPage_Params; struct PrintHostMsg_DidPreviewPage_Params;
struct PrintHostMsg_DidStartPreview_Params;
struct PrintHostMsg_PreviewIds; struct PrintHostMsg_PreviewIds;
struct PrintHostMsg_RequestPrintPreview_Params; struct PrintHostMsg_RequestPrintPreview_Params;
struct PrintHostMsg_SetOptionsFromDocument_Params; struct PrintHostMsg_SetOptionsFromDocument_Params;
...@@ -69,8 +69,7 @@ class PrintPreviewMessageHandler ...@@ -69,8 +69,7 @@ class PrintPreviewMessageHandler
const gfx::Rect& printable_area_in_points, const gfx::Rect& printable_area_in_points,
bool has_custom_page_size_style, bool has_custom_page_size_style,
const PrintHostMsg_PreviewIds& ids); const PrintHostMsg_PreviewIds& ids);
void OnDidGetPreviewPageCount( void OnDidStartPreview(const PrintHostMsg_DidStartPreview_Params& params,
const PrintHostMsg_DidGetPreviewPageCount_Params& params,
const PrintHostMsg_PreviewIds& ids); const PrintHostMsg_PreviewIds& ids);
void OnDidPreviewPage(content::RenderFrameHost* render_frame_host, void OnDidPreviewPage(content::RenderFrameHost* render_frame_host,
const PrintHostMsg_DidPreviewPage_Params& params, const PrintHostMsg_DidPreviewPage_Params& params,
......
...@@ -141,8 +141,7 @@ class PrintPreviewObserver : public WebContentsObserver { ...@@ -141,8 +141,7 @@ class PrintPreviewObserver : public WebContentsObserver {
bool OnMessageReceived(const IPC::Message& message) override { bool OnMessageReceived(const IPC::Message& message) override {
IPC_BEGIN_MESSAGE_MAP(PrintPreviewObserver, message) IPC_BEGIN_MESSAGE_MAP(PrintPreviewObserver, message)
IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPreviewPageCount, IPC_MESSAGE_HANDLER(PrintHostMsg_DidStartPreview, OnDidStartPreview)
OnDidGetPreviewPageCount)
IPC_END_MESSAGE_MAP() IPC_END_MESSAGE_MAP()
return false; return false;
} }
...@@ -268,10 +267,9 @@ class PrintPreviewObserver : public WebContentsObserver { ...@@ -268,10 +267,9 @@ class PrintPreviewObserver : public WebContentsObserver {
DISALLOW_COPY_AND_ASSIGN(UIDoneLoadingMessageHandler); DISALLOW_COPY_AND_ASSIGN(UIDoneLoadingMessageHandler);
}; };
// Called when the observer gets the IPC message stating that the page count // Called when the observer gets the IPC message with the preview document's
// is ready. // properties.
void OnDidGetPreviewPageCount( void OnDidStartPreview(const PrintHostMsg_DidStartPreview_Params& params,
const PrintHostMsg_DidGetPreviewPageCount_Params& params,
const PrintHostMsg_PreviewIds& ids) { const PrintHostMsg_PreviewIds& ids) {
WebContents* web_contents = GetDialog(); WebContents* web_contents = GetDialog();
ASSERT_TRUE(web_contents); ASSERT_TRUE(web_contents);
......
...@@ -693,8 +693,8 @@ void PrintPreviewUI::OnPrintPreviewRequest(int request_id) { ...@@ -693,8 +693,8 @@ void PrintPreviewUI::OnPrintPreviewRequest(int request_id) {
g_print_preview_request_id_map.Get().Set(id_, request_id); g_print_preview_request_id_map.Get().Set(id_, request_id);
} }
void PrintPreviewUI::OnDidGetPreviewPageCount( void PrintPreviewUI::OnDidStartPreview(
const PrintHostMsg_DidGetPreviewPageCount_Params& params, const PrintHostMsg_DidStartPreview_Params& params,
int request_id) { int request_id) {
DCHECK_GT(params.page_count, 0); DCHECK_GT(params.page_count, 0);
if (g_testing_delegate) if (g_testing_delegate)
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
class PrintPreviewHandler; class PrintPreviewHandler;
struct PrintHostMsg_DidGetPreviewPageCount_Params; struct PrintHostMsg_DidStartPreview_Params;
struct PrintHostMsg_PreviewIds; struct PrintHostMsg_PreviewIds;
struct PrintHostMsg_RequestPrintPreview_Params; struct PrintHostMsg_RequestPrintPreview_Params;
struct PrintHostMsg_SetOptionsFromDocument_Params; struct PrintHostMsg_SetOptionsFromDocument_Params;
...@@ -85,9 +85,8 @@ class PrintPreviewUI : public ConstrainedWebDialogUI { ...@@ -85,9 +85,8 @@ class PrintPreviewUI : public ConstrainedWebDialogUI {
// Notifies the Web UI of a print preview request with |request_id|. // Notifies the Web UI of a print preview request with |request_id|.
virtual void OnPrintPreviewRequest(int request_id); virtual void OnPrintPreviewRequest(int request_id);
// Notifies the Web UI about the page count of the request preview. // Notifies the Web UI about the properties of the request preview.
void OnDidGetPreviewPageCount( void OnDidStartPreview(const PrintHostMsg_DidStartPreview_Params& params,
const PrintHostMsg_DidGetPreviewPageCount_Params& params,
int request_id); int request_id);
// Notifies the Web UI of the default page layout according to the currently // Notifies the Web UI of the default page layout according to the currently
......
...@@ -284,19 +284,14 @@ IPC_STRUCT_BEGIN(PrintHostMsg_DidPrintContent_Params) ...@@ -284,19 +284,14 @@ IPC_STRUCT_BEGIN(PrintHostMsg_DidPrintContent_Params)
IPC_STRUCT_END() IPC_STRUCT_END()
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) #if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Parameters to describe a rendered document. // Parameters to describe the to-be-rendered preview document.
IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewDocument_Params) IPC_STRUCT_BEGIN(PrintHostMsg_DidStartPreview_Params)
// Document's content including metafile data and subframe info. // Total page count for the rendered preview. (Not the number of pages the
IPC_STRUCT_MEMBER(PrintHostMsg_DidPrintContent_Params, content) // user selected to print.)
IPC_STRUCT_MEMBER(int, page_count)
// 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)
// Whether the preview can be modified. // Scaling % to fit to page
IPC_STRUCT_MEMBER(bool, modifiable) IPC_STRUCT_MEMBER(int, fit_to_page_scaling)
IPC_STRUCT_END() IPC_STRUCT_END()
// Parameters to describe a rendered preview page. // Parameters to describe a rendered preview page.
...@@ -311,13 +306,19 @@ IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewPage_Params) ...@@ -311,13 +306,19 @@ IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewPage_Params)
IPC_STRUCT_MEMBER(int, document_cookie) IPC_STRUCT_MEMBER(int, document_cookie)
IPC_STRUCT_END() IPC_STRUCT_END()
// Parameters sent along with the page count. // Parameters to describe the final rendered preview document.
IPC_STRUCT_BEGIN(PrintHostMsg_DidGetPreviewPageCount_Params) IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewDocument_Params)
// Total page count. // Document's content including metafile data and subframe info.
IPC_STRUCT_MEMBER(int, page_count) IPC_STRUCT_MEMBER(PrintHostMsg_DidPrintContent_Params, content)
// Scaling % to fit to page // Cookie for the document to ensure correctness.
IPC_STRUCT_MEMBER(int, fit_to_page_scaling) IPC_STRUCT_MEMBER(int, document_cookie)
// Store the expected pages count.
IPC_STRUCT_MEMBER(int, expected_pages_count)
// Whether the preview can be modified.
IPC_STRUCT_MEMBER(bool, modifiable)
IPC_STRUCT_END() IPC_STRUCT_END()
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
...@@ -337,7 +338,6 @@ IPC_STRUCT_BEGIN(PrintHostMsg_DidPrintDocument_Params) ...@@ -337,7 +338,6 @@ IPC_STRUCT_BEGIN(PrintHostMsg_DidPrintDocument_Params)
// The physical offsets of the printer in DPI. Used for PS printing. // The physical offsets of the printer in DPI. Used for PS printing.
IPC_STRUCT_MEMBER(gfx::Point, physical_offsets) IPC_STRUCT_MEMBER(gfx::Point, physical_offsets)
IPC_STRUCT_END() IPC_STRUCT_END()
// TODO(dgn) Rename *ScriptedPrint messages because they are not called only // TODO(dgn) Rename *ScriptedPrint messages because they are not called only
...@@ -460,9 +460,9 @@ IPC_MESSAGE_CONTROL3(PrintHostMsg_TempFileForPrintingWritten, ...@@ -460,9 +460,9 @@ IPC_MESSAGE_CONTROL3(PrintHostMsg_TempFileForPrintingWritten,
IPC_MESSAGE_ROUTED1(PrintHostMsg_RequestPrintPreview, IPC_MESSAGE_ROUTED1(PrintHostMsg_RequestPrintPreview,
PrintHostMsg_RequestPrintPreview_Params /* params */) PrintHostMsg_RequestPrintPreview_Params /* params */)
// Notify the browser the number of pages in the print preview document. // Notify the browser the about the to-be-rendered print preview document.
IPC_MESSAGE_ROUTED2(PrintHostMsg_DidGetPreviewPageCount, IPC_MESSAGE_ROUTED2(PrintHostMsg_DidStartPreview,
PrintHostMsg_DidGetPreviewPageCount_Params /* params */, PrintHostMsg_DidStartPreview_Params /* params */,
PrintHostMsg_PreviewIds /* ids */) PrintHostMsg_PreviewIds /* ids */)
// Notify the browser of the default page layout according to the currently // Notify the browser of the default page layout according to the currently
......
...@@ -1261,11 +1261,11 @@ bool PrintRenderFrameHelper::CreatePreviewDocument() { ...@@ -1261,11 +1261,11 @@ bool PrintRenderFrameHelper::CreatePreviewDocument() {
routing_id(), default_page_layout, printable_area_in_points, routing_id(), default_page_layout, printable_area_in_points,
has_page_size_style, ids)); has_page_size_style, ids));
PrintHostMsg_DidGetPreviewPageCount_Params params; PrintHostMsg_DidStartPreview_Params params;
params.page_count = print_preview_context_.total_page_count(); params.page_count = print_preview_context_.total_page_count();
params.fit_to_page_scaling = params.fit_to_page_scaling =
GetFitToPageScaleFactor(printable_area_in_points); GetFitToPageScaleFactor(printable_area_in_points);
Send(new PrintHostMsg_DidGetPreviewPageCount(routing_id(), params, ids)); Send(new PrintHostMsg_DidStartPreview(routing_id(), params, ids));
if (CheckForCancel()) if (CheckForCancel())
return false; return false;
......
...@@ -61,8 +61,7 @@ bool PrintMockRenderThread::OnMessageReceived(const IPC::Message& msg) { ...@@ -61,8 +61,7 @@ bool PrintMockRenderThread::OnMessageReceived(const IPC::Message& msg) {
OnDidGetPrintedPagesCount) OnDidGetPrintedPagesCount)
IPC_MESSAGE_HANDLER(PrintHostMsg_DidPrintDocument, OnDidPrintDocument) IPC_MESSAGE_HANDLER(PrintHostMsg_DidPrintDocument, OnDidPrintDocument)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) #if BUILDFLAG(ENABLE_PRINT_PREVIEW)
IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPreviewPageCount, IPC_MESSAGE_HANDLER(PrintHostMsg_DidStartPreview, OnDidStartPreview)
OnDidGetPreviewPageCount)
IPC_MESSAGE_HANDLER(PrintHostMsg_DidPreviewPage, OnDidPreviewPage) IPC_MESSAGE_HANDLER(PrintHostMsg_DidPreviewPage, OnDidPreviewPage)
IPC_MESSAGE_HANDLER(PrintHostMsg_CheckForCancel, OnCheckForCancel) IPC_MESSAGE_HANDLER(PrintHostMsg_CheckForCancel, OnCheckForCancel)
#endif #endif
...@@ -99,8 +98,8 @@ void PrintMockRenderThread::OnDidPrintDocument( ...@@ -99,8 +98,8 @@ void PrintMockRenderThread::OnDidPrintDocument(
} }
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) #if BUILDFLAG(ENABLE_PRINT_PREVIEW)
void PrintMockRenderThread::OnDidGetPreviewPageCount( void PrintMockRenderThread::OnDidStartPreview(
const PrintHostMsg_DidGetPreviewPageCount_Params& params, const PrintHostMsg_DidStartPreview_Params& params,
const PrintHostMsg_PreviewIds& ids) { const PrintHostMsg_PreviewIds& ids) {
print_preview_pages_remaining_ = params.page_count; print_preview_pages_remaining_ = params.page_count;
} }
......
...@@ -22,7 +22,7 @@ class DictionaryValue; ...@@ -22,7 +22,7 @@ class DictionaryValue;
} }
class MockPrinter; class MockPrinter;
struct PrintHostMsg_DidGetPreviewPageCount_Params; struct PrintHostMsg_DidStartPreview_Params;
struct PrintHostMsg_DidPreviewPage_Params; struct PrintHostMsg_DidPreviewPage_Params;
struct PrintHostMsg_DidPrintDocument_Params; struct PrintHostMsg_DidPrintDocument_Params;
struct PrintHostMsg_PreviewIds; struct PrintHostMsg_PreviewIds;
...@@ -78,8 +78,7 @@ class PrintMockRenderThread : public content::MockRenderThread { ...@@ -78,8 +78,7 @@ class PrintMockRenderThread : public content::MockRenderThread {
void OnDidGetPrintedPagesCount(int cookie, int number_pages); void OnDidGetPrintedPagesCount(int cookie, int number_pages);
void OnDidPrintDocument(const PrintHostMsg_DidPrintDocument_Params& params); void OnDidPrintDocument(const PrintHostMsg_DidPrintDocument_Params& params);
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) #if BUILDFLAG(ENABLE_PRINT_PREVIEW)
void OnDidGetPreviewPageCount( void OnDidStartPreview(const PrintHostMsg_DidStartPreview_Params& params,
const PrintHostMsg_DidGetPreviewPageCount_Params& params,
const PrintHostMsg_PreviewIds& ids); const PrintHostMsg_PreviewIds& ids);
void OnDidPreviewPage(const PrintHostMsg_DidPreviewPage_Params& params, void OnDidPreviewPage(const PrintHostMsg_DidPreviewPage_Params& params,
const PrintHostMsg_PreviewIds& ids); const PrintHostMsg_PreviewIds& ids);
......
...@@ -202,14 +202,13 @@ class PrintRenderFrameHelperTestBase : public content::RenderViewTest { ...@@ -202,14 +202,13 @@ class PrintRenderFrameHelperTestBase : public content::RenderViewTest {
// according to the specified settings defined in the mock render thread. // according to the specified settings defined in the mock render thread.
// Verify the page count is correct. // Verify the page count is correct.
void VerifyPreviewPageCount(int expected_count) { void VerifyPreviewPageCount(int expected_count) {
const IPC::Message* page_cnt_msg = const IPC::Message* preview_started_message =
render_thread_->sink().GetUniqueMessageMatching( render_thread_->sink().GetUniqueMessageMatching(
PrintHostMsg_DidGetPreviewPageCount::ID); PrintHostMsg_DidStartPreview::ID);
ASSERT_TRUE(page_cnt_msg); ASSERT_TRUE(preview_started_message);
PrintHostMsg_DidGetPreviewPageCount::Param post_page_count_param; PrintHostMsg_DidStartPreview::Param param;
PrintHostMsg_DidGetPreviewPageCount::Read(page_cnt_msg, PrintHostMsg_DidStartPreview::Read(preview_started_message, &param);
&post_page_count_param); EXPECT_EQ(expected_count, std::get<0>(param).page_count);
EXPECT_EQ(expected_count, std::get<0>(post_page_count_param).page_count);
} }
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment