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

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

Issue 2975013002: Make chromeos CUPS printing code namespaces consistent. (Closed)
Patch Set: Rebase Created 3 years, 5 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 124
125 return queue; 125 return queue;
126 } 126 }
127 127
128 } // namespace 128 } // namespace
129 129
130 CupsPrintersHandler::CupsPrintersHandler(content::WebUI* webui) 130 CupsPrintersHandler::CupsPrintersHandler(content::WebUI* webui)
131 : printer_detector_(nullptr), 131 : printer_detector_(nullptr),
132 profile_(Profile::FromWebUI(webui)), 132 profile_(Profile::FromWebUI(webui)),
133 weak_factory_(this) { 133 weak_factory_(this) {
134 ppd_provider_ = printing::CreateProvider(profile_); 134 ppd_provider_ = CreatePpdProvider(profile_);
135 printer_configurer_ = PrinterConfigurer::Create(profile_); 135 printer_configurer_ = PrinterConfigurer::Create(profile_);
136 } 136 }
137 137
138 CupsPrintersHandler::~CupsPrintersHandler() {} 138 CupsPrintersHandler::~CupsPrintersHandler() {}
139 139
140 void CupsPrintersHandler::RegisterMessages() { 140 void CupsPrintersHandler::RegisterMessages() {
141 web_ui()->RegisterMessageCallback( 141 web_ui()->RegisterMessageCallback(
142 "getCupsPrintersList", 142 "getCupsPrintersList",
143 base::Bind(&CupsPrintersHandler::HandleGetCupsPrintersList, 143 base::Bind(&CupsPrintersHandler::HandleGetCupsPrintersList,
144 base::Unretained(this))); 144 base::Unretained(this)));
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents()) 509 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents())
510 ->window() 510 ->window()
511 ->GetNativeWindow(); 511 ->GetNativeWindow();
512 select_file_dialog_->SelectFile( 512 select_file_dialog_->SelectFile(
513 ui::SelectFileDialog::SELECT_OPEN_FILE, base::string16(), downloads_path, 513 ui::SelectFileDialog::SELECT_OPEN_FILE, base::string16(), downloads_path,
514 nullptr, 0, FILE_PATH_LITERAL(""), owning_window, nullptr); 514 nullptr, 0, FILE_PATH_LITERAL(""), owning_window, nullptr);
515 } 515 }
516 516
517 void CupsPrintersHandler::ResolveManufacturersDone( 517 void CupsPrintersHandler::ResolveManufacturersDone(
518 const std::string& js_callback, 518 const std::string& js_callback,
519 printing::PpdProvider::CallbackResultCode result_code, 519 PpdProvider::CallbackResultCode result_code,
520 const std::vector<std::string>& manufacturers) { 520 const std::vector<std::string>& manufacturers) {
521 auto manufacturers_value = base::MakeUnique<base::ListValue>(); 521 auto manufacturers_value = base::MakeUnique<base::ListValue>();
522 if (result_code == printing::PpdProvider::SUCCESS) { 522 if (result_code == PpdProvider::SUCCESS) {
523 manufacturers_value->AppendStrings(manufacturers); 523 manufacturers_value->AppendStrings(manufacturers);
524 } 524 }
525 base::DictionaryValue response; 525 base::DictionaryValue response;
526 response.SetBoolean("success", result_code == printing::PpdProvider::SUCCESS); 526 response.SetBoolean("success", result_code == PpdProvider::SUCCESS);
527 response.Set("manufacturers", std::move(manufacturers_value)); 527 response.Set("manufacturers", std::move(manufacturers_value));
528 ResolveJavascriptCallback(base::Value(js_callback), response); 528 ResolveJavascriptCallback(base::Value(js_callback), response);
529 } 529 }
530 530
531 void CupsPrintersHandler::ResolvePrintersDone( 531 void CupsPrintersHandler::ResolvePrintersDone(
532 const std::string& js_callback, 532 const std::string& js_callback,
533 printing::PpdProvider::CallbackResultCode result_code, 533 PpdProvider::CallbackResultCode result_code,
534 const std::vector<std::string>& printers) { 534 const std::vector<std::string>& printers) {
535 auto printers_value = base::MakeUnique<base::ListValue>(); 535 auto printers_value = base::MakeUnique<base::ListValue>();
536 if (result_code == printing::PpdProvider::SUCCESS) { 536 if (result_code == PpdProvider::SUCCESS) {
537 printers_value->AppendStrings(printers); 537 printers_value->AppendStrings(printers);
538 } 538 }
539 base::DictionaryValue response; 539 base::DictionaryValue response;
540 response.SetBoolean("success", result_code == printing::PpdProvider::SUCCESS); 540 response.SetBoolean("success", result_code == PpdProvider::SUCCESS);
541 response.Set("models", std::move(printers_value)); 541 response.Set("models", std::move(printers_value));
542 ResolveJavascriptCallback(base::Value(js_callback), response); 542 ResolveJavascriptCallback(base::Value(js_callback), response);
543 } 543 }
544 544
545 void CupsPrintersHandler::FileSelected(const base::FilePath& path, 545 void CupsPrintersHandler::FileSelected(const base::FilePath& path,
546 int index, 546 int index,
547 void* params) { 547 void* params) {
548 DCHECK(!webui_callback_id_.empty()); 548 DCHECK(!webui_callback_id_.empty());
549 ResolveJavascriptCallback(base::Value(webui_callback_id_), 549 ResolveJavascriptCallback(base::Value(webui_callback_id_),
550 base::Value(path.value())); 550 base::Value(path.value()));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 } 589 }
590 590
591 void CupsPrintersHandler::OnPrinterScanComplete() { 591 void CupsPrintersHandler::OnPrinterScanComplete() {
592 UMA_HISTOGRAM_COUNTS_100("Printing.CUPS.PrintersDiscovered", 592 UMA_HISTOGRAM_COUNTS_100("Printing.CUPS.PrintersDiscovered",
593 printer_detector_->GetPrinters().size()); 593 printer_detector_->GetPrinters().size());
594 FireWebUIListener("on-printer-discovery-done"); 594 FireWebUIListener("on-printer-discovery-done");
595 } 595 }
596 596
597 } // namespace settings 597 } // namespace settings
598 } // namespace chromeos 598 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h ('k') | chromeos/printing/ppd_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698