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

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

Issue 2738323003: Implement basic USB setup in the cups printer detector. Factor out (Closed)
Patch Set: Fix ppd provider lifetime. It was being inappropriately deleted which meant it caused USB resoluti… Created 3 years, 9 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
« no previous file with comments | « chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 235
236 // Copy the printer for the configurer. Ownership needs to be transfered to 236 // Copy the printer for the configurer. Ownership needs to be transfered to
237 // the receiver of the callback. 237 // the receiver of the callback.
238 const Printer printer_copy = *printer; 238 const Printer printer_copy = *printer;
239 printer_configurer_->SetUpPrinter( 239 printer_configurer_->SetUpPrinter(
240 printer_copy, 240 printer_copy,
241 base::Bind(&CupsPrintersHandler::OnAddedPrinter, 241 base::Bind(&CupsPrintersHandler::OnAddedPrinter,
242 weak_factory_.GetWeakPtr(), base::Passed(&printer))); 242 weak_factory_.GetWeakPtr(), base::Passed(&printer)));
243 } 243 }
244 244
245 void CupsPrintersHandler::OnAddedPrinter(std::unique_ptr<Printer> printer, 245 void CupsPrintersHandler::OnAddedPrinter(
246 chromeos::SetupResult result_code) { 246 std::unique_ptr<Printer> printer,
247 chromeos::PrinterSetupResult result_code) {
247 std::string printer_name = printer->display_name(); 248 std::string printer_name = printer->display_name();
248 bool success = (result_code == chromeos::SetupResult::SUCCESS); 249 bool success = (result_code == chromeos::PrinterSetupResult::SUCCESS);
249 if (success) { 250 if (success) {
250 PrintersManagerFactory::GetForBrowserContext(profile_)->RegisterPrinter( 251 PrintersManagerFactory::GetForBrowserContext(profile_)->RegisterPrinter(
251 std::move(printer)); 252 std::move(printer));
252 } 253 }
253 CallJavascriptFunction("cr.webUIListenerCallback", 254 CallJavascriptFunction("cr.webUIListenerCallback",
254 base::Value("on-add-cups-printer"), 255 base::Value("on-add-cups-printer"),
255 base::Value(success), base::Value(printer_name)); 256 base::Value(success), base::Value(printer_name));
256 } 257 }
257 258
258 void CupsPrintersHandler::OnAddPrinterError() { 259 void CupsPrintersHandler::OnAddPrinterError() {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 base::Value("on-printer-discovered"), *printers_list); 390 base::Value("on-printer-discovered"), *printers_list);
390 } 391 }
391 392
392 void CupsPrintersHandler::OnDiscoveryDone() { 393 void CupsPrintersHandler::OnDiscoveryDone() {
393 CallJavascriptFunction("cr.webUIListenerCallback", 394 CallJavascriptFunction("cr.webUIListenerCallback",
394 base::Value("on-printer-discovery-done")); 395 base::Value("on-printer-discovery-done"));
395 } 396 }
396 397
397 } // namespace settings 398 } // namespace settings
398 } // namespace chromeos 399 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698