OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/ref_counted_memory.h" | 11 #include "base/memory/ref_counted_memory.h" |
12 #include "base/shared_memory.h" | 12 #include "base/shared_memory.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/printing/print_job_manager.h" | 14 #include "chrome/browser/printing/print_job_manager.h" |
15 #include "chrome/browser/printing/print_preview_tab_controller.h" | 15 #include "chrome/browser/printing/print_preview_tab_controller.h" |
16 #include "chrome/browser/printing/print_view_manager.h" | 16 #include "chrome/browser/printing/print_view_manager.h" |
17 #include "chrome/browser/printing/printer_query.h" | 17 #include "chrome/browser/printing/printer_query.h" |
18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
19 #include "chrome/browser/ui/webui/print_preview_ui.h" | 19 #include "chrome/browser/ui/webui/print_preview_ui.h" |
20 #include "chrome/common/print_messages.h" | 20 #include "chrome/common/print_messages.h" |
21 #include "content/browser/renderer_host/render_view_host.h" | 21 #include "content/browser/renderer_host/render_view_host.h" |
22 #include "content/browser/tab_contents/tab_contents.h" | 22 #include "content/browser/tab_contents/tab_contents.h" |
23 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
24 #include "printing/page_size_margins.h" | 24 #include "printing/page_size_margins.h" |
25 #include "printing/print_job_constants.h" | 25 #include "printing/print_job_constants.h" |
26 | 26 |
27 using content::BrowserThread; | 27 using content::BrowserThread; |
| 28 using content::NavigationController; |
28 | 29 |
29 namespace { | 30 namespace { |
30 | 31 |
31 void StopWorker(int document_cookie) { | 32 void StopWorker(int document_cookie) { |
32 if (document_cookie <= 0) | 33 if (document_cookie <= 0) |
33 return; | 34 return; |
34 | 35 |
35 printing::PrintJobManager* print_job_manager = | 36 printing::PrintJobManager* print_job_manager = |
36 g_browser_process->print_job_manager(); | 37 g_browser_process->print_job_manager(); |
37 scoped_refptr<printing::PrinterQuery> printer_query; | 38 scoped_refptr<printing::PrinterQuery> printer_query; |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 OnPrintPreviewCancelled) | 240 OnPrintPreviewCancelled) |
240 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewInvalidPrinterSettings, | 241 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewInvalidPrinterSettings, |
241 OnInvalidPrinterSettings) | 242 OnInvalidPrinterSettings) |
242 IPC_MESSAGE_UNHANDLED(handled = false) | 243 IPC_MESSAGE_UNHANDLED(handled = false) |
243 IPC_END_MESSAGE_MAP() | 244 IPC_END_MESSAGE_MAP() |
244 return handled; | 245 return handled; |
245 } | 246 } |
246 | 247 |
247 void PrintPreviewMessageHandler::NavigateToPendingEntry( | 248 void PrintPreviewMessageHandler::NavigateToPendingEntry( |
248 const GURL& url, | 249 const GURL& url, |
249 content::NavigationController::ReloadType reload_type) { | 250 NavigationController::ReloadType reload_type) { |
250 TabContentsWrapper* tab = tab_contents_wrapper(); | 251 TabContentsWrapper* tab = tab_contents_wrapper(); |
251 TabContentsWrapper* preview_tab = GetPrintPreviewTab(); | 252 TabContentsWrapper* preview_tab = GetPrintPreviewTab(); |
252 if (tab == preview_tab) { | 253 if (tab == preview_tab) { |
253 // Cloud print sign-in reloads the page. | 254 // Cloud print sign-in reloads the page. |
254 DCHECK(PrintPreviewTabController::IsPrintPreviewURL(url)); | 255 DCHECK(PrintPreviewTabController::IsPrintPreviewURL(url)); |
255 DCHECK_EQ(content::NavigationController::RELOAD, reload_type); | 256 DCHECK_EQ(NavigationController::RELOAD, reload_type); |
256 return; | 257 return; |
257 } | 258 } |
258 // If |tab| is navigating and it has a print preview tab, notify |tab| to | 259 // If |tab| is navigating and it has a print preview tab, notify |tab| to |
259 // consider print preview done so it unfreezes the renderer in the case of | 260 // consider print preview done so it unfreezes the renderer in the case of |
260 // window.print(). | 261 // window.print(). |
261 if (preview_tab) | 262 if (preview_tab) |
262 tab->print_view_manager()->PrintPreviewDone(); | 263 tab->print_view_manager()->PrintPreviewDone(); |
263 } | 264 } |
264 | 265 |
265 } // namespace printing | 266 } // namespace printing |
OLD | NEW |