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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
Index: blimp/client/core/settings/settings.h
diff --git a/blimp/client/core/settings/settings.h b/blimp/client/core/settings/settings.h
new file mode 100644
index 0000000000000000000000000000000000000000..2ed49456dd925fb6dd22156fdab580188b7dcfd1
--- /dev/null
+++ b/blimp/client/core/settings/settings.h
@@ -0,0 +1,85 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BLIMP_CLIENT_CORE_SETTINGS_SETTINGS_H_
+#define BLIMP_CLIENT_CORE_SETTINGS_SETTINGS_H_
+
+#include "base/macros.h"
+#include "base/observer_list.h"
+#include "blimp/client/core/settings/settings_prefs.h"
+#include "components/prefs/command_line_pref_store.h"
+#include "components/prefs/pref_change_registrar.h"
+#include "components/prefs/pref_observer.h"
+#include "components/prefs/pref_service.h"
+
+class CommandLinePrefStore;
+class PrefRegistrySimple;
+
+namespace blimp {
+namespace client {
+
+class SettingsObserver;
+
+class Settings : public PrefObserver {
+ public:
+ explicit Settings(PrefService* local_state);
+ virtual ~Settings();
+
+ static void RegisterPrefs(PrefRegistrySimple* registry);
+ static void ApplyBlimpSwitches(CommandLinePrefStore* store);
+
+ void AddObserver(SettingsObserver* observer);
+ void RemoveObserver(SettingsObserver* observer);
+
+ // Set whether or not Blimp mode is enabled.
+ void SetEnableBlimpMode(bool enable);
+
+ // Set record_whole_document_, and save it to the persistent storage.
+ void SetRecordWholeDocument(bool enable);
+
+ // Set show_network_stats_.
+ void SetShowNetworkStats(bool enable);
+
+ // PrefObserver implementation.
+ void OnPreferenceChanged(
+ PrefService* service, const std::string& pref_name) override;
+
+ // Whether or not Blimp mode is enabled.
+ // Can be changed via: command line --enable-blimp, setting dialog.
+ // Persisted across restarts: Yes.
+ bool IsBlimpEnabled() {
+ 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.
+ }
+
+ // Whether or not the engine sends the whole webpage at once or pieces of it
+ // based on the current viewport.
+ // Can be changed via: command line --download-whole-document, setting dialog.
+ // Persisted across restarts: Yes.
+ bool IsRecordWholeDocument() {
+ return local_state_->GetBoolean(prefs::kRecordWholeDocument);
+ }
+
+ // Whether or not to show the network stats.
+ // Can be changed via: setting dialog.
+ // Persisted across restarts: No.
+ bool show_network_stats() { return show_network_stats_; }
+
+ private:
+ // The pref service used to store the persistent settings.
+ PrefService* local_state_;
+
+ PrefChangeRegistrar pref_change_registrar_;
+
+ // A list of all the observers of the Blimp Settings.
+ base::ObserverList<SettingsObserver> observers_;
+
+ bool show_network_stats_;
+
+ DISALLOW_COPY_AND_ASSIGN(Settings);
+};
+
+} // namespace client
+} // namespace blimp
+
+#endif // BLIMP_CLIENT_CORE_SETTINGS_SETTINGS_H_

Powered by Google App Engine
This is Rietveld 408576698