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

Side by Side Diff: chrome/browser/prefs/command_line_pref_store.cc

Issue 2334613003: Re-write many calls to WrapUnique() with MakeUnique() (Closed)
Patch Set: Changes from review by sky Created 4 years, 3 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/browser/prefs/command_line_pref_store.h" 5 #include "chrome/browser/prefs/command_line_pref_store.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 return false; 108 return false;
109 } 109 }
110 return true; 110 return true;
111 } 111 }
112 112
113 void CommandLinePrefStore::ApplySimpleSwitches() { 113 void CommandLinePrefStore::ApplySimpleSwitches() {
114 // Look for each switch we know about and set its preference accordingly. 114 // Look for each switch we know about and set its preference accordingly.
115 for (size_t i = 0; i < arraysize(string_switch_map_); ++i) { 115 for (size_t i = 0; i < arraysize(string_switch_map_); ++i) {
116 if (command_line_->HasSwitch(string_switch_map_[i].switch_name)) { 116 if (command_line_->HasSwitch(string_switch_map_[i].switch_name)) {
117 SetValue(string_switch_map_[i].preference_path, 117 SetValue(string_switch_map_[i].preference_path,
118 base::WrapUnique( 118 base::MakeUnique<base::StringValue>(
119 new base::StringValue(command_line_->GetSwitchValueASCII( 119 command_line_->GetSwitchValueASCII(
120 string_switch_map_[i].switch_name))), 120 string_switch_map_[i].switch_name)),
121 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); 121 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
122 } 122 }
123 } 123 }
124 124
125 for (size_t i = 0; i < arraysize(path_switch_map_); ++i) { 125 for (size_t i = 0; i < arraysize(path_switch_map_); ++i) {
126 if (command_line_->HasSwitch(path_switch_map_[i].switch_name)) { 126 if (command_line_->HasSwitch(path_switch_map_[i].switch_name)) {
127 SetValue( 127 SetValue(
128 path_switch_map_[i].preference_path, 128 path_switch_map_[i].preference_path,
129 base::WrapUnique(new base::StringValue( 129 base::MakeUnique<base::StringValue>(
130 command_line_->GetSwitchValuePath(path_switch_map_[i].switch_name) 130 command_line_->GetSwitchValuePath(path_switch_map_[i].switch_name)
131 .value())), 131 .value()),
132 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); 132 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
133 } 133 }
134 } 134 }
135 135
136 for (size_t i = 0; i < arraysize(integer_switch_map_); ++i) { 136 for (size_t i = 0; i < arraysize(integer_switch_map_); ++i) {
137 if (command_line_->HasSwitch(integer_switch_map_[i].switch_name)) { 137 if (command_line_->HasSwitch(integer_switch_map_[i].switch_name)) {
138 std::string str_value = command_line_->GetSwitchValueASCII( 138 std::string str_value = command_line_->GetSwitchValueASCII(
139 integer_switch_map_[i].switch_name); 139 integer_switch_map_[i].switch_name);
140 int int_value = 0; 140 int int_value = 0;
141 if (!base::StringToInt(str_value, &int_value)) { 141 if (!base::StringToInt(str_value, &int_value)) {
142 LOG(ERROR) << "The value " << str_value << " of " 142 LOG(ERROR) << "The value " << str_value << " of "
143 << integer_switch_map_[i].switch_name 143 << integer_switch_map_[i].switch_name
144 << " can not be converted to integer, ignoring!"; 144 << " can not be converted to integer, ignoring!";
145 continue; 145 continue;
146 } 146 }
147 SetValue(integer_switch_map_[i].preference_path, 147 SetValue(integer_switch_map_[i].preference_path,
148 base::WrapUnique(new base::FundamentalValue(int_value)), 148 base::MakeUnique<base::FundamentalValue>(int_value),
149 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); 149 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
150 } 150 }
151 } 151 }
152 152
153 for (size_t i = 0; i < arraysize(boolean_switch_map_); ++i) { 153 for (size_t i = 0; i < arraysize(boolean_switch_map_); ++i) {
154 if (command_line_->HasSwitch(boolean_switch_map_[i].switch_name)) { 154 if (command_line_->HasSwitch(boolean_switch_map_[i].switch_name)) {
155 SetValue(boolean_switch_map_[i].preference_path, 155 SetValue(boolean_switch_map_[i].preference_path,
156 base::WrapUnique(new base::FundamentalValue( 156 base::MakeUnique<base::FundamentalValue>(
157 boolean_switch_map_[i].set_value)), 157 boolean_switch_map_[i].set_value),
158 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); 158 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
159 } 159 }
160 } 160 }
161 } 161 }
162 162
163 void CommandLinePrefStore::ApplyProxyMode() { 163 void CommandLinePrefStore::ApplyProxyMode() {
164 if (command_line_->HasSwitch(switches::kNoProxyServer)) { 164 if (command_line_->HasSwitch(switches::kNoProxyServer)) {
165 SetValue(proxy_config::prefs::kProxy, 165 SetValue(proxy_config::prefs::kProxy,
166 base::WrapUnique(ProxyConfigDictionary::CreateDirect()), 166 base::WrapUnique(ProxyConfigDictionary::CreateDirect()),
167 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); 167 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
(...skipping 27 matching lines...) Expand all
195 command_line_->GetSwitchValueASCII(switches::kCipherSuiteBlacklist), 195 command_line_->GetSwitchValueASCII(switches::kCipherSuiteBlacklist),
196 ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)); 196 ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL));
197 SetValue(ssl_config::prefs::kCipherSuiteBlacklist, std::move(list_value), 197 SetValue(ssl_config::prefs::kCipherSuiteBlacklist, std::move(list_value),
198 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); 198 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
199 } 199 }
200 } 200 }
201 201
202 void CommandLinePrefStore::ApplyBackgroundModeSwitches() { 202 void CommandLinePrefStore::ApplyBackgroundModeSwitches() {
203 if (command_line_->HasSwitch(switches::kDisableExtensions)) { 203 if (command_line_->HasSwitch(switches::kDisableExtensions)) {
204 SetValue(prefs::kBackgroundModeEnabled, 204 SetValue(prefs::kBackgroundModeEnabled,
205 base::WrapUnique(new base::FundamentalValue(false)), 205 base::MakeUnique<base::FundamentalValue>(false),
206 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); 206 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
207 } 207 }
208 } 208 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/chrome_pref_service_factory.cc ('k') | chrome/browser/prefs/profile_pref_store_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698