Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(645)

Side by Side Diff: components/prefs/command_line_pref_store.h

Issue 2419733005: Extract a base class from CommandLinePrefStore (Closed)
Patch Set: nit in comment Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/prefs/BUILD.gn ('k') | components/prefs/command_line_pref_store.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 // Base class for a PrefStore that maps command line switches to preferences.
14 // The Apply...Switches() methods can be called by subclasses with their own
15 // maps, or delegated to other code.
16 class COMPONENTS_PREFS_EXPORT CommandLinePrefStore : public ValueMapPrefStore {
17 public:
18 struct SwitchToPreferenceMapEntry {
19 const char* switch_name;
20 const char* preference_path;
21 };
22
23 // |set_value| indicates what the preference should be set to if the switch
24 // is present.
25 struct BooleanSwitchToPreferenceMapEntry {
26 const char* switch_name;
27 const char* preference_path;
28 bool set_value;
29 };
30
31 // Apply command-line switches to the corresponding preferences of the switch
32 // map, where the value associated with the switch is a string.
33 void ApplyStringSwitches(
34 const SwitchToPreferenceMapEntry string_switch_map[], size_t size);
35
36 // Apply command-line switches to the corresponding preferences of the switch
37 // map, where the value associated with the switch is a path.
38 void ApplyPathSwitches(const SwitchToPreferenceMapEntry path_switch_map[],
39 size_t size);
40
41 // Apply command-line switches to the corresponding preferences of the switch
42 // map, where the value associated with the switch is an integer.
43 void ApplyIntegerSwitches(
44 const SwitchToPreferenceMapEntry integer_switch_map[], size_t size);
45
46 // Apply command-line switches to the corresponding preferences of the
47 // boolean switch map.
48 void ApplyBooleanSwitches(
49 const BooleanSwitchToPreferenceMapEntry boolean_switch_map[],
50 size_t size);
51
52
53 protected:
54 explicit CommandLinePrefStore(const base::CommandLine* command_line);
55 ~CommandLinePrefStore() override;
56
57 const base::CommandLine* command_line() { return command_line_; }
58
59 private:
60 // Weak reference.
61 const base::CommandLine* command_line_;
62
63 DISALLOW_COPY_AND_ASSIGN(CommandLinePrefStore);
64 };
65
66 #endif // COMPONENTS_PREFS_COMMAND_LINE_PREF_STORE_H_
OLDNEW
« no previous file with comments | « components/prefs/BUILD.gn ('k') | components/prefs/command_line_pref_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698