Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: chrome/browser/ui/webui/print_preview/print_preview_handler.cc

Issue 1995113002: Rename WebUI::CallJavascriptFunction to WebUI::CallJavascriptFunctionUnsafe (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 BrowserThread::FILE, FROM_HERE, 701 BrowserThread::FILE, FROM_HERE,
702 base::Bind(&EnumeratePrintersOnFileThread, 702 base::Bind(&EnumeratePrintersOnFileThread,
703 base::Unretained(results)), 703 base::Unretained(results)),
704 base::Bind(&PrintPreviewHandler::SetupPrinterList, 704 base::Bind(&PrintPreviewHandler::SetupPrinterList,
705 weak_factory_.GetWeakPtr(), 705 weak_factory_.GetWeakPtr(),
706 base::Owned(results))); 706 base::Owned(results)));
707 } 707 }
708 708
709 void PrintPreviewHandler::HandleGetPrivetPrinters(const base::ListValue* args) { 709 void PrintPreviewHandler::HandleGetPrivetPrinters(const base::ListValue* args) {
710 if (!PrivetPrintingEnabled()) 710 if (!PrivetPrintingEnabled())
711 return web_ui()->CallJavascriptFunction("onPrivetPrinterSearchDone"); 711 return web_ui()->CallJavascriptFunctionUnsafe("onPrivetPrinterSearchDone");
712 #if defined(ENABLE_SERVICE_DISCOVERY) 712 #if defined(ENABLE_SERVICE_DISCOVERY)
713 using local_discovery::ServiceDiscoverySharedClient; 713 using local_discovery::ServiceDiscoverySharedClient;
714 scoped_refptr<ServiceDiscoverySharedClient> service_discovery = 714 scoped_refptr<ServiceDiscoverySharedClient> service_discovery =
715 ServiceDiscoverySharedClient::GetInstance(); 715 ServiceDiscoverySharedClient::GetInstance();
716 StartPrivetLister(service_discovery); 716 StartPrivetLister(service_discovery);
717 #endif // ENABLE_SERVICE_DISCOVERY 717 #endif // ENABLE_SERVICE_DISCOVERY
718 } 718 }
719 719
720 void PrintPreviewHandler::HandleStopGetPrivetPrinters( 720 void PrintPreviewHandler::HandleStopGetPrivetPrinters(
721 const base::ListValue* args) { 721 const base::ListValue* args) {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 int width = 0; 921 int width = 0;
922 int height = 0; 922 int height = 0;
923 if (!settings->GetString(printing::kSettingDeviceName, &printer_name) || 923 if (!settings->GetString(printing::kSettingDeviceName, &printer_name) ||
924 !settings->GetString(printing::kSettingTicket, &print_ticket) || 924 !settings->GetString(printing::kSettingTicket, &print_ticket) ||
925 !settings->GetString(printing::kSettingCapabilities, &capabilities) || 925 !settings->GetString(printing::kSettingCapabilities, &capabilities) ||
926 !settings->GetInteger(printing::kSettingPageWidth, &width) || 926 !settings->GetInteger(printing::kSettingPageWidth, &width) ||
927 !settings->GetInteger(printing::kSettingPageHeight, &height) || 927 !settings->GetInteger(printing::kSettingPageHeight, &height) ||
928 width <= 0 || height <= 0) { 928 width <= 0 || height <= 0) {
929 NOTREACHED(); 929 NOTREACHED();
930 base::FundamentalValue http_code_value(-1); 930 base::FundamentalValue http_code_value(-1);
931 web_ui()->CallJavascriptFunction("onPrivetPrintFailed", http_code_value); 931 web_ui()->CallJavascriptFunctionUnsafe("onPrivetPrintFailed",
932 http_code_value);
932 return; 933 return;
933 } 934 }
934 935
935 PrintToPrivetPrinter( 936 PrintToPrivetPrinter(
936 printer_name, print_ticket, capabilities, gfx::Size(width, height)); 937 printer_name, print_ticket, capabilities, gfx::Size(width, height));
937 return; 938 return;
938 } 939 }
939 #endif 940 #endif
940 941
941 if (print_with_extension) { 942 if (print_with_extension) {
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 chrome::IsRunningInForcedAppMode()); 1283 chrome::IsRunningInForcedAppMode());
1283 if (prefs) { 1284 if (prefs) {
1284 const std::string rules_str = 1285 const std::string rules_str =
1285 prefs->GetString(prefs::kPrintPreviewDefaultDestinationSelectionRules); 1286 prefs->GetString(prefs::kPrintPreviewDefaultDestinationSelectionRules);
1286 if (!rules_str.empty()) 1287 if (!rules_str.empty())
1287 initial_settings.SetString(kDefaultDestinationSelectionRules, rules_str); 1288 initial_settings.SetString(kDefaultDestinationSelectionRules, rules_str);
1288 } 1289 }
1289 1290
1290 if (print_preview_ui()->source_is_modifiable()) 1291 if (print_preview_ui()->source_is_modifiable())
1291 GetNumberFormatAndMeasurementSystem(&initial_settings); 1292 GetNumberFormatAndMeasurementSystem(&initial_settings);
1292 web_ui()->CallJavascriptFunction("setInitialSettings", initial_settings); 1293 web_ui()->CallJavascriptFunctionUnsafe("setInitialSettings",
1294 initial_settings);
1293 1295
1294 if (PrintPreviewDistiller::IsEnabled()) { 1296 if (PrintPreviewDistiller::IsEnabled()) {
1295 using dom_distiller::url_utils::IsUrlDistillable; 1297 using dom_distiller::url_utils::IsUrlDistillable;
1296 WebContents* initiator = GetInitiator(); 1298 WebContents* initiator = GetInitiator();
1297 if (initiator && IsUrlDistillable(initiator->GetLastCommittedURL())) 1299 if (initiator && IsUrlDistillable(initiator->GetLastCommittedURL()))
1298 web_ui()->CallJavascriptFunction("allowDistillPage"); 1300 web_ui()->CallJavascriptFunctionUnsafe("allowDistillPage");
1299 } 1301 }
1300 } 1302 }
1301 1303
1302 void PrintPreviewHandler::ClosePreviewDialog() { 1304 void PrintPreviewHandler::ClosePreviewDialog() {
1303 print_preview_ui()->OnClosePrintPreviewDialog(); 1305 print_preview_ui()->OnClosePrintPreviewDialog();
1304 } 1306 }
1305 1307
1306 void PrintPreviewHandler::SendAccessToken(const std::string& type, 1308 void PrintPreviewHandler::SendAccessToken(const std::string& type,
1307 const std::string& access_token) { 1309 const std::string& access_token) {
1308 VLOG(1) << "Get getAccessToken finished"; 1310 VLOG(1) << "Get getAccessToken finished";
1309 web_ui()->CallJavascriptFunction("onDidGetAccessToken", 1311 web_ui()->CallJavascriptFunctionUnsafe("onDidGetAccessToken",
1310 base::StringValue(type), 1312 base::StringValue(type),
1311 base::StringValue(access_token)); 1313 base::StringValue(access_token));
1312 } 1314 }
1313 1315
1314 void PrintPreviewHandler::SendPrinterCapabilities( 1316 void PrintPreviewHandler::SendPrinterCapabilities(
1315 const std::string& printer_name, 1317 const std::string& printer_name,
1316 std::unique_ptr<base::DictionaryValue> settings_info) { 1318 std::unique_ptr<base::DictionaryValue> settings_info) {
1317 if (!settings_info) { 1319 if (!settings_info) {
1318 VLOG(1) << "Get printer capabilities failed"; 1320 VLOG(1) << "Get printer capabilities failed";
1319 web_ui()->CallJavascriptFunction("failedToGetPrinterCapabilities", 1321 web_ui()->CallJavascriptFunctionUnsafe("failedToGetPrinterCapabilities",
1320 base::StringValue(printer_name)); 1322 base::StringValue(printer_name));
1321 return; 1323 return;
1322 } 1324 }
1323 VLOG(1) << "Get printer capabilities finished"; 1325 VLOG(1) << "Get printer capabilities finished";
1324 web_ui()->CallJavascriptFunction("updateWithPrinterCapabilities", 1326 web_ui()->CallJavascriptFunctionUnsafe("updateWithPrinterCapabilities",
1325 *settings_info); 1327 *settings_info);
1326 } 1328 }
1327 1329
1328 void PrintPreviewHandler::SetupPrinterList(const base::ListValue* printers) { 1330 void PrintPreviewHandler::SetupPrinterList(const base::ListValue* printers) {
1329 if (!has_logged_printers_count_) { 1331 if (!has_logged_printers_count_) {
1330 UMA_HISTOGRAM_COUNTS("PrintPreview.NumberOfPrinters", printers->GetSize()); 1332 UMA_HISTOGRAM_COUNTS("PrintPreview.NumberOfPrinters", printers->GetSize());
1331 has_logged_printers_count_ = true; 1333 has_logged_printers_count_ = true;
1332 } 1334 }
1333 1335
1334 web_ui()->CallJavascriptFunction("setPrinters", *printers); 1336 web_ui()->CallJavascriptFunctionUnsafe("setPrinters", *printers);
1335 } 1337 }
1336 1338
1337 void PrintPreviewHandler::SendCloudPrintEnabled() { 1339 void PrintPreviewHandler::SendCloudPrintEnabled() {
1338 Profile* profile = Profile::FromBrowserContext( 1340 Profile* profile = Profile::FromBrowserContext(
1339 preview_web_contents()->GetBrowserContext()); 1341 preview_web_contents()->GetBrowserContext());
1340 PrefService* prefs = profile->GetPrefs(); 1342 PrefService* prefs = profile->GetPrefs();
1341 if (prefs->GetBoolean(prefs::kCloudPrintSubmitEnabled)) { 1343 if (prefs->GetBoolean(prefs::kCloudPrintSubmitEnabled)) {
1342 base::DictionaryValue settings; 1344 base::DictionaryValue settings;
1343 settings.SetString(kCloudPrintUrl, 1345 settings.SetString(kCloudPrintUrl,
1344 GURL(cloud_devices::GetCloudPrintURL()).spec()); 1346 GURL(cloud_devices::GetCloudPrintURL()).spec());
1345 settings.SetBoolean(kAppKioskMode, chrome::IsRunningInForcedAppMode()); 1347 settings.SetBoolean(kAppKioskMode, chrome::IsRunningInForcedAppMode());
1346 web_ui()->CallJavascriptFunction("setUseCloudPrint", settings); 1348 web_ui()->CallJavascriptFunctionUnsafe("setUseCloudPrint", settings);
1347 } 1349 }
1348 } 1350 }
1349 1351
1350 void PrintPreviewHandler::SendCloudPrintJob(const base::RefCountedBytes* data) { 1352 void PrintPreviewHandler::SendCloudPrintJob(const base::RefCountedBytes* data) {
1351 // BASE64 encode the job data. 1353 // BASE64 encode the job data.
1352 const base::StringPiece raw_data(reinterpret_cast<const char*>(data->front()), 1354 const base::StringPiece raw_data(reinterpret_cast<const char*>(data->front()),
1353 data->size()); 1355 data->size());
1354 std::string base64_data; 1356 std::string base64_data;
1355 base::Base64Encode(raw_data, &base64_data); 1357 base::Base64Encode(raw_data, &base64_data);
1356 base::StringValue data_value(base64_data); 1358 base::StringValue data_value(base64_data);
1357 1359
1358 web_ui()->CallJavascriptFunction("printToCloud", data_value); 1360 web_ui()->CallJavascriptFunctionUnsafe("printToCloud", data_value);
1359 } 1361 }
1360 1362
1361 WebContents* PrintPreviewHandler::GetInitiator() const { 1363 WebContents* PrintPreviewHandler::GetInitiator() const {
1362 printing::PrintPreviewDialogController* dialog_controller = 1364 printing::PrintPreviewDialogController* dialog_controller =
1363 printing::PrintPreviewDialogController::GetInstance(); 1365 printing::PrintPreviewDialogController::GetInstance();
1364 if (!dialog_controller) 1366 if (!dialog_controller)
1365 return NULL; 1367 return NULL;
1366 return dialog_controller->GetInitiator(preview_web_contents()); 1368 return dialog_controller->GetInitiator(preview_web_contents());
1367 } 1369 }
1368 1370
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 #endif // ENABLE_BASIC_PRINTING 1447 #endif // ENABLE_BASIC_PRINTING
1446 1448
1447 void PrintPreviewHandler::FileSelected(const base::FilePath& path, 1449 void PrintPreviewHandler::FileSelected(const base::FilePath& path,
1448 int /* index */, 1450 int /* index */,
1449 void* /* params */) { 1451 void* /* params */) {
1450 // Updating |save_path_| to the newly selected folder. 1452 // Updating |save_path_| to the newly selected folder.
1451 printing::StickySettings* sticky_settings = GetStickySettings(); 1453 printing::StickySettings* sticky_settings = GetStickySettings();
1452 sticky_settings->StoreSavePath(path.DirName()); 1454 sticky_settings->StoreSavePath(path.DirName());
1453 sticky_settings->SaveInPrefs(Profile::FromBrowserContext( 1455 sticky_settings->SaveInPrefs(Profile::FromBrowserContext(
1454 preview_web_contents()->GetBrowserContext())->GetPrefs()); 1456 preview_web_contents()->GetBrowserContext())->GetPrefs());
1455 web_ui()->CallJavascriptFunction("fileSelectionCompleted"); 1457 web_ui()->CallJavascriptFunctionUnsafe("fileSelectionCompleted");
1456 print_to_pdf_path_ = path; 1458 print_to_pdf_path_ = path;
1457 PostPrintToPdfTask(); 1459 PostPrintToPdfTask();
1458 } 1460 }
1459 1461
1460 void PrintPreviewHandler::PostPrintToPdfTask() { 1462 void PrintPreviewHandler::PostPrintToPdfTask() {
1461 scoped_refptr<base::RefCountedBytes> data; 1463 scoped_refptr<base::RefCountedBytes> data;
1462 base::string16 title; 1464 base::string16 title;
1463 if (!GetPreviewDataAndTitle(&data, &title)) { 1465 if (!GetPreviewDataAndTitle(&data, &title)) {
1464 NOTREACHED() << "Preview data was checked before file dialog."; 1466 NOTREACHED() << "Preview data was checked before file dialog.";
1465 return; 1467 return;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1508 *data = tmp_data; 1510 *data = tmp_data;
1509 *title = print_preview_ui()->initiator_title(); 1511 *title = print_preview_ui()->initiator_title();
1510 return true; 1512 return true;
1511 } 1513 }
1512 1514
1513 #if defined(ENABLE_SERVICE_DISCOVERY) 1515 #if defined(ENABLE_SERVICE_DISCOVERY)
1514 1516
1515 void PrintPreviewHandler::StartPrivetLister(const scoped_refptr< 1517 void PrintPreviewHandler::StartPrivetLister(const scoped_refptr<
1516 local_discovery::ServiceDiscoverySharedClient>& client) { 1518 local_discovery::ServiceDiscoverySharedClient>& client) {
1517 if (!PrivetPrintingEnabled()) 1519 if (!PrivetPrintingEnabled())
1518 return web_ui()->CallJavascriptFunction("onPrivetPrinterSearchDone"); 1520 return web_ui()->CallJavascriptFunctionUnsafe("onPrivetPrinterSearchDone");
1519 1521
1520 Profile* profile = Profile::FromWebUI(web_ui()); 1522 Profile* profile = Profile::FromWebUI(web_ui());
1521 DCHECK(!service_discovery_client_.get() || 1523 DCHECK(!service_discovery_client_.get() ||
1522 service_discovery_client_.get() == client.get()); 1524 service_discovery_client_.get() == client.get());
1523 service_discovery_client_ = client; 1525 service_discovery_client_ = client;
1524 printer_lister_.reset(new cloud_print::PrivetLocalPrinterLister( 1526 printer_lister_.reset(new cloud_print::PrivetLocalPrinterLister(
1525 service_discovery_client_.get(), profile->GetRequestContext(), this)); 1527 service_discovery_client_.get(), profile->GetRequestContext(), this));
1526 printer_lister_->Start(); 1528 printer_lister_->Start();
1527 } 1529 }
1528 1530
1529 void PrintPreviewHandler::LocalPrinterChanged( 1531 void PrintPreviewHandler::LocalPrinterChanged(
1530 const std::string& name, 1532 const std::string& name,
1531 bool has_local_printing, 1533 bool has_local_printing,
1532 const cloud_print::DeviceDescription& description) { 1534 const cloud_print::DeviceDescription& description) {
1533 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 1535 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
1534 if (has_local_printing || 1536 if (has_local_printing ||
1535 command_line->HasSwitch(switches::kEnablePrintPreviewRegisterPromos)) { 1537 command_line->HasSwitch(switches::kEnablePrintPreviewRegisterPromos)) {
1536 base::DictionaryValue info; 1538 base::DictionaryValue info;
1537 FillPrinterDescription(name, description, has_local_printing, &info); 1539 FillPrinterDescription(name, description, has_local_printing, &info);
1538 web_ui()->CallJavascriptFunction("onPrivetPrinterChanged", info); 1540 web_ui()->CallJavascriptFunctionUnsafe("onPrivetPrinterChanged", info);
1539 } 1541 }
1540 } 1542 }
1541 1543
1542 void PrintPreviewHandler::LocalPrinterRemoved(const std::string& name) { 1544 void PrintPreviewHandler::LocalPrinterRemoved(const std::string& name) {
1543 } 1545 }
1544 1546
1545 void PrintPreviewHandler::LocalPrinterCacheFlushed() { 1547 void PrintPreviewHandler::LocalPrinterCacheFlushed() {
1546 } 1548 }
1547 1549
1548 void PrintPreviewHandler::PrivetCapabilitiesUpdateClient( 1550 void PrintPreviewHandler::PrivetCapabilitiesUpdateClient(
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1593 privet_http_client_->CreateLocalPrintOperation(this); 1595 privet_http_client_->CreateLocalPrintOperation(this);
1594 1596
1595 privet_local_print_operation_->SetTicket(print_ticket); 1597 privet_local_print_operation_->SetTicket(print_ticket);
1596 privet_local_print_operation_->SetCapabilities(capabilities); 1598 privet_local_print_operation_->SetCapabilities(capabilities);
1597 1599
1598 scoped_refptr<base::RefCountedBytes> data; 1600 scoped_refptr<base::RefCountedBytes> data;
1599 base::string16 title; 1601 base::string16 title;
1600 1602
1601 if (!GetPreviewDataAndTitle(&data, &title)) { 1603 if (!GetPreviewDataAndTitle(&data, &title)) {
1602 base::FundamentalValue http_code_value(-1); 1604 base::FundamentalValue http_code_value(-1);
1603 web_ui()->CallJavascriptFunction("onPrivetPrintFailed", http_code_value); 1605 web_ui()->CallJavascriptFunctionUnsafe("onPrivetPrintFailed",
1606 http_code_value);
1604 return; 1607 return;
1605 } 1608 }
1606 1609
1607 privet_local_print_operation_->SetJobname(base::UTF16ToUTF8(title)); 1610 privet_local_print_operation_->SetJobname(base::UTF16ToUTF8(title));
1608 privet_local_print_operation_->SetPageSize(page_size); 1611 privet_local_print_operation_->SetPageSize(page_size);
1609 privet_local_print_operation_->SetData(data.get()); 1612 privet_local_print_operation_->SetData(data.get());
1610 1613
1611 Profile* profile = Profile::FromWebUI(web_ui()); 1614 Profile* profile = Profile::FromWebUI(web_ui());
1612 SigninManagerBase* signin_manager = 1615 SigninManagerBase* signin_manager =
1613 SigninManagerFactory::GetForProfileIfExists(profile); 1616 SigninManagerFactory::GetForProfileIfExists(profile);
(...skipping 21 matching lines...) Expand all
1635 const cloud_print::DeviceDescription* description = 1638 const cloud_print::DeviceDescription* description =
1636 printer_lister_->GetDeviceDescription(name); 1639 printer_lister_->GetDeviceDescription(name);
1637 1640
1638 if (!description) { 1641 if (!description) {
1639 SendPrivetCapabilitiesError(name); 1642 SendPrivetCapabilitiesError(name);
1640 return; 1643 return;
1641 } 1644 }
1642 1645
1643 FillPrinterDescription(name, *description, true, &printer_info); 1646 FillPrinterDescription(name, *description, true, &printer_info);
1644 1647
1645 web_ui()->CallJavascriptFunction( 1648 web_ui()->CallJavascriptFunctionUnsafe("onPrivetCapabilitiesSet",
1646 "onPrivetCapabilitiesSet", 1649 printer_info, *capabilities);
1647 printer_info,
1648 *capabilities);
1649 1650
1650 privet_capabilities_operation_.reset(); 1651 privet_capabilities_operation_.reset();
1651 } 1652 }
1652 1653
1653 void PrintPreviewHandler::SendPrivetCapabilitiesError( 1654 void PrintPreviewHandler::SendPrivetCapabilitiesError(
1654 const std::string& device_name) { 1655 const std::string& device_name) {
1655 base::StringValue name_value(device_name); 1656 base::StringValue name_value(device_name);
1656 web_ui()->CallJavascriptFunction( 1657 web_ui()->CallJavascriptFunctionUnsafe("failedToGetPrivetPrinterCapabilities",
1657 "failedToGetPrivetPrinterCapabilities", 1658 name_value);
1658 name_value);
1659 } 1659 }
1660 1660
1661 void PrintPreviewHandler::PrintToPrivetPrinter(const std::string& device_name, 1661 void PrintPreviewHandler::PrintToPrivetPrinter(const std::string& device_name,
1662 const std::string& ticket, 1662 const std::string& ticket,
1663 const std::string& capabilities, 1663 const std::string& capabilities,
1664 const gfx::Size& page_size) { 1664 const gfx::Size& page_size) {
1665 CreatePrivetHTTP( 1665 CreatePrivetHTTP(
1666 device_name, 1666 device_name,
1667 base::Bind(&PrintPreviewHandler::PrivetLocalPrintUpdateClient, 1667 base::Bind(&PrintPreviewHandler::PrivetLocalPrintUpdateClient,
1668 base::Unretained(this), 1668 base::Unretained(this),
(...skipping 25 matching lines...) Expand all
1694 1694
1695 void PrintPreviewHandler::OnPrivetPrintingDone( 1695 void PrintPreviewHandler::OnPrivetPrintingDone(
1696 const cloud_print::PrivetLocalPrintOperation* print_operation) { 1696 const cloud_print::PrivetLocalPrintOperation* print_operation) {
1697 ClosePreviewDialog(); 1697 ClosePreviewDialog();
1698 } 1698 }
1699 1699
1700 void PrintPreviewHandler::OnPrivetPrintingError( 1700 void PrintPreviewHandler::OnPrivetPrintingError(
1701 const cloud_print::PrivetLocalPrintOperation* print_operation, 1701 const cloud_print::PrivetLocalPrintOperation* print_operation,
1702 int http_code) { 1702 int http_code) {
1703 base::FundamentalValue http_code_value(http_code); 1703 base::FundamentalValue http_code_value(http_code);
1704 web_ui()->CallJavascriptFunction("onPrivetPrintFailed", http_code_value); 1704 web_ui()->CallJavascriptFunctionUnsafe("onPrivetPrintFailed",
1705 http_code_value);
1705 } 1706 }
1706 1707
1707 void PrintPreviewHandler::FillPrinterDescription( 1708 void PrintPreviewHandler::FillPrinterDescription(
1708 const std::string& name, 1709 const std::string& name,
1709 const cloud_print::DeviceDescription& description, 1710 const cloud_print::DeviceDescription& description,
1710 bool has_local_printing, 1711 bool has_local_printing,
1711 base::DictionaryValue* printer_value) { 1712 base::DictionaryValue* printer_value) {
1712 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 1713 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
1713 1714
1714 printer_value->SetString("serviceName", name); 1715 printer_value->SetString("serviceName", name);
(...skipping 12 matching lines...) Expand all
1727 if (extension_printer_handler_) 1728 if (extension_printer_handler_)
1728 return; 1729 return;
1729 1730
1730 extension_printer_handler_ = 1731 extension_printer_handler_ =
1731 PrinterHandler::CreateForExtensionPrinters(Profile::FromWebUI(web_ui())); 1732 PrinterHandler::CreateForExtensionPrinters(Profile::FromWebUI(web_ui()));
1732 } 1733 }
1733 1734
1734 void PrintPreviewHandler::OnGotPrintersForExtension( 1735 void PrintPreviewHandler::OnGotPrintersForExtension(
1735 const base::ListValue& printers, 1736 const base::ListValue& printers,
1736 bool done) { 1737 bool done) {
1737 web_ui()->CallJavascriptFunction("onExtensionPrintersAdded", printers, 1738 web_ui()->CallJavascriptFunctionUnsafe("onExtensionPrintersAdded", printers,
1738 base::FundamentalValue(done)); 1739 base::FundamentalValue(done));
1739 } 1740 }
1740 1741
1741 void PrintPreviewHandler::OnGotExtensionPrinterInfo( 1742 void PrintPreviewHandler::OnGotExtensionPrinterInfo(
1742 const std::string& printer_id, 1743 const std::string& printer_id,
1743 const base::DictionaryValue& printer_info) { 1744 const base::DictionaryValue& printer_info) {
1744 if (printer_info.empty()) { 1745 if (printer_info.empty()) {
1745 web_ui()->CallJavascriptFunction("failedToResolveProvisionalPrinter", 1746 web_ui()->CallJavascriptFunctionUnsafe("failedToResolveProvisionalPrinter",
1746 base::StringValue(printer_id)); 1747 base::StringValue(printer_id));
1747 return; 1748 return;
1748 } 1749 }
1749 1750
1750 web_ui()->CallJavascriptFunction("onProvisionalPrinterResolved", 1751 web_ui()->CallJavascriptFunctionUnsafe("onProvisionalPrinterResolved",
1751 base::StringValue(printer_id), 1752 base::StringValue(printer_id),
1752 printer_info); 1753 printer_info);
1753 } 1754 }
1754 1755
1755 void PrintPreviewHandler::OnGotExtensionPrinterCapabilities( 1756 void PrintPreviewHandler::OnGotExtensionPrinterCapabilities(
1756 const std::string& printer_id, 1757 const std::string& printer_id,
1757 const base::DictionaryValue& capabilities) { 1758 const base::DictionaryValue& capabilities) {
1758 if (capabilities.empty()) { 1759 if (capabilities.empty()) {
1759 web_ui()->CallJavascriptFunction("failedToGetExtensionPrinterCapabilities", 1760 web_ui()->CallJavascriptFunctionUnsafe(
1760 base::StringValue(printer_id)); 1761 "failedToGetExtensionPrinterCapabilities",
1762 base::StringValue(printer_id));
1761 return; 1763 return;
1762 } 1764 }
1763 1765
1764 web_ui()->CallJavascriptFunction("onExtensionCapabilitiesSet", 1766 web_ui()->CallJavascriptFunctionUnsafe("onExtensionCapabilitiesSet",
1765 base::StringValue(printer_id), capabilities); 1767 base::StringValue(printer_id),
1768 capabilities);
1766 } 1769 }
1767 1770
1768 void PrintPreviewHandler::OnExtensionPrintResult(bool success, 1771 void PrintPreviewHandler::OnExtensionPrintResult(bool success,
1769 const std::string& status) { 1772 const std::string& status) {
1770 if (success) { 1773 if (success) {
1771 ClosePreviewDialog(); 1774 ClosePreviewDialog();
1772 return; 1775 return;
1773 } 1776 }
1774 1777
1775 // TODO(tbarzic): This function works for extension printers case too, but it 1778 // TODO(tbarzic): This function works for extension printers case too, but it
1776 // should be renamed to something more generic. 1779 // should be renamed to something more generic.
1777 web_ui()->CallJavascriptFunction("onPrivetPrintFailed", 1780 web_ui()->CallJavascriptFunctionUnsafe("onPrivetPrintFailed",
1778 base::StringValue(status)); 1781 base::StringValue(status));
1779 } 1782 }
1780 1783
1781 void PrintPreviewHandler::RegisterForGaiaCookieChanges() { 1784 void PrintPreviewHandler::RegisterForGaiaCookieChanges() {
1782 DCHECK(!gaia_cookie_manager_service_); 1785 DCHECK(!gaia_cookie_manager_service_);
1783 Profile* profile = Profile::FromWebUI(web_ui()); 1786 Profile* profile = Profile::FromWebUI(web_ui());
1784 if (switches::IsEnableAccountConsistency() && !profile->IsOffTheRecord()) { 1787 if (switches::IsEnableAccountConsistency() && !profile->IsOffTheRecord()) {
1785 gaia_cookie_manager_service_ = 1788 gaia_cookie_manager_service_ =
1786 GaiaCookieManagerServiceFactory::GetForProfile(profile); 1789 GaiaCookieManagerServiceFactory::GetForProfile(profile);
1787 if (gaia_cookie_manager_service_) 1790 if (gaia_cookie_manager_service_)
1788 gaia_cookie_manager_service_->AddObserver(this); 1791 gaia_cookie_manager_service_->AddObserver(this);
1789 } 1792 }
1790 } 1793 }
1791 1794
1792 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { 1795 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() {
1793 if (gaia_cookie_manager_service_) 1796 if (gaia_cookie_manager_service_)
1794 gaia_cookie_manager_service_->RemoveObserver(this); 1797 gaia_cookie_manager_service_->RemoveObserver(this);
1795 } 1798 }
1796 1799
1797 void PrintPreviewHandler::SetPdfSavedClosureForTesting( 1800 void PrintPreviewHandler::SetPdfSavedClosureForTesting(
1798 const base::Closure& closure) { 1801 const base::Closure& closure) {
1799 pdf_file_saved_closure_ = closure; 1802 pdf_file_saved_closure_ = closure;
1800 } 1803 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/predictors/predictors_handler.cc ('k') | chrome/browser/ui/webui/print_preview/print_preview_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698