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

Side by Side Diff: chrome/browser/managed_mode/managed_user_settings_service.h

Issue 23466004: Add ManagedUserSettingsService and a SupervisedUserPrefStore using it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SETTINGS_SERVICE_H_
6 #define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SETTINGS_SERVICE_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/values.h"
15 #include "chrome/browser/managed_mode/managed_users.h"
16
17 // Defines an abstract base class for a service that stores managed user
18 // settings, which are key-value pairs configured by a different user to
19 // control certain browser behaviors for managed users.
20 // Setting names are defined in managed_user_settings.h.
21 class ManagedUserSettingsService {
22 public:
23 // A callback with all managed user settings. If the dictionary is NULL, it
24 // means that the service is inactive, i.e. the user is not managed.
25 typedef base::Callback<void(const base::DictionaryValue*)> SettingsCallback;
26
27 // Adds a callback to be called when managed user settings are initially
28 // available, or when they change.
29 void Subscribe(const SettingsCallback& callback);
30
31 // Activates the service. This happens when the user is managed.
32 void Activate();
33
34 protected:
35 ManagedUserSettingsService();
36 virtual ~ManagedUserSettingsService();
37
38 // Sends the settings to all subscribers. This method should be called by the
39 // subclass whenever the settings change.
40 void NotifySubscribers();
41
42 private:
43 // Whether managed user settings are available.
44 virtual bool IsReady() const = 0;
45
46 // Returns a dictionary with all managed user settings. This method will
47 // only be called once IsReady() returns true.
48 virtual scoped_ptr<base::DictionaryValue> GetSettings() const = 0;
49
50 // Returns the dictionary produced by GetSettings() above if the service is
51 // active, or NULL otherwise.
52 scoped_ptr<base::DictionaryValue> GetSettingsIfActive();
53
54 bool active_;
55
56 std::vector<SettingsCallback> subscribers_;
57
58 DISALLOW_COPY_AND_ASSIGN(ManagedUserSettingsService);
59 };
60
61 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SETTINGS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698