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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 bool PrintViewManager::PrintToDestination() { | 123 bool PrintViewManager::PrintToDestination() { |
124 // TODO(mad): Remove this once we can send user metrics from the metro driver. | 124 // TODO(mad): Remove this once we can send user metrics from the metro driver. |
125 // crbug.com/142330 | 125 // crbug.com/142330 |
126 UMA_HISTOGRAM_ENUMERATION("Metro.Print", 0, 2); | 126 UMA_HISTOGRAM_ENUMERATION("Metro.Print", 0, 2); |
127 // TODO(mad): Use a passed in destination interface instead. | 127 // TODO(mad): Use a passed in destination interface instead. |
128 g_browser_process->print_job_manager()->SetPrintDestination( | 128 g_browser_process->print_job_manager()->SetPrintDestination( |
129 printing::CreatePrintDestination()); | 129 printing::CreatePrintDestination()); |
130 return PrintNowInternal(new PrintMsg_PrintPages(routing_id())); | 130 return PrintNowInternal(new PrintMsg_PrintPages(routing_id())); |
131 } | 131 } |
132 | 132 |
133 bool PrintViewManager::PrintPreviewNow() { | 133 bool PrintViewManager::PrintPreviewNow(bool selection_only) { |
134 // Users can send print commands all they want and it is beyond | 134 // Users can send print commands all they want and it is beyond |
135 // PrintViewManager's control. Just ignore the extra commands. | 135 // PrintViewManager's control. Just ignore the extra commands. |
136 // See http://crbug.com/136842 for example. | 136 // See http://crbug.com/136842 for example. |
137 if (print_preview_state_ != NOT_PREVIEWING) | 137 if (print_preview_state_ != NOT_PREVIEWING) |
138 return false; | 138 return false; |
139 | 139 |
140 if (!PrintNowInternal(new PrintMsg_InitiatePrintPreview(routing_id()))) | 140 if (!PrintNowInternal(new PrintMsg_InitiatePrintPreview(routing_id(), |
| 141 selection_only))) { |
141 return false; | 142 return false; |
| 143 } |
142 | 144 |
143 print_preview_state_ = USER_INITIATED_PREVIEW; | 145 print_preview_state_ = USER_INITIATED_PREVIEW; |
144 return true; | 146 return true; |
145 } | 147 } |
146 | 148 |
147 void PrintViewManager::PrintPreviewForWebNode() { | 149 void PrintViewManager::PrintPreviewForWebNode() { |
148 DCHECK_EQ(NOT_PREVIEWING, print_preview_state_); | 150 DCHECK_EQ(NOT_PREVIEWING, print_preview_state_); |
149 print_preview_state_ = USER_INITIATED_PREVIEW; | 151 print_preview_state_ = USER_INITIATED_PREVIEW; |
150 } | 152 } |
151 | 153 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 | 337 |
336 print_preview_state_ = SCRIPTED_PREVIEW; | 338 print_preview_state_ = SCRIPTED_PREVIEW; |
337 base::Closure callback = | 339 base::Closure callback = |
338 base::Bind(&PrintViewManager::OnScriptedPrintPreviewReply, | 340 base::Bind(&PrintViewManager::OnScriptedPrintPreviewReply, |
339 base::Unretained(this), | 341 base::Unretained(this), |
340 reply_msg); | 342 reply_msg); |
341 map[rph] = callback; | 343 map[rph] = callback; |
342 scripted_print_preview_rph_ = rph; | 344 scripted_print_preview_rph_ = rph; |
343 | 345 |
344 dialog_controller->PrintPreview(web_contents()); | 346 dialog_controller->PrintPreview(web_contents()); |
345 PrintPreviewUI::SetSourceIsModifiable( | 347 PrintHostMsg_RequestPrintPreview_Params params; |
346 dialog_controller->GetPrintPreviewForContents(web_contents()), | 348 params.is_modifiable = source_is_modifiable; |
347 source_is_modifiable); | 349 PrintPreviewUI::SetInitialParams( |
348 PrintPreviewUI::SetSourceHasSelection( | 350 dialog_controller->GetPrintPreviewForContents(web_contents()), params); |
349 dialog_controller->GetPrintPreviewForTab(web_contents()), false); | |
350 } | 351 } |
351 | 352 |
352 void PrintViewManager::OnScriptedPrintPreviewReply(IPC::Message* reply_msg) { | 353 void PrintViewManager::OnScriptedPrintPreviewReply(IPC::Message* reply_msg) { |
353 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 354 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
354 Send(reply_msg); | 355 Send(reply_msg); |
355 } | 356 } |
356 | 357 |
357 void PrintViewManager::DidStartLoading( | 358 void PrintViewManager::DidStartLoading( |
358 content::RenderViewHost* render_view_host) { | 359 content::RenderViewHost* render_view_host) { |
359 UpdateScriptedPrintingBlocked(); | 360 UpdateScriptedPrintingBlocked(); |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 scoped_refptr<printing::PrinterQuery> printer_query; | 675 scoped_refptr<printing::PrinterQuery> printer_query; |
675 print_job_manager->PopPrinterQuery(cookie, &printer_query); | 676 print_job_manager->PopPrinterQuery(cookie, &printer_query); |
676 if (!printer_query.get()) | 677 if (!printer_query.get()) |
677 return; | 678 return; |
678 BrowserThread::PostTask( | 679 BrowserThread::PostTask( |
679 BrowserThread::IO, FROM_HERE, | 680 BrowserThread::IO, FROM_HERE, |
680 base::Bind(&PrinterQuery::StopWorker, printer_query.get())); | 681 base::Bind(&PrinterQuery::StopWorker, printer_query.get())); |
681 } | 682 } |
682 | 683 |
683 } // namespace printing | 684 } // namespace printing |
OLD | NEW |