| 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" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 // Inform the print preview tab of the failure. | 93 // Inform the print preview tab of the failure. |
| 94 TabContentsWrapper* print_preview_tab = GetPrintPreviewTab(); | 94 TabContentsWrapper* print_preview_tab = GetPrintPreviewTab(); |
| 95 // User might have closed it already. | 95 // User might have closed it already. |
| 96 if (!print_preview_tab || !print_preview_tab->web_ui()) | 96 if (!print_preview_tab || !print_preview_tab->web_ui()) |
| 97 return NULL; | 97 return NULL; |
| 98 | 98 |
| 99 return static_cast<PrintPreviewUI*>(print_preview_tab->web_ui()); | 99 return static_cast<PrintPreviewUI*>(print_preview_tab->web_ui()); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void PrintPreviewMessageHandler::OnRequestPrintPreview() { | 102 void PrintPreviewMessageHandler::OnRequestPrintPreview(bool is_modifiable) { |
| 103 PrintPreviewTabController::PrintPreview(tab_contents_wrapper()); | 103 PrintPreviewTabController::PrintPreview(tab_contents_wrapper()); |
| 104 |
| 105 TabContentsWrapper* print_preview_tab = GetPrintPreviewTab(); |
| 106 if (!print_preview_tab || !print_preview_tab->web_ui()) |
| 107 return; |
| 108 PrintPreviewUI* print_preview_ui = |
| 109 static_cast<PrintPreviewUI*>(print_preview_tab->web_ui()); |
| 110 print_preview_ui->SetIsModifiable(is_modifiable); |
| 104 } | 111 } |
| 105 | 112 |
| 106 void PrintPreviewMessageHandler::OnDidGetPreviewPageCount( | 113 void PrintPreviewMessageHandler::OnDidGetPreviewPageCount( |
| 107 const PrintHostMsg_DidGetPreviewPageCount_Params& params) { | 114 const PrintHostMsg_DidGetPreviewPageCount_Params& params) { |
| 108 if (params.page_count <= 0) { | 115 if (params.page_count <= 0) { |
| 109 NOTREACHED(); | 116 NOTREACHED(); |
| 110 return; | 117 return; |
| 111 } | 118 } |
| 112 | 119 |
| 113 TabContentsWrapper* print_preview_tab = GetPrintPreviewTab(); | 120 TabContentsWrapper* print_preview_tab = GetPrintPreviewTab(); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 } | 252 } |
| 246 | 253 |
| 247 void PrintPreviewMessageHandler::DidStartLoading() { | 254 void PrintPreviewMessageHandler::DidStartLoading() { |
| 248 if (tab_contents()->delegate() && | 255 if (tab_contents()->delegate() && |
| 249 PrintPreviewTabController::IsPrintPreviewTab(tab_contents_wrapper())) { | 256 PrintPreviewTabController::IsPrintPreviewTab(tab_contents_wrapper())) { |
| 250 tab_contents()->SetContentRestrictions(content::CONTENT_RESTRICTION_PRINT); | 257 tab_contents()->SetContentRestrictions(content::CONTENT_RESTRICTION_PRINT); |
| 251 } | 258 } |
| 252 } | 259 } |
| 253 | 260 |
| 254 } // namespace printing | 261 } // namespace printing |
| OLD | NEW |