Index: chrome/browser/managed_mode/managed_user_settings_service.h |
diff --git a/chrome/browser/managed_mode/managed_user_settings_service.h b/chrome/browser/managed_mode/managed_user_settings_service.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..99a4e6b2065f5106c285568ad81fa031e6d352d1 |
--- /dev/null |
+++ b/chrome/browser/managed_mode/managed_user_settings_service.h |
@@ -0,0 +1,62 @@ |
+// Copyright 2013 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 CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SETTINGS_SERVICE_H_ |
+#define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SETTINGS_SERVICE_H_ |
+ |
+#include <string> |
+#include <vector> |
+ |
+#include "base/basictypes.h" |
+#include "base/callback.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/values.h" |
+#include "chrome/browser/managed_mode/managed_users.h" |
+ |
+// Defines an abstract base class for a service that stores managed user |
Pam (message me for reviews)
2013/09/03 10:45:32
It doesn't just store the settings -- that would b
Bernhard Bauer
2013/09/03 10:53:43
Well, it does store the settings in the sense that
|
+// settings, which are key-value pairs configured by a different user to |
+// control certain browser behaviors for managed users. |
+// Setting names are defined in managed_user_constants.h. |
+class ManagedUserSettingsService { |
+ public: |
+ // A callback whose first parameter is a dictionary containing all managed |
+ // user settings. If the dictionary is NULL, it means that the service is |
+ // inactive, i.e. the user is not managed. |
+ typedef base::Callback<void(const base::DictionaryValue*)> SettingsCallback; |
+ |
+ // Adds a callback to be called when managed user settings are initially |
+ // available, or when they change. |
+ void Subscribe(const SettingsCallback& callback); |
+ |
+ // Activates the service. This happens when the user is managed. |
+ void Activate(); |
+ |
+ protected: |
+ ManagedUserSettingsService(); |
+ virtual ~ManagedUserSettingsService(); |
+ |
+ // Sends the settings to all subscribers. This method should be called by the |
+ // subclass whenever the settings change. |
+ void InformSubscribers(); |
+ |
+ private: |
+ // Whether managed user settings are available. |
+ virtual bool IsReady() const = 0; |
+ |
+ // Returns a dictionary with all managed user settings. This method will |
+ // only be called once IsReady() returns true. |
+ virtual scoped_ptr<base::DictionaryValue> GetSettings() const = 0; |
+ |
+ // Returns the dictionary produced by GetSettings() above if the service is |
+ // active, or NULL otherwise. |
+ scoped_ptr<base::DictionaryValue> GetSettingsIfActive(); |
+ |
+ bool active_; |
+ |
+ std::vector<SettingsCallback> subscribers_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ManagedUserSettingsService); |
+}; |
+ |
+#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SETTINGS_SERVICE_H_ |