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_view_manager.h" | 5 #include "chrome/browser/printing/print_view_manager.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/printing/print_job.h" | 10 #include "chrome/browser/printing/print_job.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 81 } |
82 | 82 |
83 bool PrintViewManager::PrintNow() { | 83 bool PrintViewManager::PrintNow() { |
84 return PrintNowInternal(new PrintMsg_PrintPages(routing_id())); | 84 return PrintNowInternal(new PrintMsg_PrintPages(routing_id())); |
85 } | 85 } |
86 | 86 |
87 bool PrintViewManager::PrintForSystemDialogNow() { | 87 bool PrintViewManager::PrintForSystemDialogNow() { |
88 return PrintNowInternal(new PrintMsg_PrintForSystemDialog(routing_id())); | 88 return PrintNowInternal(new PrintMsg_PrintForSystemDialog(routing_id())); |
89 } | 89 } |
90 | 90 |
| 91 bool PrintViewManager::AdvancedPrintNow() { |
| 92 printing::PrintPreviewTabController* tab_controller = |
| 93 printing::PrintPreviewTabController::GetInstance(); |
| 94 if (!tab_controller) |
| 95 return false; |
| 96 TabContents* print_preview_tab = |
| 97 tab_controller->GetPrintPreviewForTab(tab_contents()); |
| 98 if (print_preview_tab) { |
| 99 // Preview tab exist for current tab or current tab is preview tab. |
| 100 if (!print_preview_tab->web_ui()) |
| 101 return false; |
| 102 PrintPreviewUI* print_preview_ui = |
| 103 static_cast<PrintPreviewUI*>(print_preview_tab->web_ui()); |
| 104 print_preview_ui->OnShowSystemDialog(); |
| 105 return true; |
| 106 } else { |
| 107 return PrintNow(); |
| 108 } |
| 109 } |
| 110 |
91 bool PrintViewManager::PrintPreviewNow() { | 111 bool PrintViewManager::PrintPreviewNow() { |
92 return PrintNowInternal(new PrintMsg_InitiatePrintPreview(routing_id())); | 112 return PrintNowInternal(new PrintMsg_InitiatePrintPreview(routing_id())); |
93 } | 113 } |
94 | 114 |
95 void PrintViewManager::PreviewPrintingRequestCancelled() { | 115 void PrintViewManager::PreviewPrintingRequestCancelled() { |
96 if (!tab_contents()) | 116 if (!tab_contents()) |
97 return; | 117 return; |
98 RenderViewHost* rvh = tab_contents()->render_view_host(); | 118 RenderViewHost* rvh = tab_contents()->render_view_host(); |
99 rvh->Send(new PrintMsg_PreviewPrintingRequestCancelled(rvh->routing_id())); | 119 rvh->Send(new PrintMsg_PreviewPrintingRequestCancelled(rvh->routing_id())); |
100 } | 120 } |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 } | 532 } |
513 | 533 |
514 bool PrintViewManager::PrintNowInternal(IPC::Message* message) { | 534 bool PrintViewManager::PrintNowInternal(IPC::Message* message) { |
515 // Don't print / print preview interstitials. | 535 // Don't print / print preview interstitials. |
516 if (tab_contents()->showing_interstitial_page()) | 536 if (tab_contents()->showing_interstitial_page()) |
517 return false; | 537 return false; |
518 return Send(message); | 538 return Send(message); |
519 } | 539 } |
520 | 540 |
521 } // namespace printing | 541 } // namespace printing |
OLD | NEW |