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