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

Side by Side Diff: chrome/installer/util/master_preferences.cc

Issue 1878313003: Convert //chrome/installer from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert decompress.cc in mini_installer. Created 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/installer/util/master_preferences.h" 5 #include "chrome/installer/util/master_preferences.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/environment.h" 9 #include "base/environment.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 list.push_back(url_entry); 52 list.push_back(url_entry);
53 } 53 }
54 return list; 54 return list;
55 } 55 }
56 56
57 base::DictionaryValue* ParseDistributionPreferences( 57 base::DictionaryValue* ParseDistributionPreferences(
58 const std::string& json_data) { 58 const std::string& json_data) {
59 JSONStringValueDeserializer json(json_data); 59 JSONStringValueDeserializer json(json_data);
60 std::string error; 60 std::string error;
61 scoped_ptr<base::Value> root(json.Deserialize(NULL, &error)); 61 std::unique_ptr<base::Value> root(json.Deserialize(NULL, &error));
62 if (!root.get()) { 62 if (!root.get()) {
63 LOG(WARNING) << "Failed to parse master prefs file: " << error; 63 LOG(WARNING) << "Failed to parse master prefs file: " << error;
64 return NULL; 64 return NULL;
65 } 65 }
66 if (!root->IsType(base::Value::TYPE_DICTIONARY)) { 66 if (!root->IsType(base::Value::TYPE_DICTIONARY)) {
67 LOG(WARNING) << "Failed to parse master prefs file: " 67 LOG(WARNING) << "Failed to parse master prefs file: "
68 << "Root item must be a dictionary."; 68 << "Root item must be a dictionary.";
69 return NULL; 69 return NULL;
70 } 70 }
71 return static_cast<base::DictionaryValue*>(root.release()); 71 return static_cast<base::DictionaryValue*>(root.release());
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 std::wstring str_value(cmd_line.GetSwitchValueNative( 162 std::wstring str_value(cmd_line.GetSwitchValueNative(
163 installer::switches::kLogFile)); 163 installer::switches::kLogFile));
164 if (!str_value.empty()) { 164 if (!str_value.empty()) {
165 name.assign(installer::master_preferences::kDistroDict); 165 name.assign(installer::master_preferences::kDistroDict);
166 name.append(".").append(installer::master_preferences::kLogFile); 166 name.append(".").append(installer::master_preferences::kLogFile);
167 master_dictionary_->SetString(name, str_value); 167 master_dictionary_->SetString(name, str_value);
168 } 168 }
169 169
170 // Handle the special case of --system-level being implied by the presence of 170 // Handle the special case of --system-level being implied by the presence of
171 // the kGoogleUpdateIsMachineEnvVar environment variable. 171 // the kGoogleUpdateIsMachineEnvVar environment variable.
172 scoped_ptr<base::Environment> env(base::Environment::Create()); 172 std::unique_ptr<base::Environment> env(base::Environment::Create());
173 if (env != NULL) { 173 if (env != NULL) {
174 std::string is_machine_var; 174 std::string is_machine_var;
175 env->GetVar(env_vars::kGoogleUpdateIsMachineEnvVar, &is_machine_var); 175 env->GetVar(env_vars::kGoogleUpdateIsMachineEnvVar, &is_machine_var);
176 if (!is_machine_var.empty() && is_machine_var[0] == '1') { 176 if (!is_machine_var.empty() && is_machine_var[0] == '1') {
177 VLOG(1) << "Taking system-level from environment."; 177 VLOG(1) << "Taking system-level from environment.";
178 name.assign(installer::master_preferences::kDistroDict); 178 name.assign(installer::master_preferences::kDistroDict);
179 name.append(".").append(installer::master_preferences::kSystemLevel); 179 name.append(".").append(installer::master_preferences::kSystemLevel);
180 master_dictionary_->SetBoolean(name, true); 180 master_dictionary_->SetBoolean(name, true);
181 } 181 }
182 } 182 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 return ExtractPrefString(variations::prefs::kVariationsSeed); 295 return ExtractPrefString(variations::prefs::kVariationsSeed);
296 } 296 }
297 297
298 std::string MasterPreferences::GetVariationsSeedSignature() const { 298 std::string MasterPreferences::GetVariationsSeedSignature() const {
299 return ExtractPrefString(variations::prefs::kVariationsSeedSignature); 299 return ExtractPrefString(variations::prefs::kVariationsSeedSignature);
300 } 300 }
301 301
302 std::string MasterPreferences::ExtractPrefString( 302 std::string MasterPreferences::ExtractPrefString(
303 const std::string& name) const { 303 const std::string& name) const {
304 std::string result; 304 std::string result;
305 scoped_ptr<base::Value> pref_value; 305 std::unique_ptr<base::Value> pref_value;
306 if (master_dictionary_->Remove(name, &pref_value)) { 306 if (master_dictionary_->Remove(name, &pref_value)) {
307 if (!pref_value->GetAsString(&result)) 307 if (!pref_value->GetAsString(&result))
308 NOTREACHED(); 308 NOTREACHED();
309 } 309 }
310 return result; 310 return result;
311 } 311 }
312 312
313 // static 313 // static
314 const MasterPreferences& MasterPreferences::ForCurrentProcess() { 314 const MasterPreferences& MasterPreferences::ForCurrentProcess() {
315 return g_master_preferences.Get(); 315 return g_master_preferences.Get();
316 } 316 }
317 317
318 } // namespace installer 318 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/installer/util/master_preferences.h ('k') | chrome/installer/util/master_preferences_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698