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/logging.h" | 10 #include "base/logging.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 : command_line_(command_line) { | 74 : command_line_(command_line) { |
75 ApplySimpleSwitches(); | 75 ApplySimpleSwitches(); |
76 ApplyProxyMode(); | 76 ApplyProxyMode(); |
77 ValidateProxySwitches(); | 77 ValidateProxySwitches(); |
78 ApplySSLSwitches(); | 78 ApplySSLSwitches(); |
79 ApplyBackgroundModeSwitches(); | 79 ApplyBackgroundModeSwitches(); |
80 } | 80 } |
81 | 81 |
82 CommandLinePrefStore::~CommandLinePrefStore() {} | 82 CommandLinePrefStore::~CommandLinePrefStore() {} |
83 | 83 |
| 84 bool CommandLinePrefStore::ValidateProxySwitches() { |
| 85 if (command_line_->HasSwitch(switches::kNoProxyServer) && |
| 86 (command_line_->HasSwitch(switches::kProxyAutoDetect) || |
| 87 command_line_->HasSwitch(switches::kProxyServer) || |
| 88 command_line_->HasSwitch(switches::kProxyPacUrl) || |
| 89 command_line_->HasSwitch(switches::kProxyBypassList))) { |
| 90 LOG(WARNING) << "Additional command-line proxy switches specified when --" |
| 91 << switches::kNoProxyServer << " was also specified."; |
| 92 return false; |
| 93 } |
| 94 return true; |
| 95 } |
| 96 |
84 void CommandLinePrefStore::ApplySimpleSwitches() { | 97 void CommandLinePrefStore::ApplySimpleSwitches() { |
85 // Look for each switch we know about and set its preference accordingly. | 98 // Look for each switch we know about and set its preference accordingly. |
86 for (size_t i = 0; i < arraysize(string_switch_map_); ++i) { | 99 for (size_t i = 0; i < arraysize(string_switch_map_); ++i) { |
87 if (command_line_->HasSwitch(string_switch_map_[i].switch_name)) { | 100 if (command_line_->HasSwitch(string_switch_map_[i].switch_name)) { |
88 Value* value = Value::CreateStringValue(command_line_-> | 101 Value* value = Value::CreateStringValue(command_line_-> |
89 GetSwitchValueASCII(string_switch_map_[i].switch_name)); | 102 GetSwitchValueASCII(string_switch_map_[i].switch_name)); |
90 SetValue(string_switch_map_[i].preference_path, value); | 103 SetValue(string_switch_map_[i].preference_path, value); |
91 } | 104 } |
92 } | 105 } |
93 | 106 |
(...skipping 15 matching lines...) Expand all Loading... |
109 | 122 |
110 for (size_t i = 0; i < arraysize(boolean_switch_map_); ++i) { | 123 for (size_t i = 0; i < arraysize(boolean_switch_map_); ++i) { |
111 if (command_line_->HasSwitch(boolean_switch_map_[i].switch_name)) { | 124 if (command_line_->HasSwitch(boolean_switch_map_[i].switch_name)) { |
112 Value* value = Value::CreateBooleanValue( | 125 Value* value = Value::CreateBooleanValue( |
113 boolean_switch_map_[i].set_value); | 126 boolean_switch_map_[i].set_value); |
114 SetValue(boolean_switch_map_[i].preference_path, value); | 127 SetValue(boolean_switch_map_[i].preference_path, value); |
115 } | 128 } |
116 } | 129 } |
117 } | 130 } |
118 | 131 |
119 bool CommandLinePrefStore::ValidateProxySwitches() { | |
120 if (command_line_->HasSwitch(switches::kNoProxyServer) && | |
121 (command_line_->HasSwitch(switches::kProxyAutoDetect) || | |
122 command_line_->HasSwitch(switches::kProxyServer) || | |
123 command_line_->HasSwitch(switches::kProxyPacUrl) || | |
124 command_line_->HasSwitch(switches::kProxyBypassList))) { | |
125 LOG(WARNING) << "Additional command-line proxy switches specified when --" | |
126 << switches::kNoProxyServer << " was also specified."; | |
127 return false; | |
128 } | |
129 return true; | |
130 } | |
131 | |
132 void CommandLinePrefStore::ApplyProxyMode() { | 132 void CommandLinePrefStore::ApplyProxyMode() { |
133 if (command_line_->HasSwitch(switches::kNoProxyServer)) { | 133 if (command_line_->HasSwitch(switches::kNoProxyServer)) { |
134 SetValue(prefs::kProxy, | 134 SetValue(prefs::kProxy, |
135 ProxyConfigDictionary::CreateDirect()); | 135 ProxyConfigDictionary::CreateDirect()); |
136 } else if (command_line_->HasSwitch(switches::kProxyPacUrl)) { | 136 } else if (command_line_->HasSwitch(switches::kProxyPacUrl)) { |
137 std::string pac_script_url = | 137 std::string pac_script_url = |
138 command_line_->GetSwitchValueASCII(switches::kProxyPacUrl); | 138 command_line_->GetSwitchValueASCII(switches::kProxyPacUrl); |
139 SetValue(prefs::kProxy, | 139 SetValue(prefs::kProxy, |
140 ProxyConfigDictionary::CreatePacScript(pac_script_url, false)); | 140 ProxyConfigDictionary::CreatePacScript(pac_script_url, false)); |
141 } else if (command_line_->HasSwitch(switches::kProxyAutoDetect)) { | 141 } else if (command_line_->HasSwitch(switches::kProxyAutoDetect)) { |
(...skipping 25 matching lines...) Expand all Loading... |
167 } | 167 } |
168 } | 168 } |
169 | 169 |
170 void CommandLinePrefStore::ApplyBackgroundModeSwitches() { | 170 void CommandLinePrefStore::ApplyBackgroundModeSwitches() { |
171 if (command_line_->HasSwitch(switches::kDisableBackgroundMode) || | 171 if (command_line_->HasSwitch(switches::kDisableBackgroundMode) || |
172 command_line_->HasSwitch(switches::kDisableExtensions)) { | 172 command_line_->HasSwitch(switches::kDisableExtensions)) { |
173 Value* value = Value::CreateBooleanValue(false); | 173 Value* value = Value::CreateBooleanValue(false); |
174 SetValue(prefs::kBackgroundModeEnabled, value); | 174 SetValue(prefs::kBackgroundModeEnabled, value); |
175 } | 175 } |
176 } | 176 } |
OLD | NEW |