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

Side by Side Diff: blimp/client/core/settings/settings.h

Issue 2349073002: Blimp Settings framework on the c++ side (Closed)
Patch Set: fix trybot error Created 4 years, 1 month 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
OLDNEW
(Empty)
1 // Copyright 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 BLIMP_CLIENT_CORE_SETTINGS_SETTINGS_H_
6 #define BLIMP_CLIENT_CORE_SETTINGS_SETTINGS_H_
7
8 #include "base/macros.h"
9 #include "base/observer_list.h"
10 #include "blimp/client/core/settings/settings_prefs.h"
11 #include "components/prefs/command_line_pref_store.h"
12 #include "components/prefs/pref_change_registrar.h"
13 #include "components/prefs/pref_observer.h"
14 #include "components/prefs/pref_service.h"
15
16 class CommandLinePrefStore;
17 class PrefRegistrySimple;
18
19 namespace blimp {
20 namespace client {
21
22 class SettingsObserver;
23
24 class Settings : public PrefObserver {
25 public:
26 explicit Settings(PrefService* local_state);
27 virtual ~Settings();
28
29 static void RegisterPrefs(PrefRegistrySimple* registry);
30 static void ApplyBlimpSwitches(CommandLinePrefStore* store);
31
32 void AddObserver(SettingsObserver* observer);
33 void RemoveObserver(SettingsObserver* observer);
34
35 // Set whether or not Blimp mode is enabled.
36 void SetEnableBlimpMode(bool enable);
37
38 // Set record_whole_document_, and save it to the persistent storage.
39 void SetRecordWholeDocument(bool enable);
40
41 // Set show_network_stats_.
42 void SetShowNetworkStats(bool enable);
43
44 // PrefObserver implementation.
45 void OnPreferenceChanged(
46 PrefService* service, const std::string& pref_name) override;
47
48 // Whether or not Blimp mode is enabled.
49 // Can be changed via: command line --enable-blimp, setting dialog.
50 // Persisted across restarts: Yes.
51 bool blimp_enabled() {
Bernhard Bauer 2016/10/25 14:30:50 Nit: I think I would use CamelCase, ie. GetBlimpEn
Menglin 2016/10/25 18:32:52 Done.
52 return local_state_->GetBoolean(prefs::kBlimpEnabled);
53 }
54
55 // Whether or not the engine sends the whole webpage at once or pieces of it
56 // based on the current viewport.
57 // Can be changed via: command line --download-whole-document, setting dialog.
58 // Persisted across restarts: Yes.
59 bool record_whole_document() {
60 return local_state_->GetBoolean(prefs::kRecordWholeDocument);
61 }
62
63 // Whether or not to show the network stats.
64 // Can be changed via: setting dialog.
65 // Persisted across restarts: No.
66 bool show_network_stats() { return show_network_stats_; }
67
68 private:
69 // The pref service used to store the persistent settings.
70 PrefService* local_state_;
71
Bernhard Bauer 2016/10/25 14:30:50 Nit: superfluous empty line.
Menglin 2016/10/25 18:32:52 Done.
72
73 PrefChangeRegistrar pref_change_registrar_;
74
75 // A list of all the observers of the Blimp Settings.
76 base::ObserverList<SettingsObserver> observers_;
77
78 bool show_network_stats_;
79
80 // Mapping of command line switches to prefs.
81 static const CommandLinePrefStore::BooleanSwitchToPreferenceMapEntry
82 boolean_switch_map_[];
Bernhard Bauer 2016/10/25 14:30:50 Does this need to be declared in the header?
Menglin 2016/10/25 18:32:52 no it doesn't have to. Done.
83
84 DISALLOW_COPY_AND_ASSIGN(Settings);
85 };
86
87 } // namespace client
88 } // namespace blimp
89
90 #endif // BLIMP_CLIENT_CORE_SETTINGS_SETTINGS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698