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

Side by Side Diff: chrome/browser/chromeos/printing/printers_manager.cc

Issue 2816513002: Revert of Change base::Value::ListStorage to std::vector<base::Value> (Closed)
Patch Set: 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/chromeos/printing/printers_manager.h" 5 #include "chrome/browser/chromeos/printing/printers_manager.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 // |recommended_printers_|. 173 // |recommended_printers_|.
174 void PrintersManager::UpdateRecommendedPrinters() { 174 void PrintersManager::UpdateRecommendedPrinters() {
175 const PrefService* prefs = profile_->GetPrefs(); 175 const PrefService* prefs = profile_->GetPrefs();
176 176
177 const base::ListValue* values = 177 const base::ListValue* values =
178 prefs->GetList(prefs::kRecommendedNativePrinters); 178 prefs->GetList(prefs::kRecommendedNativePrinters);
179 179
180 recommended_printer_ids_.clear(); 180 recommended_printer_ids_.clear();
181 for (const auto& value : *values) { 181 for (const auto& value : *values) {
182 std::string printer_json; 182 std::string printer_json;
183 if (!value.GetAsString(&printer_json)) { 183 if (!value->GetAsString(&printer_json)) {
184 NOTREACHED(); 184 NOTREACHED();
185 continue; 185 continue;
186 } 186 }
187 187
188 std::unique_ptr<base::DictionaryValue> printer_dictionary = 188 std::unique_ptr<base::DictionaryValue> printer_dictionary =
189 base::DictionaryValue::From(base::JSONReader::Read( 189 base::DictionaryValue::From(base::JSONReader::Read(
190 printer_json, base::JSON_ALLOW_TRAILING_COMMAS)); 190 printer_json, base::JSON_ALLOW_TRAILING_COMMAS));
191 191
192 if (!printer_dictionary) { 192 if (!printer_dictionary) {
193 LOG(WARNING) << "Ignoring invalid printer. Invalid JSON object: " 193 LOG(WARNING) << "Ignoring invalid printer. Invalid JSON object: "
194 << printer_json; 194 << printer_json;
195 continue; 195 continue;
196 } 196 }
197 197
198 // Policy printers don't have id's but the ids only need to be locally 198 // Policy printers don't have id's but the ids only need to be locally
199 // unique so we'll hash the record. This will not collide with the UUIDs 199 // unique so we'll hash the record. This will not collide with the UUIDs
200 // generated for user entries. 200 // generated for user entries.
201 std::string id = base::MD5String(printer_json); 201 std::string id = base::MD5String(printer_json);
202 printer_dictionary->SetString(printing::kPrinterId, id); 202 printer_dictionary->SetString(printing::kPrinterId, id);
203 203
204 recommended_printer_ids_.push_back(id); 204 recommended_printer_ids_.push_back(id);
205 recommended_printers_[id] = std::move(printer_dictionary); 205 recommended_printers_[id] = std::move(printer_dictionary);
206 } 206 }
207 } 207 }
208 208
209 } // namespace chromeos 209 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698