OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/app_switches.h" | 7 #include "app/app_switches.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/prefs/proxy_prefs.h" | |
10 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
11 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
12 | 13 |
13 const CommandLinePrefStore::StringSwitchToPreferenceMapEntry | 14 const CommandLinePrefStore::StringSwitchToPreferenceMapEntry |
14 CommandLinePrefStore::string_switch_map_[] = { | 15 CommandLinePrefStore::string_switch_map_[] = { |
15 { switches::kLang, prefs::kApplicationLocale }, | 16 { switches::kLang, prefs::kApplicationLocale }, |
16 { switches::kProxyServer, prefs::kProxyServer }, | 17 { switches::kProxyServer, prefs::kProxyServer }, |
17 { switches::kProxyPacUrl, prefs::kProxyPacUrl }, | 18 { switches::kProxyPacUrl, prefs::kProxyPacUrl }, |
18 { switches::kProxyBypassList, prefs::kProxyBypassList }, | 19 { switches::kProxyBypassList, prefs::kProxyBypassList }, |
19 { switches::kAuthSchemes, prefs::kAuthSchemes }, | 20 { switches::kAuthSchemes, prefs::kAuthSchemes }, |
20 { switches::kAuthServerWhitelist, prefs::kAuthServerWhitelist }, | 21 { switches::kAuthServerWhitelist, prefs::kAuthServerWhitelist }, |
21 { switches::kAuthNegotiateDelegateWhitelist, | 22 { switches::kAuthNegotiateDelegateWhitelist, |
22 prefs::kAuthNegotiateDelegateWhitelist }, | 23 prefs::kAuthNegotiateDelegateWhitelist }, |
23 { switches::kGSSAPILibraryName, prefs::kGSSAPILibraryName }, | 24 { switches::kGSSAPILibraryName, prefs::kGSSAPILibraryName }, |
24 }; | 25 }; |
25 | 26 |
26 const CommandLinePrefStore::BooleanSwitchToPreferenceMapEntry | 27 const CommandLinePrefStore::BooleanSwitchToPreferenceMapEntry |
27 CommandLinePrefStore::boolean_switch_map_[] = { | 28 CommandLinePrefStore::boolean_switch_map_[] = { |
28 { switches::kNoProxyServer, prefs::kNoProxyServer, true }, | |
29 { switches::kProxyAutoDetect, prefs::kProxyAutoDetect, true }, | |
30 { switches::kDisableAuthNegotiateCnameLookup, | 29 { switches::kDisableAuthNegotiateCnameLookup, |
31 prefs::kDisableAuthNegotiateCnameLookup, true }, | 30 prefs::kDisableAuthNegotiateCnameLookup, true }, |
32 { switches::kEnableAuthNegotiatePort, prefs::kEnableAuthNegotiatePort, | 31 { switches::kEnableAuthNegotiatePort, prefs::kEnableAuthNegotiatePort, |
33 true }, | 32 true }, |
34 }; | 33 }; |
35 | 34 |
36 CommandLinePrefStore::CommandLinePrefStore(const CommandLine* command_line) | 35 CommandLinePrefStore::CommandLinePrefStore(const CommandLine* command_line) |
37 : command_line_(command_line) { | 36 : command_line_(command_line) { |
38 ApplySimpleSwitches(); | 37 ApplySimpleSwitches(); |
38 ApplyProxyMode(); | |
39 ValidateProxySwitches(); | 39 ValidateProxySwitches(); |
40 } | 40 } |
41 | 41 |
42 CommandLinePrefStore::~CommandLinePrefStore() {} | 42 CommandLinePrefStore::~CommandLinePrefStore() {} |
43 | 43 |
44 void CommandLinePrefStore::ApplySimpleSwitches() { | 44 void CommandLinePrefStore::ApplySimpleSwitches() { |
45 // Look for each switch we know about and set its preference accordingly. | 45 // Look for each switch we know about and set its preference accordingly. |
46 for (size_t i = 0; i < arraysize(string_switch_map_); ++i) { | 46 for (size_t i = 0; i < arraysize(string_switch_map_); ++i) { |
47 if (command_line_->HasSwitch(string_switch_map_[i].switch_name)) { | 47 if (command_line_->HasSwitch(string_switch_map_[i].switch_name)) { |
48 Value* value = Value::CreateStringValue(command_line_-> | 48 Value* value = Value::CreateStringValue(command_line_-> |
(...skipping 16 matching lines...) Expand all Loading... | |
65 (command_line_->HasSwitch(switches::kProxyAutoDetect) || | 65 (command_line_->HasSwitch(switches::kProxyAutoDetect) || |
66 command_line_->HasSwitch(switches::kProxyServer) || | 66 command_line_->HasSwitch(switches::kProxyServer) || |
67 command_line_->HasSwitch(switches::kProxyPacUrl) || | 67 command_line_->HasSwitch(switches::kProxyPacUrl) || |
68 command_line_->HasSwitch(switches::kProxyBypassList))) { | 68 command_line_->HasSwitch(switches::kProxyBypassList))) { |
69 LOG(WARNING) << "Additional command-line proxy switches specified when --" | 69 LOG(WARNING) << "Additional command-line proxy switches specified when --" |
70 << switches::kNoProxyServer << " was also specified."; | 70 << switches::kNoProxyServer << " was also specified."; |
71 return false; | 71 return false; |
72 } | 72 } |
73 return true; | 73 return true; |
74 } | 74 } |
75 | |
76 void CommandLinePrefStore::ApplyProxyMode() { | |
Pam (message me for reviews)
2010/12/18 08:29:55
Naming again. If the pref is kProxyServerMode, thi
battre (please use the other)
2010/12/20 12:57:23
This remains ApplyProxyMode after renaming kProxyS
| |
77 if (command_line_->HasSwitch(switches::kNoProxyServer)) { | |
78 SetValue(prefs::kProxyServerMode, | |
79 Value::CreateIntegerValue(ProxyPrefs::DISABLED)); | |
80 } else if (command_line_->HasSwitch(switches::kProxyAutoDetect)) { | |
81 SetValue(prefs::kProxyServerMode, | |
82 Value::CreateIntegerValue(ProxyPrefs::AUTO_DETECT)); | |
83 } else if (command_line_->HasSwitch(switches::kProxyServer) || | |
84 command_line_->HasSwitch(switches::kProxyPacUrl) || | |
Mattias Nissler (ping if slow)
2010/12/20 13:34:03
can we align these with the opening parentheses? (
battre (please use the other)
2010/12/21 14:18:18
Yes we can.
Done.
| |
85 command_line_->HasSwitch(switches::kProxyBypassList)) { | |
86 SetValue(prefs::kProxyServerMode, | |
87 Value::CreateIntegerValue(ProxyPrefs::MANUAL)); | |
88 } | |
89 // Mode defaults to system. | |
Mattias Nissler (ping if slow)
2010/12/20 13:34:03
What's that comment good for? Could also be overri
battre (please use the other)
2010/12/21 14:18:18
I deleted it.
| |
90 } | |
OLD | NEW |