| 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/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 CommandLinePrefStore::boolean_switch_map_[] = { | 27 CommandLinePrefStore::boolean_switch_map_[] = { |
| 28 { switches::kNoProxyServer, prefs::kNoProxyServer, true }, | 28 { switches::kNoProxyServer, prefs::kNoProxyServer, true }, |
| 29 { switches::kProxyAutoDetect, prefs::kProxyAutoDetect, true }, | 29 { switches::kProxyAutoDetect, prefs::kProxyAutoDetect, true }, |
| 30 { switches::kDisableAuthNegotiateCnameLookup, | 30 { switches::kDisableAuthNegotiateCnameLookup, |
| 31 prefs::kDisableAuthNegotiateCnameLookup, true }, | 31 prefs::kDisableAuthNegotiateCnameLookup, true }, |
| 32 { switches::kEnableAuthNegotiatePort, prefs::kEnableAuthNegotiatePort, | 32 { switches::kEnableAuthNegotiatePort, prefs::kEnableAuthNegotiatePort, |
| 33 true }, | 33 true }, |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 CommandLinePrefStore::CommandLinePrefStore(const CommandLine* command_line) | 36 CommandLinePrefStore::CommandLinePrefStore(const CommandLine* command_line) |
| 37 : command_line_(command_line), | 37 : command_line_(command_line) { |
| 38 prefs_(new DictionaryValue()) {} | 38 ApplySimpleSwitches(); |
| 39 ValidateProxySwitches(); |
| 40 } |
| 39 | 41 |
| 40 CommandLinePrefStore::~CommandLinePrefStore() {} | 42 CommandLinePrefStore::~CommandLinePrefStore() {} |
| 41 | 43 |
| 42 PrefStore::PrefReadError CommandLinePrefStore::ReadPrefs() { | |
| 43 ApplySimpleSwitches(); | |
| 44 ValidateProxySwitches(); | |
| 45 return PrefStore::PREF_READ_ERROR_NONE; | |
| 46 } | |
| 47 | |
| 48 void CommandLinePrefStore::ApplySimpleSwitches() { | 44 void CommandLinePrefStore::ApplySimpleSwitches() { |
| 49 // 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. |
| 50 for (size_t i = 0; i < arraysize(string_switch_map_); ++i) { | 46 for (size_t i = 0; i < arraysize(string_switch_map_); ++i) { |
| 51 if (command_line_->HasSwitch(string_switch_map_[i].switch_name)) { | 47 if (command_line_->HasSwitch(string_switch_map_[i].switch_name)) { |
| 52 Value* value = Value::CreateStringValue(command_line_-> | 48 Value* value = Value::CreateStringValue(command_line_-> |
| 53 GetSwitchValueASCII(string_switch_map_[i].switch_name)); | 49 GetSwitchValueASCII(string_switch_map_[i].switch_name)); |
| 54 prefs_->Set(string_switch_map_[i].preference_path, value); | 50 SetValue(string_switch_map_[i].preference_path, value); |
| 55 } | 51 } |
| 56 } | 52 } |
| 57 | 53 |
| 58 for (size_t i = 0; i < arraysize(boolean_switch_map_); ++i) { | 54 for (size_t i = 0; i < arraysize(boolean_switch_map_); ++i) { |
| 59 if (command_line_->HasSwitch(boolean_switch_map_[i].switch_name)) { | 55 if (command_line_->HasSwitch(boolean_switch_map_[i].switch_name)) { |
| 60 Value* value = Value::CreateBooleanValue( | 56 Value* value = Value::CreateBooleanValue( |
| 61 boolean_switch_map_[i].set_value); | 57 boolean_switch_map_[i].set_value); |
| 62 prefs_->Set(boolean_switch_map_[i].preference_path, value); | 58 SetValue(boolean_switch_map_[i].preference_path, value); |
| 63 } | 59 } |
| 64 } | 60 } |
| 65 } | 61 } |
| 66 | 62 |
| 67 bool CommandLinePrefStore::ValidateProxySwitches() { | 63 bool CommandLinePrefStore::ValidateProxySwitches() { |
| 68 if (command_line_->HasSwitch(switches::kNoProxyServer) && | 64 if (command_line_->HasSwitch(switches::kNoProxyServer) && |
| 69 (command_line_->HasSwitch(switches::kProxyAutoDetect) || | 65 (command_line_->HasSwitch(switches::kProxyAutoDetect) || |
| 70 command_line_->HasSwitch(switches::kProxyServer) || | 66 command_line_->HasSwitch(switches::kProxyServer) || |
| 71 command_line_->HasSwitch(switches::kProxyPacUrl) || | 67 command_line_->HasSwitch(switches::kProxyPacUrl) || |
| 72 command_line_->HasSwitch(switches::kProxyBypassList))) { | 68 command_line_->HasSwitch(switches::kProxyBypassList))) { |
| 73 LOG(WARNING) << "Additional command-line proxy switches specified when --" | 69 LOG(WARNING) << "Additional command-line proxy switches specified when --" |
| 74 << switches::kNoProxyServer << " was also specified."; | 70 << switches::kNoProxyServer << " was also specified."; |
| 75 return false; | 71 return false; |
| 76 } | 72 } |
| 77 return true; | 73 return true; |
| 78 } | 74 } |
| OLD | NEW |