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

Side by Side Diff: chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc

Issue 2886083002: MD Settings: Use FireWebUIListener() helper wherever possible. (Closed)
Patch Set: Fixed typo Created 3 years, 7 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/settings/chromeos/cups_printers_handler.h" 5 #include "chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 LOG(ERROR) << "Unrecoverable error. Reboot required."; 282 LOG(ERROR) << "Unrecoverable error. Reboot required.";
283 break; 283 break;
284 } 284 }
285 CallJavascriptFunction( 285 CallJavascriptFunction(
286 "cr.webUIListenerCallback", base::Value("on-add-cups-printer"), 286 "cr.webUIListenerCallback", base::Value("on-add-cups-printer"),
287 base::Value(result_code == chromeos::PrinterSetupResult::SUCCESS), 287 base::Value(result_code == chromeos::PrinterSetupResult::SUCCESS),
288 base::Value(printer_name)); 288 base::Value(printer_name));
289 } 289 }
290 290
291 void CupsPrintersHandler::OnAddPrinterError() { 291 void CupsPrintersHandler::OnAddPrinterError() {
292 CallJavascriptFunction("cr.webUIListenerCallback", 292 FireWebUIListener("on-add-cups-printer", base::Value(false), base::Value(""));
293 base::Value("on-add-cups-printer"), base::Value(false),
294 base::Value(""));
295 } 293 }
296 294
297 void CupsPrintersHandler::HandleGetCupsPrinterManufacturers( 295 void CupsPrintersHandler::HandleGetCupsPrinterManufacturers(
298 const base::ListValue* args) { 296 const base::ListValue* args) {
299 AllowJavascript(); 297 AllowJavascript();
300 std::string js_callback; 298 std::string js_callback;
301 CHECK_EQ(1U, args->GetSize()); 299 CHECK_EQ(1U, args->GetSize());
302 CHECK(args->GetString(0, &js_callback)); 300 CHECK(args->GetString(0, &js_callback));
303 ppd_provider_->ResolveManufacturers( 301 ppd_provider_->ResolveManufacturers(
304 base::Bind(&CupsPrintersHandler::ResolveManufacturersDone, 302 base::Bind(&CupsPrintersHandler::ResolveManufacturersDone,
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 } 400 }
403 401
404 void CupsPrintersHandler::OnPrintersFound( 402 void CupsPrintersHandler::OnPrintersFound(
405 const std::vector<Printer>& printers) { 403 const std::vector<Printer>& printers) {
406 std::unique_ptr<base::ListValue> printers_list = 404 std::unique_ptr<base::ListValue> printers_list =
407 base::MakeUnique<base::ListValue>(); 405 base::MakeUnique<base::ListValue>();
408 for (const auto& printer : printers) { 406 for (const auto& printer : printers) {
409 printers_list->Append(GetPrinterInfo(printer)); 407 printers_list->Append(GetPrinterInfo(printer));
410 } 408 }
411 409
412 CallJavascriptFunction("cr.webUIListenerCallback", 410 FireWebUIListener("on-printer-discovered", *printers_list);
413 base::Value("on-printer-discovered"), *printers_list);
414 } 411 }
415 412
416 void CupsPrintersHandler::OnDiscoveryInitialScanDone() { 413 void CupsPrintersHandler::OnDiscoveryInitialScanDone() {
417 CallJavascriptFunction("cr.webUIListenerCallback", 414 FireWebUIListener("on-printer-discovery-done");
418 base::Value("on-printer-discovery-done"));
419 } 415 }
420 416
421 } // namespace settings 417 } // namespace settings
422 } // namespace chromeos 418 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698