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

Side by Side Diff: chrome/browser/printing/print_preview_message_handler.cc

Issue 2566153007: Implement PrintBrowser functionality. (Closed)
Patch Set: Fix git weirdness Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/printing/print_preview_message_handler.h" 5 #include "chrome/browser/printing/print_preview_message_handler.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/command_line.h"
14 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
15 #include "base/memory/ref_counted_memory.h" 16 #include "base/memory/ref_counted_memory.h"
16 #include "base/memory/shared_memory.h" 17 #include "base/memory/shared_memory.h"
17 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/printing/print_job_manager.h" 19 #include "chrome/browser/printing/print_job_manager.h"
19 #include "chrome/browser/printing/print_preview_dialog_controller.h" 20 #include "chrome/browser/printing/print_preview_dialog_controller.h"
20 #include "chrome/browser/printing/print_view_manager.h" 21 #include "chrome/browser/printing/print_view_manager.h"
22 #include "chrome/browser/printing/print_view_manager_common.h"
21 #include "chrome/browser/printing/printer_query.h" 23 #include "chrome/browser/printing/printer_query.h"
22 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" 24 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h"
25 #include "chrome/common/chrome_switches.h"
23 #include "components/printing/common/print_messages.h" 26 #include "components/printing/common/print_messages.h"
24 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
25 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
26 #include "content/public/browser/web_ui.h" 29 #include "content/public/browser/web_ui.h"
27 #include "printing/page_size_margins.h" 30 #include "printing/page_size_margins.h"
28 #include "printing/print_job_constants.h" 31 #include "printing/print_job_constants.h"
29 32
30 using content::BrowserThread; 33 using content::BrowserThread;
31 using content::WebContents; 34 using content::WebContents;
32 35
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 OnPrintPreviewCancelled) 239 OnPrintPreviewCancelled)
237 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewInvalidPrinterSettings, 240 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewInvalidPrinterSettings,
238 OnInvalidPrinterSettings) 241 OnInvalidPrinterSettings)
239 IPC_MESSAGE_HANDLER(PrintHostMsg_SetOptionsFromDocument, 242 IPC_MESSAGE_HANDLER(PrintHostMsg_SetOptionsFromDocument,
240 OnSetOptionsFromDocument) 243 OnSetOptionsFromDocument)
241 IPC_MESSAGE_UNHANDLED(handled = false) 244 IPC_MESSAGE_UNHANDLED(handled = false)
242 IPC_END_MESSAGE_MAP() 245 IPC_END_MESSAGE_MAP()
243 return handled; 246 return handled;
244 } 247 }
245 248
249 #if BUILDFLAG(ENABLE_PRINT_BROWSER)
250 // If PrintBrowser mode is enabled, trigger StartPrint() for every page
251 void PrintPreviewMessageHandler::DidFinishLoad(
skau 2016/12/16 18:32:50 This seems to have a limited relationship to Print
252 content::RenderFrameHost* render_frame_host,
253 const GURL& validated_url) {
254 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
255 bool print_browser_enabled =
256 command_line->HasSwitch(switches::kEnablePrintBrowser);
257 if (print_browser_enabled) {
258 content::WebContents* initiator =
259 content::WebContents::FromRenderFrameHost(render_frame_host);
260 printing::StartPrint(initiator, false /* print_preview_disabled */,
skau 2016/12/16 18:32:50 You should enforce that Print Preview is enabled f
rbpotter 2016/12/16 20:05:28 In this case it may be implicitly enforced; I don'
261 false /* has_selection */);
262 }
263 }
264 #endif
265
246 } // namespace printing 266 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698