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

Unified Diff: chrome/browser/ui/webui/print_preview/print_preview_handler.cc

Issue 2935303003: Print Preview: Remove global onPrivetPrintFailed (Closed)
Patch Set: Fix annotations Created 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/print_preview/print_preview_handler.cc
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
index 16b30f20fc7d5228d2b432c3b1731fcef5c20de9..b4ceb816e49a79177a1e882ae57422e66f952db4 100644
--- a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
+++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
@@ -917,9 +917,7 @@ void PrintPreviewHandler::HandlePrint(const base::ListValue* args) {
!settings->GetInteger(printing::kSettingPageHeight, &height) ||
width <= 0 || height <= 0) {
NOTREACHED();
- base::Value http_code_value(-1);
- web_ui()->CallJavascriptFunctionUnsafe("onPrivetPrintFailed",
- http_code_value);
+ FireWebUIListener("print-failed", base::Value(-1));
return;
}
@@ -1608,9 +1606,7 @@ bool PrintPreviewHandler::PrivetUpdateClient(
if (!http_client) {
if (callback_id.empty()) {
// This was an attempt to print to a privet printer and has failed.
- base::Value http_code_value(-1);
- web_ui()->CallJavascriptFunctionUnsafe("onPrivetPrintFailed",
- http_code_value);
+ FireWebUIListener("print-failed", base::Value(-1));
} else { // Capabilities update failed
RejectJavascriptCallback(base::Value(callback_id), base::Value());
}
@@ -1652,9 +1648,7 @@ void PrintPreviewHandler::StartPrivetLocalPrint(const std::string& print_ticket,
base::string16 title;
if (!GetPreviewDataAndTitle(&data, &title)) {
- base::Value http_code_value(-1);
- web_ui()->CallJavascriptFunctionUnsafe("onPrivetPrintFailed",
- http_code_value);
+ FireWebUIListener("print-failed", base::Value(-1));
return;
}
@@ -1716,9 +1710,7 @@ void PrintPreviewHandler::PrintToPrivetPrinter(const std::string& device_name,
base::Bind(&PrintPreviewHandler::PrivetLocalPrintUpdateClient,
weak_factory_.GetWeakPtr(), ticket, capabilities,
page_size))) {
- base::Value http_code_value(-1);
- web_ui()->CallJavascriptFunctionUnsafe("onPrivetPrintFailed",
- http_code_value);
+ FireWebUIListener("print-failed", base::Value(-1));
}
}
@@ -1749,9 +1741,7 @@ void PrintPreviewHandler::OnPrivetPrintingDone(
void PrintPreviewHandler::OnPrivetPrintingError(
const cloud_print::PrivetLocalPrintOperation* print_operation,
int http_code) {
- base::Value http_code_value(http_code);
- web_ui()->CallJavascriptFunctionUnsafe("onPrivetPrintFailed",
- http_code_value);
+ FireWebUIListener("print-failed", base::Value(http_code));
}
void PrintPreviewHandler::FillPrinterDescription(
@@ -1821,11 +1811,7 @@ void PrintPreviewHandler::OnExtensionPrintResult(bool success,
ClosePreviewDialog();
return;
}
-
- // TODO(tbarzic): This function works for extension printers case too, but it
- // should be renamed to something more generic.
- web_ui()->CallJavascriptFunctionUnsafe("onPrivetPrintFailed",
- base::Value(status));
+ FireWebUIListener("print-failed", base::Value(status));
}
void PrintPreviewHandler::RegisterForGaiaCookieChanges() {
« no previous file with comments | « chrome/browser/resources/print_preview/print_preview.js ('k') | ui/webui/resources/html/webui_listener_tracker.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698