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_SUPERVISED_USER_LEGACY_SUPERVISED_USER_SYNC_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_LEGACY_SUPERVISED_USER_SYNC_SERVICE_H_ |
6 #define CHROME_BROWSER_SUPERVISED_USER_LEGACY_SUPERVISED_USER_SYNC_SERVICE_H_ | 6 #define CHROME_BROWSER_SUPERVISED_USER_LEGACY_SUPERVISED_USER_SYNC_SERVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "base/prefs/pref_change_registrar.h" | |
15 #include "chrome/browser/supervised_user/legacy/supervised_user_sync_service_obs
erver.h" | 14 #include "chrome/browser/supervised_user/legacy/supervised_user_sync_service_obs
erver.h" |
16 #include "chrome/browser/supervised_user/supervised_users.h" | 15 #include "chrome/browser/supervised_user/supervised_users.h" |
17 #include "components/keyed_service/core/keyed_service.h" | 16 #include "components/keyed_service/core/keyed_service.h" |
| 17 #include "components/signin/core/browser/signin_manager_base.h" |
18 #include "sync/api/syncable_service.h" | 18 #include "sync/api/syncable_service.h" |
19 | 19 |
20 namespace base { | 20 namespace base { |
21 class DictionaryValue; | 21 class DictionaryValue; |
22 } | 22 } |
23 | 23 |
24 namespace user_prefs { | 24 namespace user_prefs { |
25 class PrefRegistrySyncable; | 25 class PrefRegistrySyncable; |
26 } | 26 } |
27 | 27 |
28 class PrefService; | 28 class PrefService; |
| 29 class Profile; |
29 | 30 |
30 class SupervisedUserSyncService : public KeyedService, | 31 class SupervisedUserSyncService : public KeyedService, |
| 32 public SigninManagerBase::Observer, |
31 public syncer::SyncableService { | 33 public syncer::SyncableService { |
32 public: | 34 public: |
33 // For use with GetSupervisedUsersAsync() below. | 35 // For use with GetSupervisedUsersAsync() below. |
34 typedef base::Callback<void(const base::DictionaryValue*)> | 36 typedef base::Callback<void(const base::DictionaryValue*)> |
35 SupervisedUsersCallback; | 37 SupervisedUsersCallback; |
36 | 38 |
37 // Dictionary keys for entry values of |prefs::kSupervisedUsers|. | 39 // Dictionary keys for entry values of |prefs::kSupervisedUsers|. |
38 static const char kAcknowledged[]; | 40 static const char kAcknowledged[]; |
39 static const char kChromeAvatar[]; | 41 static const char kChromeAvatar[]; |
40 static const char kChromeOsAvatar[]; | 42 static const char kChromeOsAvatar[]; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; | 121 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; |
120 syncer::SyncError ProcessSyncChanges( | 122 syncer::SyncError ProcessSyncChanges( |
121 const tracked_objects::Location& from_here, | 123 const tracked_objects::Location& from_here, |
122 const syncer::SyncChangeList& change_list) override; | 124 const syncer::SyncChangeList& change_list) override; |
123 | 125 |
124 private: | 126 private: |
125 friend class SupervisedUserSyncServiceFactory; | 127 friend class SupervisedUserSyncServiceFactory; |
126 | 128 |
127 // Use |SupervisedUserSyncServiceFactory::GetForProfile(...)| to get an | 129 // Use |SupervisedUserSyncServiceFactory::GetForProfile(...)| to get an |
128 // instance of this service. | 130 // instance of this service. |
129 explicit SupervisedUserSyncService(PrefService* prefs); | 131 explicit SupervisedUserSyncService(Profile* profile); |
130 | 132 |
131 void OnLastSignedInUsernameChange(); | 133 // SigninManagerBase::Observer implementation. |
| 134 void GoogleSignedOut(const std::string& account_id, |
| 135 const std::string& username) override; |
132 | 136 |
133 scoped_ptr<base::DictionaryValue> CreateDictionary( | 137 scoped_ptr<base::DictionaryValue> CreateDictionary( |
134 const std::string& name, | 138 const std::string& name, |
135 const std::string& master_key, | 139 const std::string& master_key, |
136 const std::string& signature_key, | 140 const std::string& signature_key, |
137 const std::string& encryption_key, | 141 const std::string& encryption_key, |
138 int avatar_index); | 142 int avatar_index); |
139 | 143 |
140 void UpdateSupervisedUserImpl(const std::string& id, | 144 void UpdateSupervisedUserImpl(const std::string& id, |
141 const std::string& name, | 145 const std::string& name, |
142 const std::string& master_key, | 146 const std::string& master_key, |
143 const std::string& signature_key, | 147 const std::string& signature_key, |
144 const std::string& encryption_key, | 148 const std::string& encryption_key, |
145 int avatar_index, | 149 int avatar_index, |
146 bool add_user); | 150 bool add_user); |
147 | 151 |
148 void NotifySupervisedUserAcknowledged(const std::string& supervised_user_id); | 152 void NotifySupervisedUserAcknowledged(const std::string& supervised_user_id); |
149 void NotifySupervisedUsersSyncingStopped(); | 153 void NotifySupervisedUsersSyncingStopped(); |
150 void NotifySupervisedUsersChanged(); | 154 void NotifySupervisedUsersChanged(); |
151 | 155 |
152 void DispatchCallbacks(); | 156 void DispatchCallbacks(); |
153 | 157 |
| 158 Profile* profile_; |
154 PrefService* prefs_; | 159 PrefService* prefs_; |
155 PrefChangeRegistrar pref_change_registrar_; | |
156 | 160 |
157 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; | 161 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; |
158 scoped_ptr<syncer::SyncErrorFactory> error_handler_; | 162 scoped_ptr<syncer::SyncErrorFactory> error_handler_; |
159 | 163 |
160 ObserverList<SupervisedUserSyncServiceObserver> observers_; | 164 ObserverList<SupervisedUserSyncServiceObserver> observers_; |
161 | 165 |
162 std::vector<SupervisedUsersCallback> callbacks_; | 166 std::vector<SupervisedUsersCallback> callbacks_; |
163 | 167 |
164 DISALLOW_COPY_AND_ASSIGN(SupervisedUserSyncService); | 168 DISALLOW_COPY_AND_ASSIGN(SupervisedUserSyncService); |
165 }; | 169 }; |
166 | 170 |
167 #endif // CHROME_BROWSER_SUPERVISED_USER_LEGACY_SUPERVISED_USER_SYNC_SERVICE_H_ | 171 #endif // CHROME_BROWSER_SUPERVISED_USER_LEGACY_SUPERVISED_USER_SYNC_SERVICE_H_ |
OLD | NEW |