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

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

Issue 2812953002: Stop passing raw pointers to base::Value API in c/b/ui (Closed)
Patch Set: No ListValue::SetDouble Created 3 years, 8 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 base::ListValue* printers_list = new base::ListValue; 141 auto printers_list = base::MakeUnique<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 std::unique_ptr<base::DictionaryValue> response = 148 auto response = base::MakeUnique<base::DictionaryValue>();
149 base::MakeUnique<base::DictionaryValue>(); 149 response->Set("printerList", std::move(printers_list));
150 response->Set("printerList", printers_list);
151 ResolveJavascriptCallback(base::Value(callback_id), *response); 150 ResolveJavascriptCallback(base::Value(callback_id), *response);
152 } 151 }
153 152
154 void CupsPrintersHandler::HandleUpdateCupsPrinter(const base::ListValue* args) { 153 void CupsPrintersHandler::HandleUpdateCupsPrinter(const base::ListValue* args) {
155 std::string printer_id; 154 std::string printer_id;
156 std::string printer_name; 155 std::string printer_name;
157 CHECK(args->GetString(0, &printer_id)); 156 CHECK(args->GetString(0, &printer_id));
158 CHECK(args->GetString(1, &printer_name)); 157 CHECK(args->GetString(1, &printer_name));
159 158
160 std::unique_ptr<Printer> printer = base::MakeUnique<Printer>(printer_id); 159 std::unique_ptr<Printer> printer = base::MakeUnique<Printer>(printer_id);
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 base::Value("on-printer-discovered"), *printers_list); 401 base::Value("on-printer-discovered"), *printers_list);
403 } 402 }
404 403
405 void CupsPrintersHandler::OnDiscoveryInitialScanDone() { 404 void CupsPrintersHandler::OnDiscoveryInitialScanDone() {
406 CallJavascriptFunction("cr.webUIListenerCallback", 405 CallJavascriptFunction("cr.webUIListenerCallback",
407 base::Value("on-printer-discovery-done")); 406 base::Value("on-printer-discovery-done"));
408 } 407 }
409 408
410 } // namespace settings 409 } // namespace settings
411 } // namespace chromeos 410 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698