OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SHARED_SETTINGS_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SHARED_SETTINGS_SERVICE_H _ |
6 #define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SHARED_SETTINGS_SERVICE_H_ | 6 #define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SHARED_SETTINGS_SERVICE_H _ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/callback_list.h" | 9 #include "base/callback_list.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "chrome/browser/managed_mode/managed_users.h" | 11 #include "chrome/browser/supervised_user/supervised_users.h" |
12 #include "components/keyed_service/core/keyed_service.h" | 12 #include "components/keyed_service/core/keyed_service.h" |
13 #include "sync/api/syncable_service.h" | 13 #include "sync/api/syncable_service.h" |
14 | 14 |
15 class PrefService; | 15 class PrefService; |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class DictionaryValue; | 18 class DictionaryValue; |
19 class Value; | 19 class Value; |
20 } | 20 } |
21 | 21 |
22 namespace user_prefs { | 22 namespace user_prefs { |
23 class PrefRegistrySyncable; | 23 class PrefRegistrySyncable; |
24 } | 24 } |
25 | 25 |
26 // ManagedUserSharedSettingsService syncs settings (as key-value pairs) that can | 26 // SupervisedUserSharedSettingsService syncs settings (as key-value pairs) that |
27 // be modified both by a supervised user and their manager. | 27 // can be modified both by a supervised user and their manager. |
28 // A supervised user can only modify their own settings, whereas a manager can | 28 // A supervised user can only modify their own settings, whereas a manager can |
29 // modify settings for all their supervised users. | 29 // modify settings for all their supervised users. |
30 // | 30 // |
31 // The shared settings are stored in the user preferences in a multi-level | 31 // The shared settings are stored in the user preferences in a multi-level |
32 // dictionary. The first level is the MU ID, the second level is the key for the | 32 // dictionary. The first level is the SU ID, the second level is the key for the |
Pam (message me for reviews)
2014/06/16 23:51:51
If I'm not mistaken, the entity on the server side
| |
33 // setting, and the third level is a dictionary with a "value" key for the value | 33 // setting, and the third level is a dictionary with a "value" key for the value |
34 // and an "acknowledged" flag, which is used to wait for the Sync server to | 34 // and an "acknowledged" flag, which is used to wait for the Sync server to |
35 // acknowledge that it has seen a setting change (see | 35 // acknowledge that it has seen a setting change (see |
36 // ManagedUserSharedSettingsUpdate for how to use this). | 36 // SupervisedUserSharedSettingsUpdate for how to use this). |
37 class ManagedUserSharedSettingsService : public KeyedService, | 37 class SupervisedUserSharedSettingsService : public KeyedService, |
38 public syncer::SyncableService { | 38 public syncer::SyncableService { |
39 public: | 39 public: |
40 // Called whenever a setting changes (see Subscribe() below). | 40 // Called whenever a setting changes (see Subscribe() below). |
41 typedef base::Callback<void(const std::string& /* mu_id */, | 41 typedef base::Callback<void(const std::string& /* mu_id */, |
42 const std::string& /* key */)> ChangeCallback; | 42 const std::string& /* key */)> ChangeCallback; |
43 typedef base::CallbackList< | 43 typedef base::CallbackList< |
44 void(const std::string& /* mu_id */, const std::string& /* key */)> | 44 void(const std::string& /* mu_id */, const std::string& /* key */)> |
45 ChangeCallbackList; | 45 ChangeCallbackList; |
46 | 46 |
47 // This constructor is public only for testing. Use | 47 // This constructor is public only for testing. Use |
48 // |ManagedUserSyncServiceFactory::GetForProfile(...)| instead to get an | 48 // |SupervisedUserSharedSettingsServiceFactory::GetForProfile(...)| instead to |
49 // instance of this service in production code. | 49 // get an instance of this service in production code. |
50 explicit ManagedUserSharedSettingsService(PrefService* prefs); | 50 explicit SupervisedUserSharedSettingsService(PrefService* prefs); |
51 virtual ~ManagedUserSharedSettingsService(); | 51 virtual ~SupervisedUserSharedSettingsService(); |
52 | 52 |
53 // Returns the value for the given |key| and the supervised user identified by | 53 // Returns the value for the given |key| and the supervised user identified by |
54 // |mu_id|. If either the supervised user or the key does not exist, NULL is | 54 // |mu_id|. If either the supervised user or the key does not exist, NULL is |
55 // returned. Note that if the profile that owns this service belongs to a | 55 // returned. Note that if the profile that owns this service belongs to a |
56 // supervised user, callers will only see settings for their own |mu_id|, i.e. | 56 // supervised user, callers will only see settings for their own |mu_id|, i.e. |
57 // a non-matching |mu_id| is treated as non-existent. | 57 // a non-matching |mu_id| is treated as non-existent. |
58 const base::Value* GetValue(const std::string& mu_id, const std::string& key); | 58 const base::Value* GetValue(const std::string& mu_id, const std::string& key); |
59 | 59 |
60 // Sets the value for the given |key| and the supervised user identified by | 60 // Sets the value for the given |key| and the supervised user identified by |
61 // |mu_id|. If the profile that owns this service belongs to a supervised | 61 // |mu_id|. If the profile that owns this service belongs to a supervised |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 friend class ManagedUserSharedSettingsUpdate; | 105 friend class ManagedUserSharedSettingsUpdate; |
106 | 106 |
107 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; | 107 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; |
108 scoped_ptr<syncer::SyncErrorFactory> error_handler_; | 108 scoped_ptr<syncer::SyncErrorFactory> error_handler_; |
109 | 109 |
110 ChangeCallbackList callbacks_; | 110 ChangeCallbackList callbacks_; |
111 | 111 |
112 PrefService* prefs_; | 112 PrefService* prefs_; |
113 }; | 113 }; |
114 | 114 |
115 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SHARED_SETTINGS_SERVICE_H_ | 115 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SHARED_SETTINGS_SERVIC E_H_ |
OLD | NEW |