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 10 matching lines...) Expand all Loading... |
21 const CommandLinePrefStore::BooleanSwitchToPreferenceMapEntry | 21 const CommandLinePrefStore::BooleanSwitchToPreferenceMapEntry |
22 CommandLinePrefStore::boolean_switch_map_[] = { | 22 CommandLinePrefStore::boolean_switch_map_[] = { |
23 { switches::kNoProxyServer, prefs::kNoProxyServer, true }, | 23 { switches::kNoProxyServer, prefs::kNoProxyServer, true }, |
24 { switches::kProxyAutoDetect, prefs::kProxyAutoDetect, true }, | 24 { switches::kProxyAutoDetect, prefs::kProxyAutoDetect, true }, |
25 }; | 25 }; |
26 | 26 |
27 CommandLinePrefStore::CommandLinePrefStore(const CommandLine* command_line) | 27 CommandLinePrefStore::CommandLinePrefStore(const CommandLine* command_line) |
28 : command_line_(command_line), | 28 : command_line_(command_line), |
29 prefs_(new DictionaryValue()) {} | 29 prefs_(new DictionaryValue()) {} |
30 | 30 |
| 31 CommandLinePrefStore::~CommandLinePrefStore() {} |
| 32 |
31 PrefStore::PrefReadError CommandLinePrefStore::ReadPrefs() { | 33 PrefStore::PrefReadError CommandLinePrefStore::ReadPrefs() { |
32 ApplySimpleSwitches(); | 34 ApplySimpleSwitches(); |
33 ValidateProxySwitches(); | 35 ValidateProxySwitches(); |
34 return PrefStore::PREF_READ_ERROR_NONE; | 36 return PrefStore::PREF_READ_ERROR_NONE; |
35 } | 37 } |
36 | 38 |
| 39 DictionaryValue* CommandLinePrefStore::prefs() { return prefs_.get(); } |
| 40 |
37 void CommandLinePrefStore::ApplySimpleSwitches() { | 41 void CommandLinePrefStore::ApplySimpleSwitches() { |
38 // Look for each switch we know about and set its preference accordingly. | 42 // Look for each switch we know about and set its preference accordingly. |
39 for (size_t i = 0; i < arraysize(string_switch_map_); ++i) { | 43 for (size_t i = 0; i < arraysize(string_switch_map_); ++i) { |
40 if (command_line_->HasSwitch(string_switch_map_[i].switch_name)) { | 44 if (command_line_->HasSwitch(string_switch_map_[i].switch_name)) { |
41 Value* value = Value::CreateStringValue(command_line_-> | 45 Value* value = Value::CreateStringValue(command_line_-> |
42 GetSwitchValueASCII(string_switch_map_[i].switch_name)); | 46 GetSwitchValueASCII(string_switch_map_[i].switch_name)); |
43 prefs_->Set(string_switch_map_[i].preference_path, value); | 47 prefs_->Set(string_switch_map_[i].preference_path, value); |
44 } | 48 } |
45 } | 49 } |
46 | 50 |
(...skipping 11 matching lines...) Expand all Loading... |
58 (command_line_->HasSwitch(switches::kProxyAutoDetect) || | 62 (command_line_->HasSwitch(switches::kProxyAutoDetect) || |
59 command_line_->HasSwitch(switches::kProxyServer) || | 63 command_line_->HasSwitch(switches::kProxyServer) || |
60 command_line_->HasSwitch(switches::kProxyPacUrl) || | 64 command_line_->HasSwitch(switches::kProxyPacUrl) || |
61 command_line_->HasSwitch(switches::kProxyBypassList))) { | 65 command_line_->HasSwitch(switches::kProxyBypassList))) { |
62 LOG(WARNING) << "Additional command-line proxy switches specified when --" | 66 LOG(WARNING) << "Additional command-line proxy switches specified when --" |
63 << switches::kNoProxyServer << " was also specified."; | 67 << switches::kNoProxyServer << " was also specified."; |
64 return false; | 68 return false; |
65 } | 69 } |
66 return true; | 70 return true; |
67 } | 71 } |
OLD | NEW |