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

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

Issue 2349073002: Blimp Settings framework on the c++ side (Closed)
Patch Set: move the PrefService logic from blimp_main.cc 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 IsBlimpEnabled() {
52 return local_state_->GetBoolean(prefs::kBlimpEnabled);
Bernhard Bauer 2016/10/26 09:47:23 And now move the implementation out of line :)
Menglin 2016/10/26 19:28:33 Done.
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 IsRecordWholeDocument() {
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
72 PrefChangeRegistrar pref_change_registrar_;
73
74 // A list of all the observers of the Blimp Settings.
75 base::ObserverList<SettingsObserver> observers_;
76
77 bool show_network_stats_;
78
79 DISALLOW_COPY_AND_ASSIGN(Settings);
80 };
81
82 } // namespace client
83 } // namespace blimp
84
85 #endif // BLIMP_CLIENT_CORE_SETTINGS_SETTINGS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698