OLD | NEW |
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_view_manager.h" | 5 #include "chrome/browser/printing/print_view_manager.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 : PrintViewManagerBase(web_contents), | 39 : PrintViewManagerBase(web_contents), |
40 observer_(NULL), | 40 observer_(NULL), |
41 print_preview_state_(NOT_PREVIEWING), | 41 print_preview_state_(NOT_PREVIEWING), |
42 scripted_print_preview_rph_(NULL) { | 42 scripted_print_preview_rph_(NULL) { |
43 } | 43 } |
44 | 44 |
45 PrintViewManager::~PrintViewManager() { | 45 PrintViewManager::~PrintViewManager() { |
46 DCHECK_EQ(NOT_PREVIEWING, print_preview_state_); | 46 DCHECK_EQ(NOT_PREVIEWING, print_preview_state_); |
47 } | 47 } |
48 | 48 |
49 #if !defined(OS_WIN) | |
50 bool PrintViewManager::PrintForSystemDialogNow() { | 49 bool PrintViewManager::PrintForSystemDialogNow() { |
| 50 #if defined(OS_WIN) |
| 51 NOTREACHED(); |
| 52 #endif |
51 return PrintNowInternal(new PrintMsg_PrintForSystemDialog(routing_id())); | 53 return PrintNowInternal(new PrintMsg_PrintForSystemDialog(routing_id())); |
52 } | 54 } |
53 | 55 |
54 bool PrintViewManager::AdvancedPrintNow() { | 56 bool PrintViewManager::AdvancedPrintNow() { |
55 PrintPreviewDialogController* dialog_controller = | 57 PrintPreviewDialogController* dialog_controller = |
56 PrintPreviewDialogController::GetInstance(); | 58 PrintPreviewDialogController::GetInstance(); |
57 if (!dialog_controller) | 59 if (!dialog_controller) |
58 return false; | 60 return false; |
59 content::WebContents* print_preview_dialog = | 61 content::WebContents* print_preview_dialog = |
60 dialog_controller->GetPrintPreviewForContents(web_contents()); | 62 dialog_controller->GetPrintPreviewForContents(web_contents()); |
61 if (print_preview_dialog) { | 63 if (print_preview_dialog) { |
62 if (!print_preview_dialog->GetWebUI()) | 64 if (!print_preview_dialog->GetWebUI()) |
63 return false; | 65 return false; |
64 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( | 66 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( |
65 print_preview_dialog->GetWebUI()->GetController()); | 67 print_preview_dialog->GetWebUI()->GetController()); |
66 print_preview_ui->OnShowSystemDialog(); | 68 print_preview_ui->OnShowSystemDialog(); |
67 return true; | 69 return true; |
68 } else { | 70 } else { |
69 return PrintNow(); | 71 return PrintNow(); |
70 } | 72 } |
71 } | 73 } |
72 #endif // !OS_WIN | 74 |
73 bool PrintViewManager::PrintPreviewNow(bool selection_only) { | 75 bool PrintViewManager::PrintPreviewNow(bool selection_only) { |
74 // Users can send print commands all they want and it is beyond | 76 // Users can send print commands all they want and it is beyond |
75 // PrintViewManager's control. Just ignore the extra commands. | 77 // PrintViewManager's control. Just ignore the extra commands. |
76 // See http://crbug.com/136842 for example. | 78 // See http://crbug.com/136842 for example. |
77 if (print_preview_state_ != NOT_PREVIEWING) | 79 if (print_preview_state_ != NOT_PREVIEWING) |
78 return false; | 80 return false; |
79 | 81 |
80 if (!PrintNowInternal(new PrintMsg_InitiatePrintPreview(routing_id(), | 82 if (!PrintNowInternal(new PrintMsg_InitiatePrintPreview(routing_id(), |
81 selection_only))) { | 83 selection_only))) { |
82 return false; | 84 return false; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 OnSetupScriptedPrintPreview) | 189 OnSetupScriptedPrintPreview) |
188 IPC_MESSAGE_HANDLER(PrintHostMsg_ShowScriptedPrintPreview, | 190 IPC_MESSAGE_HANDLER(PrintHostMsg_ShowScriptedPrintPreview, |
189 OnShowScriptedPrintPreview) | 191 OnShowScriptedPrintPreview) |
190 IPC_MESSAGE_UNHANDLED(handled = false) | 192 IPC_MESSAGE_UNHANDLED(handled = false) |
191 IPC_END_MESSAGE_MAP() | 193 IPC_END_MESSAGE_MAP() |
192 | 194 |
193 return handled ? true : PrintViewManagerBase::OnMessageReceived(message); | 195 return handled ? true : PrintViewManagerBase::OnMessageReceived(message); |
194 } | 196 } |
195 | 197 |
196 } // namespace printing | 198 } // namespace printing |
OLD | NEW |