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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 const base::ListValue* args) { | 131 const base::ListValue* args) { |
132 AllowJavascript(); | 132 AllowJavascript(); |
133 | 133 |
134 CHECK_EQ(1U, args->GetSize()); | 134 CHECK_EQ(1U, args->GetSize()); |
135 std::string callback_id; | 135 std::string callback_id; |
136 CHECK(args->GetString(0, &callback_id)); | 136 CHECK(args->GetString(0, &callback_id)); |
137 | 137 |
138 std::vector<std::unique_ptr<Printer>> printers = | 138 std::vector<std::unique_ptr<Printer>> printers = |
139 PrintersManagerFactory::GetForBrowserContext(profile_)->GetPrinters(); | 139 PrintersManagerFactory::GetForBrowserContext(profile_)->GetPrinters(); |
140 | 140 |
141 auto printers_list = base::MakeUnique<base::ListValue>(); | 141 base::ListValue* printers_list = new base::ListValue; |
142 for (const std::unique_ptr<Printer>& printer : printers) { | 142 for (const std::unique_ptr<Printer>& printer : printers) { |
143 std::unique_ptr<base::DictionaryValue> printer_info = | 143 std::unique_ptr<base::DictionaryValue> printer_info = |
144 GetPrinterInfo(*printer.get()); | 144 GetPrinterInfo(*printer.get()); |
145 printers_list->Append(std::move(printer_info)); | 145 printers_list->Append(std::move(printer_info)); |
146 } | 146 } |
147 | 147 |
148 auto response = base::MakeUnique<base::DictionaryValue>(); | 148 std::unique_ptr<base::DictionaryValue> response = |
149 response->Set("printerList", std::move(printers_list)); | 149 base::MakeUnique<base::DictionaryValue>(); |
| 150 response->Set("printerList", printers_list); |
150 ResolveJavascriptCallback(base::Value(callback_id), *response); | 151 ResolveJavascriptCallback(base::Value(callback_id), *response); |
151 } | 152 } |
152 | 153 |
153 void CupsPrintersHandler::HandleUpdateCupsPrinter(const base::ListValue* args) { | 154 void CupsPrintersHandler::HandleUpdateCupsPrinter(const base::ListValue* args) { |
154 std::string printer_id; | 155 std::string printer_id; |
155 std::string printer_name; | 156 std::string printer_name; |
156 CHECK(args->GetString(0, &printer_id)); | 157 CHECK(args->GetString(0, &printer_id)); |
157 CHECK(args->GetString(1, &printer_name)); | 158 CHECK(args->GetString(1, &printer_name)); |
158 | 159 |
159 std::unique_ptr<Printer> printer = base::MakeUnique<Printer>(printer_id); | 160 std::unique_ptr<Printer> printer = base::MakeUnique<Printer>(printer_id); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 base::Value("on-printer-discovered"), *printers_list); | 402 base::Value("on-printer-discovered"), *printers_list); |
402 } | 403 } |
403 | 404 |
404 void CupsPrintersHandler::OnDiscoveryInitialScanDone() { | 405 void CupsPrintersHandler::OnDiscoveryInitialScanDone() { |
405 CallJavascriptFunction("cr.webUIListenerCallback", | 406 CallJavascriptFunction("cr.webUIListenerCallback", |
406 base::Value("on-printer-discovery-done")); | 407 base::Value("on-printer-discovery-done")); |
407 } | 408 } |
408 | 409 |
409 } // namespace settings | 410 } // namespace settings |
410 } // namespace chromeos | 411 } // namespace chromeos |
OLD | NEW |