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_system_task_proxy.h" | 5 #include "chrome/browser/printing/print_system_task_proxy.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 : handler_(handler), | 309 : handler_(handler), |
310 print_backend_(print_backend), | 310 print_backend_(print_backend), |
311 has_logged_printers_count_(has_logged_printers_count) { | 311 has_logged_printers_count_(has_logged_printers_count) { |
312 } | 312 } |
313 | 313 |
314 PrintSystemTaskProxy::~PrintSystemTaskProxy() { | 314 PrintSystemTaskProxy::~PrintSystemTaskProxy() { |
315 } | 315 } |
316 | 316 |
317 void PrintSystemTaskProxy::GetDefaultPrinter() { | 317 void PrintSystemTaskProxy::GetDefaultPrinter() { |
318 VLOG(1) << "Get default printer start"; | 318 VLOG(1) << "Get default printer start"; |
319 std::string* default_printer = NULL; | 319 StringValue* default_printer = NULL; |
320 if (PrintPreviewHandler::last_used_printer_name_ == NULL) { | 320 if (PrintPreviewHandler::last_used_printer_name_ == NULL) { |
321 default_printer = new std::string(print_backend_->GetDefaultPrinterName()); | 321 default_printer = new StringValue( |
| 322 print_backend_->GetDefaultPrinterName()); |
322 } else { | 323 } else { |
323 default_printer = new std::string( | 324 default_printer = new StringValue( |
324 *PrintPreviewHandler::last_used_printer_name_); | 325 *PrintPreviewHandler::last_used_printer_name_); |
325 } | 326 } |
| 327 std::string default_printer_string; |
| 328 default_printer->GetAsString(&default_printer_string); |
326 VLOG(1) << "Get default printer finished, found: " | 329 VLOG(1) << "Get default printer finished, found: " |
327 << default_printer; | 330 << default_printer_string; |
328 | 331 |
329 std::string* cloud_print_data = NULL; | 332 StringValue* cloud_print_data = NULL; |
330 if (PrintPreviewHandler::last_used_printer_cloud_print_data_ != NULL) { | 333 if (PrintPreviewHandler::last_used_printer_cloud_print_data_ != NULL) { |
331 cloud_print_data = new std::string( | 334 cloud_print_data = new StringValue( |
332 *PrintPreviewHandler::last_used_printer_cloud_print_data_); | 335 *PrintPreviewHandler::last_used_printer_cloud_print_data_); |
333 } else { | 336 } else { |
334 cloud_print_data = new std::string; | 337 cloud_print_data = new StringValue(""); |
335 } | 338 } |
336 | 339 |
337 BrowserThread::PostTask( | 340 BrowserThread::PostTask( |
338 BrowserThread::UI, FROM_HERE, | 341 BrowserThread::UI, FROM_HERE, |
339 base::Bind(&PrintSystemTaskProxy::SendDefaultPrinter, this, | 342 base::Bind(&PrintSystemTaskProxy::SendDefaultPrinter, this, |
340 default_printer, cloud_print_data)); | 343 default_printer, cloud_print_data)); |
341 } | 344 } |
342 | 345 |
343 void PrintSystemTaskProxy::SendDefaultPrinter( | 346 void PrintSystemTaskProxy::SendDefaultPrinter( |
344 const std::string* default_printer, const std::string* cloud_print_data) { | 347 const StringValue* default_printer, const StringValue* cloud_print_data) { |
345 if (handler_) | 348 if (handler_) |
346 handler_->SendInitialSettings(*default_printer, *cloud_print_data); | 349 handler_->SendDefaultPrinter(*default_printer, *cloud_print_data); |
347 delete default_printer; | 350 delete default_printer; |
348 } | 351 } |
349 | 352 |
350 void PrintSystemTaskProxy::EnumeratePrinters() { | 353 void PrintSystemTaskProxy::EnumeratePrinters() { |
351 VLOG(1) << "Enumerate printers start"; | 354 VLOG(1) << "Enumerate printers start"; |
352 ListValue* printers = new ListValue; | 355 ListValue* printers = new ListValue; |
353 printing::PrinterList printer_list; | 356 printing::PrinterList printer_list; |
354 print_backend_->EnumeratePrinters(&printer_list); | 357 print_backend_->EnumeratePrinters(&printer_list); |
355 | 358 |
356 if (!has_logged_printers_count_) { | 359 if (!has_logged_printers_count_) { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 base::Bind(&PrintSystemTaskProxy::SendPrinterCapabilities, this, | 538 base::Bind(&PrintSystemTaskProxy::SendPrinterCapabilities, this, |
536 settings_info.DeepCopy())); | 539 settings_info.DeepCopy())); |
537 } | 540 } |
538 | 541 |
539 void PrintSystemTaskProxy::SendPrinterCapabilities( | 542 void PrintSystemTaskProxy::SendPrinterCapabilities( |
540 DictionaryValue* settings_info) { | 543 DictionaryValue* settings_info) { |
541 if (handler_) | 544 if (handler_) |
542 handler_->SendPrinterCapabilities(*settings_info); | 545 handler_->SendPrinterCapabilities(*settings_info); |
543 delete settings_info; | 546 delete settings_info; |
544 } | 547 } |
OLD | NEW |