Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(361)

Unified Diff: headless/lib/browser/headless_print_manager.cc

Issue 2890133002: check whether the printing render frame host has been initialised before accepting a message in the… (Closed)
Patch Set: check whether the printing render frame host has been initialised before accepting a message in the… Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/lib/browser/headless_print_manager.cc
diff --git a/headless/lib/browser/headless_print_manager.cc b/headless/lib/browser/headless_print_manager.cc
index 036c7471fcdc7cee8c35a46ad69b0121eb12c853..6e6efe40b460da151e579fe300cc2efc8e198f1c 100644
--- a/headless/lib/browser/headless_print_manager.cc
+++ b/headless/lib/browser/headless_print_manager.cc
@@ -173,6 +173,25 @@ HeadlessPrintManager::GetPrintParamsFromSettings(
bool HeadlessPrintManager::OnMessageReceived(
const IPC::Message& message,
content::RenderFrameHost* render_frame_host) {
+ if (!printing_rfh_ &&
+ (message.type() == PrintHostMsg_GetDefaultPrintSettings::ID ||
+ message.type() == PrintHostMsg_ScriptedPrint::ID)) {
jzfeng 2017/05/19 01:01:08 nit: check for PrintHostMsg_DidPrintPage here? Or
+ std::string type;
+ switch (message.type()) {
+ case PrintHostMsg_GetDefaultPrintSettings::ID:
+ type = "GetDefaultPrintSettings";
+ break;
+ case PrintHostMsg_ScriptedPrint::ID:
+ type = "ScriptedPrint";
+ break;
Sami 2017/05/19 13:10:01 Please add a default case too.
+ }
+ DLOG(ERROR)
+ << "Unexpected message received before GetPDFContents is called: "
+ << type;
+ render_frame_host->Send(new IPC::Message());
Sami 2017/05/19 13:10:01 Does this end up dropping the print request on the
+ return true;
+ }
+
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(HeadlessPrintManager, message)
IPC_MESSAGE_HANDLER(PrintHostMsg_ShowInvalidPrinterSettingsError,
@@ -233,12 +252,6 @@ void HeadlessPrintManager::OnDidGetPrintedPagesCount(int cookie,
void HeadlessPrintManager::OnDidPrintPage(
const PrintHostMsg_DidPrintPage_Params& params) {
- if (!callback_) {
- DLOG(ERROR)
- << "Unexpected PrintHostMsg_DidPrintPage message from the renderer";
- return;
- }
-
const bool metafile_must_be_valid = expecting_first_page_;
expecting_first_page_ = false;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698