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 #ifndef CHROME_BROWSER_PREFS_COMMAND_LINE_PREF_STORE_H_ | 5 #ifndef CHROME_BROWSER_PREFS_COMMAND_LINE_PREF_STORE_H_ |
6 #define CHROME_BROWSER_PREFS_COMMAND_LINE_PREF_STORE_H_ | 6 #define CHROME_BROWSER_PREFS_COMMAND_LINE_PREF_STORE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
12 #include "chrome/common/pref_store.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/prefs/value_map_pref_store.h" |
13 | 14 |
14 class DictionaryValue; | 15 class DictionaryValue; |
15 | 16 |
16 // This PrefStore keeps track of preferences set by command-line switches, | 17 // This PrefStore keeps track of preferences set by command-line switches, |
17 // such as proxy settings. | 18 // such as proxy settings. |
18 class CommandLinePrefStore : public PrefStore { | 19 class CommandLinePrefStore : public ValueMapPrefStore { |
19 public: | 20 public: |
20 explicit CommandLinePrefStore(const CommandLine* command_line); | 21 explicit CommandLinePrefStore(const CommandLine* command_line); |
21 virtual ~CommandLinePrefStore(); | 22 virtual ~CommandLinePrefStore(); |
22 | 23 |
23 // PrefStore methods: | |
24 virtual PrefReadError ReadPrefs(); | |
25 virtual DictionaryValue* prefs() const { return prefs_.get(); } | |
26 | |
27 protected: | 24 protected: |
28 // Logs a message and returns false if the proxy switches are | 25 // Logs a message and returns false if the proxy switches are |
29 // self-contradictory. Protected so it can be used in unit testing. | 26 // self-contradictory. Protected so it can be used in unit testing. |
30 bool ValidateProxySwitches(); | 27 bool ValidateProxySwitches(); |
31 | 28 |
32 private: | 29 private: |
33 struct StringSwitchToPreferenceMapEntry { | 30 struct StringSwitchToPreferenceMapEntry { |
34 const char* switch_name; | 31 const char* switch_name; |
35 const char* preference_path; | 32 const char* preference_path; |
36 }; | 33 }; |
37 | 34 |
38 // |set_value| indicates what the preference should be set to if the switch | 35 // |set_value| indicates what the preference should be set to if the switch |
39 // is present. | 36 // is present. |
40 struct BooleanSwitchToPreferenceMapEntry { | 37 struct BooleanSwitchToPreferenceMapEntry { |
41 const char* switch_name; | 38 const char* switch_name; |
42 const char* preference_path; | 39 const char* preference_path; |
43 bool set_value; | 40 bool set_value; |
44 }; | 41 }; |
45 static const BooleanSwitchToPreferenceMapEntry boolean_switch_map_[]; | 42 static const BooleanSwitchToPreferenceMapEntry boolean_switch_map_[]; |
46 | 43 |
47 // Using the string and boolean maps, apply command-line switches to their | 44 // Using the string and boolean maps, apply command-line switches to their |
48 // corresponding preferences in this pref store. | 45 // corresponding preferences in this pref store. |
49 void ApplySimpleSwitches(); | 46 void ApplySimpleSwitches(); |
50 | 47 |
51 // Weak reference. | 48 // Weak reference. |
52 const CommandLine* command_line_; | 49 const CommandLine* command_line_; |
53 | 50 |
54 scoped_ptr<DictionaryValue> prefs_; | |
55 | |
56 static const StringSwitchToPreferenceMapEntry string_switch_map_[]; | 51 static const StringSwitchToPreferenceMapEntry string_switch_map_[]; |
57 | 52 |
58 DISALLOW_COPY_AND_ASSIGN(CommandLinePrefStore); | 53 DISALLOW_COPY_AND_ASSIGN(CommandLinePrefStore); |
59 }; | 54 }; |
60 | 55 |
61 #endif // CHROME_BROWSER_PREFS_COMMAND_LINE_PREF_STORE_H_ | 56 #endif // CHROME_BROWSER_PREFS_COMMAND_LINE_PREF_STORE_H_ |
OLD | NEW |