OLD | NEW |
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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 } | 254 } |
255 | 255 |
256 void CupsPrintersHandler::OnAddedPrinter(std::unique_ptr<Printer> printer, | 256 void CupsPrintersHandler::OnAddedPrinter(std::unique_ptr<Printer> printer, |
257 int32_t result_code) { | 257 int32_t result_code) { |
258 std::string printer_name = printer->display_name(); | 258 std::string printer_name = printer->display_name(); |
259 bool success = (result_code == 0); | 259 bool success = (result_code == 0); |
260 if (success) { | 260 if (success) { |
261 PrintersManagerFactory::GetForBrowserContext(profile_)->RegisterPrinter( | 261 PrintersManagerFactory::GetForBrowserContext(profile_)->RegisterPrinter( |
262 std::move(printer)); | 262 std::move(printer)); |
263 } | 263 } |
264 CallJavascriptFunction( | 264 CallJavascriptFunction("cr.webUIListenerCallback", |
265 "cr.webUIListenerCallback", base::StringValue("on-add-cups-printer"), | 265 base::StringValue("on-add-cups-printer"), |
266 base::FundamentalValue(success), base::StringValue(printer_name)); | 266 base::Value(success), base::StringValue(printer_name)); |
267 } | 267 } |
268 | 268 |
269 void CupsPrintersHandler::OnAddPrinterError() { | 269 void CupsPrintersHandler::OnAddPrinterError() { |
270 CallJavascriptFunction("cr.webUIListenerCallback", | 270 CallJavascriptFunction("cr.webUIListenerCallback", |
271 base::StringValue("on-add-cups-printer"), | 271 base::StringValue("on-add-cups-printer"), |
272 base::FundamentalValue(false), base::StringValue("")); | 272 base::Value(false), base::StringValue("")); |
273 } | 273 } |
274 | 274 |
275 void CupsPrintersHandler::HandleGetCupsPrinterManufacturers( | 275 void CupsPrintersHandler::HandleGetCupsPrinterManufacturers( |
276 const base::ListValue* args) { | 276 const base::ListValue* args) { |
277 AllowJavascript(); | 277 AllowJavascript(); |
278 std::string js_callback; | 278 std::string js_callback; |
279 CHECK_EQ(1U, args->GetSize()); | 279 CHECK_EQ(1U, args->GetSize()); |
280 CHECK(args->GetString(0, &js_callback)); | 280 CHECK(args->GetString(0, &js_callback)); |
281 ppd_provider_->ResolveManufacturers( | 281 ppd_provider_->ResolveManufacturers( |
282 base::Bind(&CupsPrintersHandler::ResolveManufacturersDone, | 282 base::Bind(&CupsPrintersHandler::ResolveManufacturersDone, |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 client->CupsAddManuallyConfiguredPrinter( | 426 client->CupsAddManuallyConfiguredPrinter( |
427 printer_id, printer_uri, ppd_contents, | 427 printer_id, printer_uri, ppd_contents, |
428 base::Bind(&CupsPrintersHandler::OnAddedPrinter, | 428 base::Bind(&CupsPrintersHandler::OnAddedPrinter, |
429 weak_factory_.GetWeakPtr(), base::Passed(&printer)), | 429 weak_factory_.GetWeakPtr(), base::Passed(&printer)), |
430 base::Bind(&CupsPrintersHandler::OnAddPrinterError, | 430 base::Bind(&CupsPrintersHandler::OnAddPrinterError, |
431 weak_factory_.GetWeakPtr())); | 431 weak_factory_.GetWeakPtr())); |
432 } | 432 } |
433 | 433 |
434 } // namespace settings | 434 } // namespace settings |
435 } // namespace chromeos | 435 } // namespace chromeos |
OLD | NEW |