OLD | NEW |
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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
17 #include "components/proxy_config/proxy_config_dictionary.h" | 17 #include "components/proxy_config/proxy_config_dictionary.h" |
| 18 #include "components/proxy_config/proxy_config_pref_names.h" |
18 #include "ui/base/ui_base_switches.h" | 19 #include "ui/base/ui_base_switches.h" |
19 | 20 |
20 #if defined(OS_CHROMEOS) | 21 #if defined(OS_CHROMEOS) |
21 #include "chromeos/chromeos_switches.h" | 22 #include "chromeos/chromeos_switches.h" |
22 #endif | 23 #endif |
23 | 24 |
24 const CommandLinePrefStore::StringSwitchToPreferenceMapEntry | 25 const CommandLinePrefStore::StringSwitchToPreferenceMapEntry |
25 CommandLinePrefStore::string_switch_map_[] = { | 26 CommandLinePrefStore::string_switch_map_[] = { |
26 { switches::kLang, prefs::kApplicationLocale }, | 27 { switches::kLang, prefs::kApplicationLocale }, |
27 { data_reduction_proxy::switches::kDataReductionProxy, | 28 { data_reduction_proxy::switches::kDataReductionProxy, |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 SetValue(boolean_switch_map_[i].preference_path, | 142 SetValue(boolean_switch_map_[i].preference_path, |
142 make_scoped_ptr(new base::FundamentalValue( | 143 make_scoped_ptr(new base::FundamentalValue( |
143 boolean_switch_map_[i].set_value)), | 144 boolean_switch_map_[i].set_value)), |
144 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 145 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
145 } | 146 } |
146 } | 147 } |
147 } | 148 } |
148 | 149 |
149 void CommandLinePrefStore::ApplyProxyMode() { | 150 void CommandLinePrefStore::ApplyProxyMode() { |
150 if (command_line_->HasSwitch(switches::kNoProxyServer)) { | 151 if (command_line_->HasSwitch(switches::kNoProxyServer)) { |
151 SetValue(prefs::kProxy, | 152 SetValue(ProxyPrefs::prefs::kProxy, |
152 make_scoped_ptr(ProxyConfigDictionary::CreateDirect()), | 153 make_scoped_ptr(ProxyConfigDictionary::CreateDirect()), |
153 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 154 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
154 } else if (command_line_->HasSwitch(switches::kProxyPacUrl)) { | 155 } else if (command_line_->HasSwitch(switches::kProxyPacUrl)) { |
155 std::string pac_script_url = | 156 std::string pac_script_url = |
156 command_line_->GetSwitchValueASCII(switches::kProxyPacUrl); | 157 command_line_->GetSwitchValueASCII(switches::kProxyPacUrl); |
157 SetValue(prefs::kProxy, | 158 SetValue(ProxyPrefs::prefs::kProxy, |
158 make_scoped_ptr( | 159 make_scoped_ptr( |
159 ProxyConfigDictionary::CreatePacScript(pac_script_url, false)), | 160 ProxyConfigDictionary::CreatePacScript(pac_script_url, false)), |
160 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 161 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
161 } else if (command_line_->HasSwitch(switches::kProxyAutoDetect)) { | 162 } else if (command_line_->HasSwitch(switches::kProxyAutoDetect)) { |
162 SetValue(prefs::kProxy, | 163 SetValue(ProxyPrefs::prefs::kProxy, |
163 make_scoped_ptr(ProxyConfigDictionary::CreateAutoDetect()), | 164 make_scoped_ptr(ProxyConfigDictionary::CreateAutoDetect()), |
164 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 165 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
165 } else if (command_line_->HasSwitch(switches::kProxyServer)) { | 166 } else if (command_line_->HasSwitch(switches::kProxyServer)) { |
166 std::string proxy_server = | 167 std::string proxy_server = |
167 command_line_->GetSwitchValueASCII(switches::kProxyServer); | 168 command_line_->GetSwitchValueASCII(switches::kProxyServer); |
168 std::string bypass_list = | 169 std::string bypass_list = |
169 command_line_->GetSwitchValueASCII(switches::kProxyBypassList); | 170 command_line_->GetSwitchValueASCII(switches::kProxyBypassList); |
170 SetValue(prefs::kProxy, | 171 SetValue(ProxyPrefs::prefs::kProxy, |
171 make_scoped_ptr(ProxyConfigDictionary::CreateFixedServers( | 172 make_scoped_ptr(ProxyConfigDictionary::CreateFixedServers( |
172 proxy_server, bypass_list)), | 173 proxy_server, bypass_list)), |
173 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 174 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
174 } | 175 } |
175 } | 176 } |
176 | 177 |
177 void CommandLinePrefStore::ApplySSLSwitches() { | 178 void CommandLinePrefStore::ApplySSLSwitches() { |
178 if (command_line_->HasSwitch(switches::kCipherSuiteBlacklist)) { | 179 if (command_line_->HasSwitch(switches::kCipherSuiteBlacklist)) { |
179 scoped_ptr<base::ListValue> list_value(new base::ListValue()); | 180 scoped_ptr<base::ListValue> list_value(new base::ListValue()); |
180 list_value->AppendStrings(base::SplitString( | 181 list_value->AppendStrings(base::SplitString( |
181 command_line_->GetSwitchValueASCII(switches::kCipherSuiteBlacklist), | 182 command_line_->GetSwitchValueASCII(switches::kCipherSuiteBlacklist), |
182 ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)); | 183 ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)); |
183 SetValue(prefs::kCipherSuiteBlacklist, list_value.Pass(), | 184 SetValue(prefs::kCipherSuiteBlacklist, list_value.Pass(), |
184 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 185 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
185 } | 186 } |
186 } | 187 } |
187 | 188 |
188 void CommandLinePrefStore::ApplyBackgroundModeSwitches() { | 189 void CommandLinePrefStore::ApplyBackgroundModeSwitches() { |
189 if (command_line_->HasSwitch(switches::kDisableExtensions)) { | 190 if (command_line_->HasSwitch(switches::kDisableExtensions)) { |
190 SetValue(prefs::kBackgroundModeEnabled, | 191 SetValue(prefs::kBackgroundModeEnabled, |
191 make_scoped_ptr(new base::FundamentalValue(false)), | 192 make_scoped_ptr(new base::FundamentalValue(false)), |
192 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 193 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
193 } | 194 } |
194 } | 195 } |
OLD | NEW |