OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_split.h" |
8 #include "base/values.h" | 9 #include "base/values.h" |
9 #include "chrome/browser/prefs/proxy_config_dictionary.h" | 10 #include "chrome/browser/prefs/proxy_config_dictionary.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 #include "ui/base/ui_base_switches.h" | 13 #include "ui/base/ui_base_switches.h" |
13 | 14 |
14 const CommandLinePrefStore::StringSwitchToPreferenceMapEntry | 15 const CommandLinePrefStore::StringSwitchToPreferenceMapEntry |
15 CommandLinePrefStore::string_switch_map_[] = { | 16 CommandLinePrefStore::string_switch_map_[] = { |
16 { switches::kLang, prefs::kApplicationLocale }, | 17 { switches::kLang, prefs::kApplicationLocale }, |
17 { switches::kAuthSchemes, prefs::kAuthSchemes }, | 18 { switches::kAuthSchemes, prefs::kAuthSchemes }, |
(...skipping 23 matching lines...) Expand all Loading... |
41 prefs::kWebKitAllowDisplayingInsecureContent, false }, | 42 prefs::kWebKitAllowDisplayingInsecureContent, false }, |
42 { switches::kAllowCrossOriginAuthPrompt, | 43 { switches::kAllowCrossOriginAuthPrompt, |
43 prefs::kAllowCrossOriginAuthPrompt, true }, | 44 prefs::kAllowCrossOriginAuthPrompt, true }, |
44 }; | 45 }; |
45 | 46 |
46 CommandLinePrefStore::CommandLinePrefStore(const CommandLine* command_line) | 47 CommandLinePrefStore::CommandLinePrefStore(const CommandLine* command_line) |
47 : command_line_(command_line) { | 48 : command_line_(command_line) { |
48 ApplySimpleSwitches(); | 49 ApplySimpleSwitches(); |
49 ApplyProxyMode(); | 50 ApplyProxyMode(); |
50 ValidateProxySwitches(); | 51 ValidateProxySwitches(); |
| 52 ApplySSLSwitches(); |
51 } | 53 } |
52 | 54 |
53 CommandLinePrefStore::~CommandLinePrefStore() {} | 55 CommandLinePrefStore::~CommandLinePrefStore() {} |
54 | 56 |
55 void CommandLinePrefStore::ApplySimpleSwitches() { | 57 void CommandLinePrefStore::ApplySimpleSwitches() { |
56 // Look for each switch we know about and set its preference accordingly. | 58 // Look for each switch we know about and set its preference accordingly. |
57 for (size_t i = 0; i < arraysize(string_switch_map_); ++i) { | 59 for (size_t i = 0; i < arraysize(string_switch_map_); ++i) { |
58 if (command_line_->HasSwitch(string_switch_map_[i].switch_name)) { | 60 if (command_line_->HasSwitch(string_switch_map_[i].switch_name)) { |
59 Value* value = Value::CreateStringValue(command_line_-> | 61 Value* value = Value::CreateStringValue(command_line_-> |
60 GetSwitchValueASCII(string_switch_map_[i].switch_name)); | 62 GetSwitchValueASCII(string_switch_map_[i].switch_name)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 } else if (command_line_->HasSwitch(switches::kProxyServer)) { | 101 } else if (command_line_->HasSwitch(switches::kProxyServer)) { |
100 std::string proxy_server = | 102 std::string proxy_server = |
101 command_line_->GetSwitchValueASCII(switches::kProxyServer); | 103 command_line_->GetSwitchValueASCII(switches::kProxyServer); |
102 std::string bypass_list = | 104 std::string bypass_list = |
103 command_line_->GetSwitchValueASCII(switches::kProxyBypassList); | 105 command_line_->GetSwitchValueASCII(switches::kProxyBypassList); |
104 SetValue(prefs::kProxy, | 106 SetValue(prefs::kProxy, |
105 ProxyConfigDictionary::CreateFixedServers(proxy_server, | 107 ProxyConfigDictionary::CreateFixedServers(proxy_server, |
106 bypass_list)); | 108 bypass_list)); |
107 } | 109 } |
108 } | 110 } |
| 111 |
| 112 void CommandLinePrefStore::ApplySSLSwitches() { |
| 113 if (command_line_->HasSwitch(switches::kCipherSuiteBlacklist)) { |
| 114 std::string cipher_suites = |
| 115 command_line_->GetSwitchValueASCII(switches::kCipherSuiteBlacklist); |
| 116 std::vector<std::string> cipher_strings; |
| 117 base::SplitString(cipher_suites, ',', &cipher_strings); |
| 118 base::ListValue* list_value = new base::ListValue(); |
| 119 for (std::vector<std::string>::const_iterator it = cipher_strings.begin(); |
| 120 it != cipher_strings.end(); ++it) { |
| 121 list_value->Append(base::Value::CreateStringValue(*it)); |
| 122 } |
| 123 SetValue(prefs::kCipherSuiteBlacklist, list_value); |
| 124 } |
| 125 } |
OLD | NEW |