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

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

Issue 123293003: Add ManagedUserSharedSettingsService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 years, 11 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_SHARED_SETTINGS_SERVICE_H_
6 #define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SHARED_SETTINGS_SERVICE_H_
7
8 #include "base/callback.h"
9 #include "base/callback_list.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/managed_mode/managed_users.h"
12 #include "components/browser_context_keyed_service/browser_context_keyed_service .h"
13 #include "sync/api/syncable_service.h"
14
15 class PrefService;
16
17 namespace base {
18 class DictionaryValue;
19 class Value;
20 }
21
22 namespace user_prefs {
23 class PrefRegistrySyncable;
24 }
25
26 // ManagedUserSharedSettingsService syncs settings (as key-value pairs) that can
27 // be modified both by a supervised user and their manager.
28 // A supervised user can only modify their own settings, whereas a manager can
29 // modify settings for all their supervised users.
30 class ManagedUserSharedSettingsService : public BrowserContextKeyedService,
31 public syncer::SyncableService {
32 public:
33 typedef base::Callback<void(const std::string& /* mu_id */,
Pam (message me for reviews) 2014/01/08 10:30:40 A comment saying that this is called with settings
Bernhard Bauer 2014/01/08 11:42:04 Done.
34 const std::string& /* key */)> Callback;
35 typedef base::CallbackList<void(const std::string& /* mu_id */,
36 const std::string& /* key */)> CallbackList;
37
38 // Public for testing. Use |ManagedUserSyncServiceFactory::GetForProfile(...)|
39 // to get an instance of this service.
Pam (message me for reviews) 2014/01/08 10:30:40 It's not clear from this comment whether the secon
Bernhard Bauer 2014/01/08 11:42:04 Done.
40 explicit ManagedUserSharedSettingsService(PrefService* prefs);
41 virtual ~ManagedUserSharedSettingsService();
42
43 // Returns the value for the given |key| and the supervised user identified by
44 // |mu_id|. If either the supervised user or the key does not exist, NULL is
45 // returned. Note that a supervised user will only see settings for their own
46 // |mu_id|.
Pam (message me for reviews) 2014/01/08 10:30:40 For complete clarity, something like Returns the
Bernhard Bauer 2014/01/08 11:42:04 Well, the "must be their own" part isn't entirely
47 const base::Value* GetValue(const std::string& mu_id, const std::string& key);
48
49 // Sets the value for the given |key| and the supervised user identified by
50 // |mu_id|. If the profile that owns this service belongs to a supervised
51 // user, |mu_id| must be their own.
52 void SetValue(const std::string& mu_id,
53 const std::string& key,
54 const base::Value& value);
55
56 // Subscribes to changes in the synced settings. The callback will be notified
57 // whenever any setting for any supervised user is changed via Sync (but not
58 // for local changes). Subscribers should filter the settings and users they
59 // are interested in with the |mu_id| and |key| parameters to the callback.
60 scoped_ptr<CallbackList::Subscription> Subscribe(const Callback& cb);
61
62 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
63
64 // Public for testing.
65 void SetValueInternal(const std::string& mu_id,
Pam (message me for reviews) 2014/01/08 10:30:40 I remember seeing some announcement about naming p
Bernhard Bauer 2014/01/08 11:42:04 There is indeed such a presubmit check, but it is
Pam (message me for reviews) 2014/01/08 12:19:28 Agreed. I reviewed the .h before the .cc and didn'
66 const std::string& key,
67 const base::Value& value,
68 bool acknowledged);
69
70 // Public for testing.
71 static syncer::SyncData CreateSyncDataForSetting(const std::string& mu_id,
72 const std::string& key,
73 const base::Value& value,
74 bool acknowledged);
75
76 // BrowserContextKeyedService implementation:
77 virtual void Shutdown() OVERRIDE;
78
79 // SyncableService implementation:
80 virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
81 syncer::ModelType type,
82 const syncer::SyncDataList& initial_sync_data,
83 scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
84 scoped_ptr<syncer::SyncErrorFactory> error_handler) OVERRIDE;
85 virtual void StopSyncing(syncer::ModelType type) OVERRIDE;
86 virtual syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const
87 OVERRIDE;
88 virtual syncer::SyncError ProcessSyncChanges(
89 const tracked_objects::Location& from_here,
90 const syncer::SyncChangeList& change_list) OVERRIDE;
91
92 private:
93 friend class ManagedUserSharedSettingsUpdate;
94
95 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
96 scoped_ptr<syncer::SyncErrorFactory> error_handler_;
97
98 CallbackList callbacks_;
99
100 PrefService* prefs_;
101 };
102
103 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SHARED_SETTINGS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698