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..e5579189926f3a6dc027880745d90fcca0aaa35a |
--- /dev/null |
+++ b/chrome/browser/managed_mode/managed_user_settings_service.h |
@@ -0,0 +1,61 @@ |
+// 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 |
+// 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_settings.h. |
+class ManagedUserSettingsService { |
+ public: |
+ // A callback with 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 NotifySubscribers(); |
+ |
+ 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_ |