Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_PREFS_COMMAND_LINE_PREF_STORE_H_ | |
| 6 #define COMPONENTS_PREFS_COMMAND_LINE_PREF_STORE_H_ | |
| 7 | |
| 8 #include "base/command_line.h" | |
| 9 #include "base/macros.h" | |
| 10 #include "base/values.h" | |
| 11 #include "components/prefs/value_map_pref_store.h" | |
| 12 | |
| 13 // Given {command-line, preferences}, this PrefStore apply the command-line | |
| 14 // switches to their corresponding preferences. | |
|
Bernhard Bauer
2016/10/14 10:06:31
Nit: Maybe something like, "Base class for a PrefS
Menglin
2016/10/14 17:12:04
Done.
| |
| 15 class COMPONENTS_PREFS_EXPORT CommandLinePrefStore : public ValueMapPrefStore { | |
| 16 public: | |
| 17 struct SwitchToPreferenceMapEntry { | |
|
Bernhard Bauer
2016/10/14 10:06:31
Can these become protected as well?
Menglin
2016/10/14 17:12:04
hmm I think if in blimp, we have
static BlimpClie
| |
| 18 const char* switch_name; | |
| 19 const char* preference_path; | |
| 20 }; | |
| 21 | |
| 22 // |set_value| indicates what the preference should be set to if the switch | |
| 23 // is present. | |
| 24 struct BooleanSwitchToPreferenceMapEntry { | |
| 25 const char* switch_name; | |
| 26 const char* preference_path; | |
| 27 bool set_value; | |
| 28 }; | |
| 29 | |
| 30 // Apply command-line switches to the corresponding preferences of the switch | |
| 31 // map, where the value associated with the switch is a string. | |
| 32 void ApplyStringSwitches( | |
| 33 const SwitchToPreferenceMapEntry string_switch_map[], size_t size); | |
| 34 | |
| 35 // Apply command-line switches to the corresponding preferences of the switch | |
| 36 // map, where the value associated with the switch is a path. | |
| 37 void ApplyPathSwitches(const SwitchToPreferenceMapEntry path_switch_map[], | |
| 38 size_t size); | |
| 39 | |
| 40 // Apply command-line switches to the corresponding preferences of the switch | |
| 41 // map, where the value associated with the switch is an integer. | |
| 42 void ApplyIntegerSwitches( | |
| 43 const SwitchToPreferenceMapEntry integer_switch_map[], size_t size); | |
| 44 | |
| 45 // Apply command-line switches to the corresponding preferences of the | |
| 46 // boolean switch map. | |
| 47 void ApplyBooleanSwitches( | |
| 48 const BooleanSwitchToPreferenceMapEntry boolean_switch_map[], | |
| 49 size_t size); | |
| 50 | |
| 51 | |
| 52 protected: | |
| 53 explicit CommandLinePrefStore(const base::CommandLine* command_line); | |
| 54 ~CommandLinePrefStore() override; | |
| 55 | |
| 56 const base::CommandLine* command_line() { return command_line_; } | |
| 57 | |
| 58 private: | |
| 59 // Weak reference. | |
| 60 const base::CommandLine* command_line_; | |
| 61 | |
| 62 DISALLOW_COPY_AND_ASSIGN(CommandLinePrefStore); | |
| 63 }; | |
| 64 | |
| 65 #endif // COMPONENTS_PREFS_COMMAND_LINE_PREF_STORE_H_ | |
| OLD | NEW |