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/logging.h" | 11 #include "base/logging.h" |
11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
13 #include "base/values.h" | 14 #include "base/values.h" |
14 #include "chrome/browser/prefs/proxy_config_dictionary.h" | 15 #include "chrome/browser/prefs/proxy_config_dictionary.h" |
15 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
16 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
17 #include "ui/base/ui_base_switches.h" | 18 #include "ui/base/ui_base_switches.h" |
18 | 19 |
19 #if defined(OS_CHROMEOS) | 20 #if defined(OS_CHROMEOS) |
20 #include "chromeos/chromeos_switches.h" | 21 #include "chromeos/chromeos_switches.h" |
21 #endif | 22 #endif |
22 | 23 |
23 const CommandLinePrefStore::StringSwitchToPreferenceMapEntry | 24 const CommandLinePrefStore::StringSwitchToPreferenceMapEntry |
24 CommandLinePrefStore::string_switch_map_[] = { | 25 CommandLinePrefStore::string_switch_map_[] = { |
25 { switches::kLang, prefs::kApplicationLocale }, | 26 { switches::kLang, prefs::kApplicationLocale }, |
26 { switches::kAuthSchemes, prefs::kAuthSchemes }, | 27 { switches::kAuthSchemes, prefs::kAuthSchemes }, |
27 { switches::kAuthServerWhitelist, prefs::kAuthServerWhitelist }, | 28 { switches::kAuthServerWhitelist, prefs::kAuthServerWhitelist }, |
28 { switches::kAuthNegotiateDelegateWhitelist, | 29 { switches::kAuthNegotiateDelegateWhitelist, |
29 prefs::kAuthNegotiateDelegateWhitelist }, | 30 prefs::kAuthNegotiateDelegateWhitelist }, |
30 { switches::kGSSAPILibraryName, prefs::kGSSAPILibraryName }, | 31 { switches::kGSSAPILibraryName, prefs::kGSSAPILibraryName }, |
31 { data_reduction_proxy::switches::kDataReductionProxy, | 32 { data_reduction_proxy::switches::kDataReductionProxy, |
32 data_reduction_proxy::prefs::kDataReductionProxy }, | 33 data_reduction_proxy::prefs::kDataReductionProxy }, |
33 { switches::kDiskCacheDir, prefs::kDiskCacheDir }, | |
34 { switches::kSSLVersionMin, prefs::kSSLVersionMin }, | 34 { switches::kSSLVersionMin, prefs::kSSLVersionMin }, |
35 { switches::kSSLVersionMax, prefs::kSSLVersionMax }, | 35 { switches::kSSLVersionMax, prefs::kSSLVersionMax }, |
36 }; | 36 }; |
37 | 37 |
| 38 const CommandLinePrefStore::PathSwitchToPreferenceMapEntry |
| 39 CommandLinePrefStore::path_switch_map_[] = { |
| 40 { switches::kDiskCacheDir, prefs::kDiskCacheDir }, |
| 41 }; |
| 42 |
38 const CommandLinePrefStore::BooleanSwitchToPreferenceMapEntry | 43 const CommandLinePrefStore::BooleanSwitchToPreferenceMapEntry |
39 CommandLinePrefStore::boolean_switch_map_[] = { | 44 CommandLinePrefStore::boolean_switch_map_[] = { |
40 { switches::kDisableAuthNegotiateCnameLookup, | 45 { switches::kDisableAuthNegotiateCnameLookup, |
41 prefs::kDisableAuthNegotiateCnameLookup, true }, | 46 prefs::kDisableAuthNegotiateCnameLookup, true }, |
42 { switches::kEnableAuthNegotiatePort, prefs::kEnableAuthNegotiatePort, | 47 { switches::kEnableAuthNegotiatePort, prefs::kEnableAuthNegotiatePort, |
43 true }, | 48 true }, |
44 { switches::kDisable3DAPIs, prefs::kDisable3DAPIs, true }, | 49 { switches::kDisable3DAPIs, prefs::kDisable3DAPIs, true }, |
45 { switches::kEnableCloudPrintProxy, prefs::kCloudPrintProxyEnabled, | 50 { switches::kEnableCloudPrintProxy, prefs::kCloudPrintProxyEnabled, |
46 true }, | 51 true }, |
47 { switches::kAllowOutdatedPlugins, prefs::kPluginsAllowOutdated, true }, | 52 { switches::kAllowOutdatedPlugins, prefs::kPluginsAllowOutdated, true }, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 void CommandLinePrefStore::ApplySimpleSwitches() { | 101 void CommandLinePrefStore::ApplySimpleSwitches() { |
97 // Look for each switch we know about and set its preference accordingly. | 102 // Look for each switch we know about and set its preference accordingly. |
98 for (size_t i = 0; i < arraysize(string_switch_map_); ++i) { | 103 for (size_t i = 0; i < arraysize(string_switch_map_); ++i) { |
99 if (command_line_->HasSwitch(string_switch_map_[i].switch_name)) { | 104 if (command_line_->HasSwitch(string_switch_map_[i].switch_name)) { |
100 SetValue(string_switch_map_[i].preference_path, | 105 SetValue(string_switch_map_[i].preference_path, |
101 new base::StringValue(command_line_->GetSwitchValueASCII( | 106 new base::StringValue(command_line_->GetSwitchValueASCII( |
102 string_switch_map_[i].switch_name))); | 107 string_switch_map_[i].switch_name))); |
103 } | 108 } |
104 } | 109 } |
105 | 110 |
| 111 for (size_t i = 0; i < arraysize(path_switch_map_); ++i) { |
| 112 if (command_line_->HasSwitch(path_switch_map_[i].switch_name)) { |
| 113 SetValue(path_switch_map_[i].preference_path, |
| 114 new base::StringValue(command_line_->GetSwitchValuePath( |
| 115 path_switch_map_[i].switch_name).value())); |
| 116 } |
| 117 } |
| 118 |
106 for (size_t i = 0; i < arraysize(integer_switch_map_); ++i) { | 119 for (size_t i = 0; i < arraysize(integer_switch_map_); ++i) { |
107 if (command_line_->HasSwitch(integer_switch_map_[i].switch_name)) { | 120 if (command_line_->HasSwitch(integer_switch_map_[i].switch_name)) { |
108 std::string str_value = command_line_->GetSwitchValueASCII( | 121 std::string str_value = command_line_->GetSwitchValueASCII( |
109 integer_switch_map_[i].switch_name); | 122 integer_switch_map_[i].switch_name); |
110 int int_value = 0; | 123 int int_value = 0; |
111 if (!base::StringToInt(str_value, &int_value)) { | 124 if (!base::StringToInt(str_value, &int_value)) { |
112 LOG(ERROR) << "The value " << str_value << " of " | 125 LOG(ERROR) << "The value " << str_value << " of " |
113 << integer_switch_map_[i].switch_name | 126 << integer_switch_map_[i].switch_name |
114 << " can not be converted to integer, ignoring!"; | 127 << " can not be converted to integer, ignoring!"; |
115 continue; | 128 continue; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 list_value->Append(new base::StringValue(*it)); | 175 list_value->Append(new base::StringValue(*it)); |
163 } | 176 } |
164 SetValue(prefs::kCipherSuiteBlacklist, list_value); | 177 SetValue(prefs::kCipherSuiteBlacklist, list_value); |
165 } | 178 } |
166 } | 179 } |
167 | 180 |
168 void CommandLinePrefStore::ApplyBackgroundModeSwitches() { | 181 void CommandLinePrefStore::ApplyBackgroundModeSwitches() { |
169 if (command_line_->HasSwitch(switches::kDisableExtensions)) | 182 if (command_line_->HasSwitch(switches::kDisableExtensions)) |
170 SetValue(prefs::kBackgroundModeEnabled, new base::FundamentalValue(false)); | 183 SetValue(prefs::kBackgroundModeEnabled, new base::FundamentalValue(false)); |
171 } | 184 } |
OLD | NEW |