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

Unified Diff: blimp/client/core/settings/settings.h

Issue 2349073002: Blimp Settings framework on the c++ side (Closed)
Patch Set: Created 4 years, 3 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..e98099bfafcb63a5b17e3d4c9a47af29bbd6ddaf
--- /dev/null
+++ b/blimp/client/core/settings/settings.h
@@ -0,0 +1,68 @@
+// 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"
+
+class PrefRegistrySimple;
+class PrefService;
+
+namespace blimp {
+namespace client {
+
+class SettingsFeature;
+class SettingsObserver;
+
+class Settings {
+ public:
+ explicit Settings(PrefService* local_state);
+ virtual ~Settings();
+
+ static void RegisterPrefs(PrefRegistrySimple* registry);
+
+ // TODO(mlliu): pull more settings from java.
+ // Initializes blimp_enabled_, and record_whole_document_ from the command
David Trainor- moved to gerrit 2016/09/27 04:10:06 Maybe don't include this. I expect it to get out
Menglin 2016/09/30 23:48:57 Done.
+ // line flags and the PrefService.
+ void InitializeFromCommandLineAndPref();
David Trainor- moved to gerrit 2016/09/27 04:10:06 Can this just happen in the constructor?
Menglin 2016/09/30 23:48:57 Yes. Then I need to test the constructor because t
+
+ void AddObserver(std::unique_ptr<SettingsObserver> observer);
David Trainor- moved to gerrit 2016/09/27 04:10:06 I think giving ownership of the observer is a bit
Menglin 2016/09/30 23:48:57 Done.
+ void RemoveObserver(std::unique_ptr<SettingsObserver> observer) {}
David Trainor- moved to gerrit 2016/09/27 04:10:06 Implement?
Menglin 2016/09/30 23:48:57 Done.
+
+ void SetEnableBlimpMode(bool enable);
David Trainor- moved to gerrit 2016/09/27 04:10:06 Comment on these? Maybe also include what command
Menglin 2016/09/30 23:48:57 Done.
+ void SetRecordWholeDocument(bool enable);
+ void SetShowNetworkStats(bool enable);
+
+ bool blimp_enabled() { return blimp_enabled_; }
+ bool record_whole_document() { return record_whole_document_; }
+ bool show_network_stats() { return show_network_stats_; }
+
+ private:
+ // The pref service used to store persist the settings.
+ PrefService* local_state_;
+
+ // A list of all the observers of the Blimp Settings.
+ std::vector<std::unique_ptr<SettingsObserver>> observers_;
+
+ // blimp_enabled_ is init from command line/PrefService. It can be changed
+ // from UI.
+ bool blimp_enabled_;
+
+ // Used to avoid sending unnecessary messages to engine. SettingsFeature sends
+ // this to the engine.
+ bool record_whole_document_;
+
+ // show_network_stats_ can only be set from UI, and the value is not stored
+ // persistently.
+ 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