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/printing_message_filter.h" | 5 #include "chrome/browser/printing/printing_message_filter.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 } // namespace | 91 } // namespace |
92 | 92 |
93 PrintingMessageFilter::PrintingMessageFilter(int render_process_id, | 93 PrintingMessageFilter::PrintingMessageFilter(int render_process_id, |
94 Profile* profile) | 94 Profile* profile) |
95 : BrowserMessageFilter(PrintMsgStart), | 95 : BrowserMessageFilter(PrintMsgStart), |
96 profile_io_data_(ProfileIOData::FromResourceContext( | 96 profile_io_data_(ProfileIOData::FromResourceContext( |
97 profile->GetResourceContext())), | 97 profile->GetResourceContext())), |
98 render_process_id_(render_process_id), | 98 render_process_id_(render_process_id), |
99 queue_(g_browser_process->print_job_manager()->queue()) { | 99 queue_(g_browser_process->print_job_manager()->queue()) { |
100 DCHECK(queue_); | 100 DCHECK(queue_.get()); |
101 } | 101 } |
102 | 102 |
103 PrintingMessageFilter::~PrintingMessageFilter() { | 103 PrintingMessageFilter::~PrintingMessageFilter() { |
104 } | 104 } |
105 | 105 |
106 void PrintingMessageFilter::OverrideThreadForMessage( | 106 void PrintingMessageFilter::OverrideThreadForMessage( |
107 const IPC::Message& message, BrowserThread::ID* thread) { | 107 const IPC::Message& message, BrowserThread::ID* thread) { |
108 #if defined(OS_CHROMEOS) | 108 #if defined(OS_CHROMEOS) |
109 if (message.type() == PrintHostMsg_AllocateTempFileForPrinting::ID || | 109 if (message.type() == PrintHostMsg_AllocateTempFileForPrinting::ID || |
110 message.type() == PrintHostMsg_TempFileForPrintingWritten::ID) { | 110 message.type() == PrintHostMsg_TempFileForPrintingWritten::ID) { |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 | 266 |
267 void PrintingMessageFilter::OnGetDefaultPrintSettings(IPC::Message* reply_msg) { | 267 void PrintingMessageFilter::OnGetDefaultPrintSettings(IPC::Message* reply_msg) { |
268 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 268 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
269 scoped_refptr<PrinterQuery> printer_query; | 269 scoped_refptr<PrinterQuery> printer_query; |
270 if (!profile_io_data_->printing_enabled()->GetValue()) { | 270 if (!profile_io_data_->printing_enabled()->GetValue()) { |
271 // Reply with NULL query. | 271 // Reply with NULL query. |
272 OnGetDefaultPrintSettingsReply(printer_query, reply_msg); | 272 OnGetDefaultPrintSettingsReply(printer_query, reply_msg); |
273 return; | 273 return; |
274 } | 274 } |
275 printer_query = queue_->PopPrinterQuery(0); | 275 printer_query = queue_->PopPrinterQuery(0); |
276 if (!printer_query) { | 276 if (!printer_query.get()) { |
277 printer_query = | 277 printer_query = |
278 queue_->CreatePrinterQuery(render_process_id_, reply_msg->routing_id()); | 278 queue_->CreatePrinterQuery(render_process_id_, reply_msg->routing_id()); |
279 } | 279 } |
280 | 280 |
281 // Loads default settings. This is asynchronous, only the IPC message sender | 281 // Loads default settings. This is asynchronous, only the IPC message sender |
282 // will hang until the settings are retrieved. | 282 // will hang until the settings are retrieved. |
283 printer_query->GetSettings( | 283 printer_query->GetSettings( |
284 PrinterQuery::DEFAULTS, | 284 PrinterQuery::DEFAULTS, |
285 0, | 285 0, |
286 false, | 286 false, |
(...skipping 26 matching lines...) Expand all Loading... |
313 printer_query->StopWorker(); | 313 printer_query->StopWorker(); |
314 } | 314 } |
315 } | 315 } |
316 } | 316 } |
317 | 317 |
318 void PrintingMessageFilter::OnScriptedPrint( | 318 void PrintingMessageFilter::OnScriptedPrint( |
319 const PrintHostMsg_ScriptedPrint_Params& params, | 319 const PrintHostMsg_ScriptedPrint_Params& params, |
320 IPC::Message* reply_msg) { | 320 IPC::Message* reply_msg) { |
321 scoped_refptr<PrinterQuery> printer_query = | 321 scoped_refptr<PrinterQuery> printer_query = |
322 queue_->PopPrinterQuery(params.cookie); | 322 queue_->PopPrinterQuery(params.cookie); |
323 if (!printer_query) { | 323 if (!printer_query.get()) { |
324 printer_query = | 324 printer_query = |
325 queue_->CreatePrinterQuery(render_process_id_, reply_msg->routing_id()); | 325 queue_->CreatePrinterQuery(render_process_id_, reply_msg->routing_id()); |
326 } | 326 } |
327 printer_query->GetSettings( | 327 printer_query->GetSettings( |
328 PrinterQuery::ASK_USER, | 328 PrinterQuery::ASK_USER, |
329 params.expected_pages_count, | 329 params.expected_pages_count, |
330 params.has_selection, | 330 params.has_selection, |
331 params.margin_type, | 331 params.margin_type, |
332 base::Bind(&PrintingMessageFilter::OnScriptedPrintReply, | 332 base::Bind(&PrintingMessageFilter::OnScriptedPrintReply, |
333 this, | 333 this, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 IPC::Message* reply_msg) { | 388 IPC::Message* reply_msg) { |
389 scoped_ptr<base::DictionaryValue> new_settings(job_settings.DeepCopy()); | 389 scoped_ptr<base::DictionaryValue> new_settings(job_settings.DeepCopy()); |
390 | 390 |
391 scoped_refptr<PrinterQuery> printer_query; | 391 scoped_refptr<PrinterQuery> printer_query; |
392 if (!profile_io_data_->printing_enabled()->GetValue()) { | 392 if (!profile_io_data_->printing_enabled()->GetValue()) { |
393 // Reply with NULL query. | 393 // Reply with NULL query. |
394 OnUpdatePrintSettingsReply(printer_query, reply_msg); | 394 OnUpdatePrintSettingsReply(printer_query, reply_msg); |
395 return; | 395 return; |
396 } | 396 } |
397 printer_query = queue_->PopPrinterQuery(document_cookie); | 397 printer_query = queue_->PopPrinterQuery(document_cookie); |
398 if (!printer_query) { | 398 if (!printer_query.get()) { |
399 int host_id = render_process_id_; | 399 int host_id = render_process_id_; |
400 int routing_id = reply_msg->routing_id(); | 400 int routing_id = reply_msg->routing_id(); |
401 if (!new_settings->GetInteger(printing::kPreviewInitiatorHostId, | 401 if (!new_settings->GetInteger(printing::kPreviewInitiatorHostId, |
402 &host_id) || | 402 &host_id) || |
403 !new_settings->GetInteger(printing::kPreviewInitiatorRoutingId, | 403 !new_settings->GetInteger(printing::kPreviewInitiatorRoutingId, |
404 &routing_id)) { | 404 &routing_id)) { |
405 host_id = content::ChildProcessHost::kInvalidUniqueID; | 405 host_id = content::ChildProcessHost::kInvalidUniqueID; |
406 routing_id = content::ChildProcessHost::kInvalidUniqueID; | 406 routing_id = content::ChildProcessHost::kInvalidUniqueID; |
407 } | 407 } |
408 printer_query = queue_->CreatePrinterQuery(host_id, routing_id); | 408 printer_query = queue_->CreatePrinterQuery(host_id, routing_id); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 void PrintingMessageFilter::OnCheckForCancel(int32 preview_ui_id, | 441 void PrintingMessageFilter::OnCheckForCancel(int32 preview_ui_id, |
442 int preview_request_id, | 442 int preview_request_id, |
443 bool* cancel) { | 443 bool* cancel) { |
444 PrintPreviewUI::GetCurrentPrintPreviewStatus(preview_ui_id, | 444 PrintPreviewUI::GetCurrentPrintPreviewStatus(preview_ui_id, |
445 preview_request_id, | 445 preview_request_id, |
446 cancel); | 446 cancel); |
447 } | 447 } |
448 #endif | 448 #endif |
449 | 449 |
450 } // namespace printing | 450 } // namespace printing |
OLD | NEW |