Chromium Code Reviews| 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..123c75d12f1825751fffc148166b4f0ed46e7038 |
| --- /dev/null |
| +++ b/chrome/browser/managed_mode/managed_user_settings_service.h |
| @@ -0,0 +1,58 @@ |
| +// 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 |
|
Pam (message me for reviews)
2013/08/30 13:35:53
What does "with" mean here?
Bernhard Bauer
2013/08/30 14:54:27
It's the first parameter. "A callback whose first
Pam (message me for reviews)
2013/09/02 09:38:41
A little bulky, but it would be clearer.
Bernhard Bauer
2013/09/02 11:01:07
Done.
|
| + // 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); |
|
Pam (message me for reviews)
2013/08/30 13:35:53
Do we really need Yet Another Settings Notifier? A
Bernhard Bauer
2013/08/30 14:54:27
You mean in general, do we need a mechanism for th
Pam (message me for reviews)
2013/09/02 09:38:41
Will anything besides the PrefStore be subscribing
Bernhard Bauer
2013/09/02 11:01:07
The only other implementation is in tests. Testing
Bernhard Bauer
2013/09/04 09:29:05
Removed the abstract interface. The syncing code i
|
| + |
| + // Activates the service. This happens when the user is managed. |
| + void Activate(); |
| + |
| + protected: |
| + ManagedUserSettingsService(); |
| + virtual ~ManagedUserSettingsService(); |
| + |
| + // Sends the settings to all subscribers. |
|
Pam (message me for reviews)
2013/08/30 13:35:53
What triggers this? Sync?
Bernhard Bauer
2013/08/30 14:54:27
Yes. From the point of view of this class, the (no
|
| + void NotifySettingsChanged(); |
|
Pam (message me for reviews)
2013/08/30 13:35:53
If it does keep using callbacks, this should be re
Bernhard Bauer
2013/08/30 14:54:27
Done.
Pam (message me for reviews)
2013/09/02 09:38:41
I meant to avoid the word "notify", with all its N
Bernhard Bauer
2013/09/02 11:01:07
I like InformSubscribers! Done.
Pam (message me for reviews)
2013/09/03 10:45:32
CallSubscribersBack :)
Sorry, that's the cold meds
|
| + |
| + private: |
| + // Whether managed user settings are available. |
|
Pam (message me for reviews)
2013/08/30 13:35:53
What makes them available?
Bernhard Bauer
2013/08/30 14:54:27
The subclass has to load them from a Json file on
|
| + 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; |
| + |
| + scoped_ptr<base::DictionaryValue> GetSettingsIfActive(); |
|
Pam (message me for reviews)
2013/08/30 13:35:53
Comment please. (Mainly that it returns an empty d
Bernhard Bauer
2013/08/30 14:54:27
Done.
|
| + |
| + bool active_; |
| + |
| + std::vector<SettingsCallback> subscribers_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ManagedUserSettingsService); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SETTINGS_SERVICE_H_ |