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