| 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/ui/webui/print_preview/print_preview_handler.h" | 5 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h" |
| 6 | 6 |
| 7 #include <ctype.h> | 7 #include <ctype.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); | 302 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); |
| 303 metafile.SaveTo(&file); | 303 metafile.SaveTo(&file); |
| 304 if (!pdf_file_saved_closure.is_null()) | 304 if (!pdf_file_saved_closure.is_null()) |
| 305 pdf_file_saved_closure.Run(); | 305 pdf_file_saved_closure.Run(); |
| 306 } | 306 } |
| 307 | 307 |
| 308 std::string GetDefaultPrinterOnFileThread() { | 308 std::string GetDefaultPrinterOnFileThread() { |
| 309 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 309 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 310 | 310 |
| 311 scoped_refptr<printing::PrintBackend> print_backend( | 311 scoped_refptr<printing::PrintBackend> print_backend( |
| 312 printing::PrintBackend::CreateInstance(NULL)); | 312 printing::PrintBackend::CreateInstance(nullptr)); |
| 313 | 313 |
| 314 std::string default_printer = print_backend->GetDefaultPrinterName(); | 314 std::string default_printer = print_backend->GetDefaultPrinterName(); |
| 315 VLOG(1) << "Default Printer: " << default_printer; | 315 VLOG(1) << "Default Printer: " << default_printer; |
| 316 return default_printer; | 316 return default_printer; |
| 317 } | 317 } |
| 318 | 318 |
| 319 class PrintingContextDelegate : public printing::PrintingContext::Delegate { | 319 class PrintingContextDelegate : public printing::PrintingContext::Delegate { |
| 320 public: | 320 public: |
| 321 // PrintingContext::Delegate methods. | 321 // PrintingContext::Delegate methods. |
| 322 gfx::NativeView GetParentView() override { return NULL; } | 322 gfx::NativeView GetParentView() override { return NULL; } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 334 return gfx::Size(); | 334 return gfx::Size(); |
| 335 } | 335 } |
| 336 gfx::Size pdf_media_size = printing_context->GetPdfPaperSizeDeviceUnits(); | 336 gfx::Size pdf_media_size = printing_context->GetPdfPaperSizeDeviceUnits(); |
| 337 float deviceMicronsPerDeviceUnit = | 337 float deviceMicronsPerDeviceUnit = |
| 338 (printing::kHundrethsMMPerInch * 10.0f) / | 338 (printing::kHundrethsMMPerInch * 10.0f) / |
| 339 printing_context->settings().device_units_per_inch(); | 339 printing_context->settings().device_units_per_inch(); |
| 340 return gfx::Size(pdf_media_size.width() * deviceMicronsPerDeviceUnit, | 340 return gfx::Size(pdf_media_size.width() * deviceMicronsPerDeviceUnit, |
| 341 pdf_media_size.height() * deviceMicronsPerDeviceUnit); | 341 pdf_media_size.height() * deviceMicronsPerDeviceUnit); |
| 342 } | 342 } |
| 343 | 343 |
| 344 typedef base::Callback<void(const base::DictionaryValue*)> | 344 std::unique_ptr<base::DictionaryValue> GetPdfCapabilities( |
| 345 GetPdfCapabilitiesCallback; | |
| 346 | |
| 347 std::unique_ptr<base::DictionaryValue> GetPdfCapabilitiesOnFileThread( | |
| 348 const std::string& locale) { | 345 const std::string& locale) { |
| 349 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 346 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 350 | 347 |
| 351 cloud_devices::CloudDeviceDescription description; | 348 cloud_devices::CloudDeviceDescription description; |
| 352 using namespace cloud_devices::printer; | 349 using namespace cloud_devices::printer; |
| 353 | 350 |
| 354 OrientationCapability orientation; | 351 OrientationCapability orientation; |
| 355 orientation.AddOption(cloud_devices::printer::PORTRAIT); | 352 orientation.AddOption(cloud_devices::printer::PORTRAIT); |
| 356 orientation.AddOption(cloud_devices::printer::LANDSCAPE); | 353 orientation.AddOption(cloud_devices::printer::LANDSCAPE); |
| 357 orientation.AddDefaultOption(AUTO_ORIENTATION, true); | 354 orientation.AddDefaultOption(AUTO_ORIENTATION, true); |
| 358 orientation.SaveTo(&description); | 355 orientation.SaveTo(&description); |
| 359 | 356 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 389 for (size_t i = 0; i < arraysize(kPdfMedia); ++i) { | 386 for (size_t i = 0; i < arraysize(kPdfMedia); ++i) { |
| 390 Media media_option(kPdfMedia[i]); | 387 Media media_option(kPdfMedia[i]); |
| 391 media.AddDefaultOption(media_option, | 388 media.AddDefaultOption(media_option, |
| 392 default_media.type == media_option.type); | 389 default_media.type == media_option.type); |
| 393 } | 390 } |
| 394 media.SaveTo(&description); | 391 media.SaveTo(&description); |
| 395 | 392 |
| 396 return std::unique_ptr<base::DictionaryValue>(description.root().DeepCopy()); | 393 return std::unique_ptr<base::DictionaryValue>(description.root().DeepCopy()); |
| 397 } | 394 } |
| 398 | 395 |
| 399 std::unique_ptr<base::DictionaryValue> GetLocalPrinterCapabilitiesOnFileThread( | 396 std::pair<std::string, std::string> GetPrinterNameAndDescription( |
| 400 const std::string& printer_name) { | 397 const printing::PrinterBasicInfo& printer) { |
| 401 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 398 #if defined(OS_MACOSX) |
| 402 | 399 // On Mac, |printer.printer_description| specifies the printer name and |
| 403 scoped_refptr<printing::PrintBackend> print_backend( | 400 // |printer.printer_name| specifies the device name / printer queue name. |
| 404 printing::PrintBackend::CreateInstance(NULL)); | 401 const std::string& real_name = printer.printer_description; |
| 405 | 402 std::string real_description; |
| 406 VLOG(1) << "Get printer capabilities start for " << printer_name; | 403 const auto it = printer.options.find(kDriverNameTagName); |
| 407 crash_keys::ScopedPrinterInfo crash_key( | 404 if (it != printer.options.end()) |
| 408 print_backend->GetPrinterDriverInfo(printer_name)); | 405 real_description = it->second; |
| 409 | 406 return std::make_pair(real_name, real_description); |
| 410 if (!print_backend->IsValidPrinter(printer_name)) { | 407 #else |
| 411 LOG(WARNING) << "Invalid printer " << printer_name; | 408 return std::make_pair(printer.printer_name, printer.printer_description); |
| 412 return std::unique_ptr<base::DictionaryValue>(); | 409 #endif |
| 413 } | |
| 414 | |
| 415 printing::PrinterSemanticCapsAndDefaults info; | |
| 416 if (!print_backend->GetPrinterSemanticCapsAndDefaults(printer_name, &info)) { | |
| 417 LOG(WARNING) << "Failed to get capabilities for " << printer_name; | |
| 418 return std::unique_ptr<base::DictionaryValue>(); | |
| 419 } | |
| 420 | |
| 421 std::unique_ptr<base::DictionaryValue> description( | |
| 422 cloud_print::PrinterSemanticCapsAndDefaultsToCdd(info)); | |
| 423 if (!description) { | |
| 424 LOG(WARNING) << "Failed to convert capabilities for " << printer_name; | |
| 425 return std::unique_ptr<base::DictionaryValue>(); | |
| 426 } | |
| 427 | |
| 428 return description; | |
| 429 } | 410 } |
| 430 | 411 |
| 431 void EnumeratePrintersOnFileThread(base::ListValue* printers) { | 412 void EnumeratePrintersOnFileThread(base::ListValue* printers) { |
| 432 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 413 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 433 | 414 |
| 434 scoped_refptr<printing::PrintBackend> print_backend( | 415 scoped_refptr<printing::PrintBackend> print_backend( |
| 435 printing::PrintBackend::CreateInstance(NULL)); | 416 printing::PrintBackend::CreateInstance(nullptr)); |
| 436 | 417 |
| 437 VLOG(1) << "Enumerate printers start"; | 418 VLOG(1) << "Enumerate printers start"; |
| 438 printing::PrinterList printer_list; | 419 printing::PrinterList printer_list; |
| 439 print_backend->EnumeratePrinters(&printer_list); | 420 print_backend->EnumeratePrinters(&printer_list); |
| 440 | 421 |
| 441 for (printing::PrinterList::iterator it = printer_list.begin(); | 422 for (const printing::PrinterBasicInfo& printer : printer_list) { |
| 442 it != printer_list.end(); ++it) { | |
| 443 base::DictionaryValue* printer_info = new base::DictionaryValue; | 423 base::DictionaryValue* printer_info = new base::DictionaryValue; |
| 444 printers->Append(printer_info); | 424 printers->Append(printer_info); |
| 445 std::string printer_name; | 425 |
| 446 std::string printer_description; | 426 const auto printer_name_description = GetPrinterNameAndDescription(printer); |
| 447 #if defined(OS_MACOSX) | 427 const std::string& printer_name = printer_name_description.first; |
| 448 // On Mac, |it->printer_description| specifies the printer name and | 428 const std::string& printer_description = printer_name_description.second; |
| 449 // |it->printer_name| specifies the device name / printer queue name. | 429 printer_info->SetString(printing::kSettingDeviceName, printer.printer_name); |
| 450 printer_name = it->printer_description; | 430 printer_info->SetString(printing::kSettingPrinterName, printer_name); |
| 451 if (!it->options[kDriverNameTagName].empty()) | |
| 452 printer_description = it->options[kDriverNameTagName]; | |
| 453 #else | |
| 454 printer_name = it->printer_name; | |
| 455 printer_description = it->printer_description; | |
| 456 #endif | |
| 457 printer_info->SetString(printing::kSettingDeviceName, it->printer_name); | |
| 458 printer_info->SetString(printing::kSettingPrinterDescription, | 431 printer_info->SetString(printing::kSettingPrinterDescription, |
| 459 printer_description); | 432 printer_description); |
| 460 printer_info->SetString(printing::kSettingPrinterName, printer_name); | |
| 461 VLOG(1) << "Found printer " << printer_name | |
| 462 << " with device name " << it->printer_name; | |
| 463 | 433 |
| 464 base::DictionaryValue* options = new base::DictionaryValue; | 434 base::DictionaryValue* options = new base::DictionaryValue; |
| 465 printer_info->Set(printing::kSettingPrinterOptions, options); | 435 printer_info->Set(printing::kSettingPrinterOptions, options); |
| 466 for (std::map<std::string, std::string>::iterator opt = it->options.begin(); | 436 for (const auto opt_it : printer.options) |
| 467 opt != it->options.end(); | 437 options->SetString(opt_it.first, opt_it.second); |
| 468 ++opt) { | |
| 469 options->SetString(opt->first, opt->second); | |
| 470 } | |
| 471 | 438 |
| 472 VLOG(1) << "Found printer " << printer_name << " with device name " | 439 VLOG(1) << "Found printer " << printer_name << " with device name " |
| 473 << it->printer_name; | 440 << printer.printer_name; |
| 474 } | 441 } |
| 475 VLOG(1) << "Enumerate printers finished, found " << printers->GetSize() | 442 VLOG(1) << "Enumerate printers finished, found " << printers->GetSize() |
| 476 << " printers"; | 443 << " printers"; |
| 477 } | 444 } |
| 478 | 445 |
| 479 typedef base::Callback<void(const base::DictionaryValue*)> | 446 std::unique_ptr<base::DictionaryValue> GetPrinterCapabilitiesOnFileThread( |
| 480 GetPrinterCapabilitiesSuccessCallback; | 447 const std::string& device_name) { |
| 481 typedef base::Callback<void(const std::string&)> | 448 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 482 GetPrinterCapabilitiesFailureCallback; | 449 DCHECK(!device_name.empty()); |
| 483 | 450 |
| 484 void GetPrinterCapabilitiesOnFileThread( | 451 scoped_refptr<printing::PrintBackend> print_backend( |
| 485 const std::string& printer_name, | 452 printing::PrintBackend::CreateInstance(nullptr)); |
| 486 const std::string& locale, | |
| 487 const GetPrinterCapabilitiesSuccessCallback& success_cb, | |
| 488 const GetPrinterCapabilitiesFailureCallback& failure_cb) { | |
| 489 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | |
| 490 DCHECK(!printer_name.empty()); | |
| 491 | 453 |
| 492 std::unique_ptr<base::DictionaryValue> printer_capabilities( | 454 VLOG(1) << "Get printer capabilities start for " << device_name; |
| 493 printer_name == kLocalPdfPrinterId | 455 crash_keys::ScopedPrinterInfo crash_key( |
| 494 ? GetPdfCapabilitiesOnFileThread(locale) | 456 print_backend->GetPrinterDriverInfo(device_name)); |
| 495 : GetLocalPrinterCapabilitiesOnFileThread(printer_name)); | 457 |
| 496 if (!printer_capabilities) { | 458 std::unique_ptr<base::DictionaryValue> printer_info; |
| 497 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 459 if (!print_backend->IsValidPrinter(device_name)) { |
| 498 base::Bind(failure_cb, printer_name)); | 460 LOG(WARNING) << "Invalid printer " << device_name; |
| 499 return; | 461 return printer_info; |
| 500 } | 462 } |
| 501 | 463 |
| 502 std::unique_ptr<base::DictionaryValue> printer_info( | 464 printing::PrinterSemanticCapsAndDefaults info; |
| 503 new base::DictionaryValue); | 465 if (!print_backend->GetPrinterSemanticCapsAndDefaults(device_name, &info)) { |
| 504 printer_info->SetString(kPrinterId, printer_name); | 466 LOG(WARNING) << "Failed to get capabilities for " << device_name; |
| 467 return printer_info; |
| 468 } |
| 469 |
| 470 std::unique_ptr<base::DictionaryValue> printer_capabilities = |
| 471 cloud_print::PrinterSemanticCapsAndDefaultsToCdd(info); |
| 472 if (!printer_capabilities) { |
| 473 LOG(WARNING) << "Failed to convert capabilities for " << device_name; |
| 474 return printer_info; |
| 475 } |
| 476 |
| 477 printing::PrinterBasicInfo basic_info; |
| 478 if (!print_backend->GetPrinterBasicInfo(device_name, &basic_info)) |
| 479 return printer_info; |
| 480 |
| 481 const auto printer_name_description = |
| 482 GetPrinterNameAndDescription(basic_info); |
| 483 const std::string& printer_name = printer_name_description.first; |
| 484 const std::string& printer_description = printer_name_description.second; |
| 485 |
| 486 printer_info.reset(new base::DictionaryValue); |
| 487 printer_info->SetString(kPrinterId, device_name); |
| 488 printer_info->SetString(printing::kSettingPrinterName, printer_name); |
| 489 printer_info->SetString(printing::kSettingPrinterDescription, |
| 490 printer_description); |
| 505 printer_info->Set(kPrinterCapabilities, printer_capabilities.release()); | 491 printer_info->Set(kPrinterCapabilities, printer_capabilities.release()); |
| 506 | 492 return printer_info; |
| 507 BrowserThread::PostTask( | |
| 508 BrowserThread::UI, FROM_HERE, | |
| 509 base::Bind(success_cb, base::Owned(printer_info.release()))); | |
| 510 } | 493 } |
| 511 | 494 |
| 512 base::LazyInstance<printing::StickySettings> g_sticky_settings = | 495 base::LazyInstance<printing::StickySettings> g_sticky_settings = |
| 513 LAZY_INSTANCE_INITIALIZER; | 496 LAZY_INSTANCE_INITIALIZER; |
| 514 | 497 |
| 515 printing::StickySettings* GetStickySettings() { | 498 printing::StickySettings* GetStickySettings() { |
| 516 return g_sticky_settings.Pointer(); | 499 return g_sticky_settings.Pointer(); |
| 517 } | 500 } |
| 518 | 501 |
| 519 // Returns a unique path for |path|, just like with downloads. | 502 // Returns a unique path for |path|, just like with downloads. |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 preview_web_contents()->GetBrowserContext())->GetPrefs()); | 1096 preview_web_contents()->GetBrowserContext())->GetPrefs()); |
| 1114 } | 1097 } |
| 1115 | 1098 |
| 1116 void PrintPreviewHandler::HandleGetPrinterCapabilities( | 1099 void PrintPreviewHandler::HandleGetPrinterCapabilities( |
| 1117 const base::ListValue* args) { | 1100 const base::ListValue* args) { |
| 1118 std::string printer_name; | 1101 std::string printer_name; |
| 1119 bool ret = args->GetString(0, &printer_name); | 1102 bool ret = args->GetString(0, &printer_name); |
| 1120 if (!ret || printer_name.empty()) | 1103 if (!ret || printer_name.empty()) |
| 1121 return; | 1104 return; |
| 1122 | 1105 |
| 1123 GetPrinterCapabilitiesSuccessCallback success_cb = | 1106 if (printer_name == kLocalPdfPrinterId) { |
| 1107 std::unique_ptr<base::DictionaryValue> printer_info( |
| 1108 new base::DictionaryValue); |
| 1109 printer_info->SetString(kPrinterId, printer_name); |
| 1110 printer_info->Set( |
| 1111 kPrinterCapabilities, |
| 1112 GetPdfCapabilities(g_browser_process->GetApplicationLocale())); |
| 1113 SendPrinterCapabilities(printer_name, std::move(printer_info)); |
| 1114 return; |
| 1115 } |
| 1116 |
| 1117 BrowserThread::PostTaskAndReplyWithResult( |
| 1118 BrowserThread::FILE, FROM_HERE, |
| 1119 base::Bind(&GetPrinterCapabilitiesOnFileThread, printer_name), |
| 1124 base::Bind(&PrintPreviewHandler::SendPrinterCapabilities, | 1120 base::Bind(&PrintPreviewHandler::SendPrinterCapabilities, |
| 1125 weak_factory_.GetWeakPtr()); | 1121 weak_factory_.GetWeakPtr(), printer_name)); |
| 1126 GetPrinterCapabilitiesFailureCallback failure_cb = | |
| 1127 base::Bind(&PrintPreviewHandler::SendFailedToGetPrinterCapabilities, | |
| 1128 weak_factory_.GetWeakPtr()); | |
| 1129 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | |
| 1130 base::Bind(&GetPrinterCapabilitiesOnFileThread, | |
| 1131 printer_name, | |
| 1132 g_browser_process->GetApplicationLocale(), | |
| 1133 success_cb, failure_cb)); | |
| 1134 } | 1122 } |
| 1135 | 1123 |
| 1136 void PrintPreviewHandler::OnSigninComplete() { | 1124 void PrintPreviewHandler::OnSigninComplete() { |
| 1137 if (print_preview_ui()) | 1125 if (print_preview_ui()) |
| 1138 print_preview_ui()->OnReloadPrintersList(); | 1126 print_preview_ui()->OnReloadPrintersList(); |
| 1139 } | 1127 } |
| 1140 | 1128 |
| 1141 void PrintPreviewHandler::HandleSignin(const base::ListValue* args) { | 1129 void PrintPreviewHandler::HandleSignin(const base::ListValue* args) { |
| 1142 bool add_account = false; | 1130 bool add_account = false; |
| 1143 bool success = args->GetBoolean(0, &add_account); | 1131 bool success = args->GetBoolean(0, &add_account); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 system = UMS_SI; | 1226 system = UMS_SI; |
| 1239 | 1227 |
| 1240 // Getting the number formatting based on the locale and writing to | 1228 // Getting the number formatting based on the locale and writing to |
| 1241 // dictionary. | 1229 // dictionary. |
| 1242 settings->SetString(kNumberFormat, base::FormatDouble(123456.78, 2)); | 1230 settings->SetString(kNumberFormat, base::FormatDouble(123456.78, 2)); |
| 1243 settings->SetInteger(kMeasurementSystem, system); | 1231 settings->SetInteger(kMeasurementSystem, system); |
| 1244 } | 1232 } |
| 1245 | 1233 |
| 1246 void PrintPreviewHandler::HandleGetInitialSettings( | 1234 void PrintPreviewHandler::HandleGetInitialSettings( |
| 1247 const base::ListValue* /*args*/) { | 1235 const base::ListValue* /*args*/) { |
| 1248 // Send before SendInitialSettings to allow cloud printer auto select. | 1236 // Send before SendInitialSettings() to allow cloud printer auto select. |
| 1249 SendCloudPrintEnabled(); | 1237 SendCloudPrintEnabled(); |
| 1250 BrowserThread::PostTaskAndReplyWithResult( | 1238 BrowserThread::PostTaskAndReplyWithResult( |
| 1251 BrowserThread::FILE, FROM_HERE, | 1239 BrowserThread::FILE, FROM_HERE, |
| 1252 base::Bind(&GetDefaultPrinterOnFileThread), | 1240 base::Bind(&GetDefaultPrinterOnFileThread), |
| 1253 base::Bind(&PrintPreviewHandler::SendInitialSettings, | 1241 base::Bind(&PrintPreviewHandler::SendInitialSettings, |
| 1254 weak_factory_.GetWeakPtr())); | 1242 weak_factory_.GetWeakPtr())); |
| 1255 } | 1243 } |
| 1256 | 1244 |
| 1257 void PrintPreviewHandler::HandleForceOpenNewTab(const base::ListValue* args) { | 1245 void PrintPreviewHandler::HandleForceOpenNewTab(const base::ListValue* args) { |
| 1258 std::string url; | 1246 std::string url; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1317 | 1305 |
| 1318 void PrintPreviewHandler::SendAccessToken(const std::string& type, | 1306 void PrintPreviewHandler::SendAccessToken(const std::string& type, |
| 1319 const std::string& access_token) { | 1307 const std::string& access_token) { |
| 1320 VLOG(1) << "Get getAccessToken finished"; | 1308 VLOG(1) << "Get getAccessToken finished"; |
| 1321 web_ui()->CallJavascriptFunction("onDidGetAccessToken", | 1309 web_ui()->CallJavascriptFunction("onDidGetAccessToken", |
| 1322 base::StringValue(type), | 1310 base::StringValue(type), |
| 1323 base::StringValue(access_token)); | 1311 base::StringValue(access_token)); |
| 1324 } | 1312 } |
| 1325 | 1313 |
| 1326 void PrintPreviewHandler::SendPrinterCapabilities( | 1314 void PrintPreviewHandler::SendPrinterCapabilities( |
| 1327 const base::DictionaryValue* settings_info) { | 1315 const std::string& printer_name, |
| 1316 std::unique_ptr<base::DictionaryValue> settings_info) { |
| 1317 if (!settings_info) { |
| 1318 VLOG(1) << "Get printer capabilities failed"; |
| 1319 web_ui()->CallJavascriptFunction("failedToGetPrinterCapabilities", |
| 1320 base::StringValue(printer_name)); |
| 1321 return; |
| 1322 } |
| 1328 VLOG(1) << "Get printer capabilities finished"; | 1323 VLOG(1) << "Get printer capabilities finished"; |
| 1329 web_ui()->CallJavascriptFunction("updateWithPrinterCapabilities", | 1324 web_ui()->CallJavascriptFunction("updateWithPrinterCapabilities", |
| 1330 *settings_info); | 1325 *settings_info); |
| 1331 } | 1326 } |
| 1332 | 1327 |
| 1333 void PrintPreviewHandler::SendFailedToGetPrinterCapabilities( | |
| 1334 const std::string& printer_name) { | |
| 1335 VLOG(1) << "Get printer capabilities failed"; | |
| 1336 base::StringValue printer_name_value(printer_name); | |
| 1337 web_ui()->CallJavascriptFunction("failedToGetPrinterCapabilities", | |
| 1338 printer_name_value); | |
| 1339 } | |
| 1340 | |
| 1341 void PrintPreviewHandler::SetupPrinterList(const base::ListValue* printers) { | 1328 void PrintPreviewHandler::SetupPrinterList(const base::ListValue* printers) { |
| 1342 if (!has_logged_printers_count_) { | 1329 if (!has_logged_printers_count_) { |
| 1343 UMA_HISTOGRAM_COUNTS("PrintPreview.NumberOfPrinters", printers->GetSize()); | 1330 UMA_HISTOGRAM_COUNTS("PrintPreview.NumberOfPrinters", printers->GetSize()); |
| 1344 has_logged_printers_count_ = true; | 1331 has_logged_printers_count_ = true; |
| 1345 } | 1332 } |
| 1346 | 1333 |
| 1347 web_ui()->CallJavascriptFunction("setPrinters", *printers); | 1334 web_ui()->CallJavascriptFunction("setPrinters", *printers); |
| 1348 } | 1335 } |
| 1349 | 1336 |
| 1350 void PrintPreviewHandler::SendCloudPrintEnabled() { | 1337 void PrintPreviewHandler::SendCloudPrintEnabled() { |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1805 | 1792 |
| 1806 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { | 1793 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { |
| 1807 if (gaia_cookie_manager_service_) | 1794 if (gaia_cookie_manager_service_) |
| 1808 gaia_cookie_manager_service_->RemoveObserver(this); | 1795 gaia_cookie_manager_service_->RemoveObserver(this); |
| 1809 } | 1796 } |
| 1810 | 1797 |
| 1811 void PrintPreviewHandler::SetPdfSavedClosureForTesting( | 1798 void PrintPreviewHandler::SetPdfSavedClosureForTesting( |
| 1812 const base::Closure& closure) { | 1799 const base::Closure& closure) { |
| 1813 pdf_file_saved_closure_ = closure; | 1800 pdf_file_saved_closure_ = closure; |
| 1814 } | 1801 } |
| OLD | NEW |