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

Side by Side Diff: chrome/browser/supervised_user/legacy/supervised_user_sync_service.h

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
OLDNEW
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 "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"
15 #include "chrome/browser/supervised_user/supervised_users.h" 15 #include "chrome/browser/supervised_user/supervised_users.h"
16 #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" 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 namespace user_manager {
29 class UserID;
30 }
31
28 class PrefService; 32 class PrefService;
29 class Profile; 33 class Profile;
30 34
31 class SupervisedUserSyncService : public KeyedService, 35 class SupervisedUserSyncService : public KeyedService,
32 public SigninManagerBase::Observer, 36 public SigninManagerBase::Observer,
33 public syncer::SyncableService { 37 public syncer::SyncableService {
34 public: 38 public:
35 // For use with GetSupervisedUsersAsync() below. 39 // For use with GetSupervisedUsersAsync() below.
36 typedef base::Callback<void(const base::DictionaryValue*)> 40 typedef base::Callback<void(const base::DictionaryValue*)>
37 SupervisedUsersCallback; 41 SupervisedUsersCallback;
(...skipping 25 matching lines...) Expand all
63 int* avatar_index); 67 int* avatar_index);
64 68
65 // Given an |avatar_index|, it returns a string of the form: 69 // Given an |avatar_index|, it returns a string of the form:
66 // "chrome-avatar-index:INDEX" where INDEX = |avatar_index|. 70 // "chrome-avatar-index:INDEX" where INDEX = |avatar_index|.
67 // It is exposed for testing purposes only. 71 // It is exposed for testing purposes only.
68 static std::string BuildAvatarString(int avatar_index); 72 static std::string BuildAvatarString(int avatar_index);
69 73
70 void AddObserver(SupervisedUserSyncServiceObserver* observer); 74 void AddObserver(SupervisedUserSyncServiceObserver* observer);
71 void RemoveObserver(SupervisedUserSyncServiceObserver* observer); 75 void RemoveObserver(SupervisedUserSyncServiceObserver* observer);
72 76
73 void AddSupervisedUser(const std::string& id, 77 void AddSupervisedUser(const user_manager::UserID& id,
74 const std::string& name, 78 const std::string& name,
75 const std::string& master_key, 79 const std::string& master_key,
76 const std::string& signature_key, 80 const std::string& signature_key,
77 const std::string& encryption_key, 81 const std::string& encryption_key,
78 int avatar_index); 82 int avatar_index);
79 void UpdateSupervisedUser(const std::string& id, 83 void UpdateSupervisedUser(const user_manager::UserID& id,
80 const std::string& name, 84 const std::string& name,
81 const std::string& master_key, 85 const std::string& master_key,
82 const std::string& signature_key, 86 const std::string& signature_key,
83 const std::string& encryption_key, 87 const std::string& encryption_key,
84 int avatar_index); 88 int avatar_index);
85 89
86 void DeleteSupervisedUser(const std::string& id); 90 void DeleteSupervisedUser(const user_manager::UserID& id);
87 91
88 // Updates the supervised user avatar only if the supervised user has 92 // Updates the supervised user avatar only if the supervised user has
89 // no avatar and |avatar_index| is set to some value other than 93 // no avatar and |avatar_index| is set to some value other than
90 // |kNoAvatar|. If |avatar_index| equals |kNoAvatar| and the 94 // |kNoAvatar|. If |avatar_index| equals |kNoAvatar| and the
91 // supervised user has an avatar, it will be cleared. However, 95 // supervised user has an avatar, it will be cleared. However,
92 // to clear an avatar call the convenience method 96 // to clear an avatar call the convenience method
93 // |ClearSupervisedUserAvatar()|. 97 // |ClearSupervisedUserAvatar()|.
94 // Returns true if the avatar value is changed (either updated or cleared) 98 // Returns true if the avatar value is changed (either updated or cleared)
95 // and false otherwise. 99 // and false otherwise.
96 bool UpdateSupervisedUserAvatarIfNeeded(const std::string& id, 100 bool UpdateSupervisedUserAvatarIfNeeded(const user_manager::UserID& id,
97 int avatar_index); 101 int avatar_index);
98 void ClearSupervisedUserAvatar(const std::string& id); 102 void ClearSupervisedUserAvatar(const user_manager::UserID& id);
99 103
100 // Returns a dictionary containing all supervised users supervised by this 104 // Returns a dictionary containing all supervised users supervised by this
101 // custodian. This method should only be called once this service has started 105 // custodian. This method should only be called once this service has started
102 // syncing supervised users (i.e. has finished its initial merge of local and 106 // syncing supervised users (i.e. has finished its initial merge of local and
103 // server-side data, via MergeDataAndStartSyncing), as the stored data might 107 // server-side data, via MergeDataAndStartSyncing), as the stored data might
104 // be outdated before that. 108 // be outdated before that.
105 const base::DictionaryValue* GetSupervisedUsers(); 109 const base::DictionaryValue* GetSupervisedUsers();
106 110
107 // Calls the passed |callback| with a dictionary containing all supervised 111 // Calls the passed |callback| with a dictionary containing all supervised
108 // users managed by this custodian. 112 // users managed by this custodian.
(...skipping 25 matching lines...) Expand all
134 void GoogleSignedOut(const std::string& account_id, 138 void GoogleSignedOut(const std::string& account_id,
135 const std::string& username) override; 139 const std::string& username) override;
136 140
137 scoped_ptr<base::DictionaryValue> CreateDictionary( 141 scoped_ptr<base::DictionaryValue> CreateDictionary(
138 const std::string& name, 142 const std::string& name,
139 const std::string& master_key, 143 const std::string& master_key,
140 const std::string& signature_key, 144 const std::string& signature_key,
141 const std::string& encryption_key, 145 const std::string& encryption_key,
142 int avatar_index); 146 int avatar_index);
143 147
144 void UpdateSupervisedUserImpl(const std::string& id, 148 void UpdateSupervisedUserImpl(const user_manager::UserID& id,
145 const std::string& name, 149 const std::string& name,
146 const std::string& master_key, 150 const std::string& master_key,
147 const std::string& signature_key, 151 const std::string& signature_key,
148 const std::string& encryption_key, 152 const std::string& encryption_key,
149 int avatar_index, 153 int avatar_index,
150 bool add_user); 154 bool add_user);
151 155
152 void NotifySupervisedUserAcknowledged(const std::string& supervised_user_id); 156 void NotifySupervisedUserAcknowledged(const user_manager::UserID& supervised_u ser_id);
153 void NotifySupervisedUsersSyncingStopped(); 157 void NotifySupervisedUsersSyncingStopped();
154 void NotifySupervisedUsersChanged(); 158 void NotifySupervisedUsersChanged();
155 159
156 void DispatchCallbacks(); 160 void DispatchCallbacks();
157 161
158 Profile* profile_; 162 Profile* profile_;
159 PrefService* prefs_; 163 PrefService* prefs_;
160 164
161 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; 165 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
162 scoped_ptr<syncer::SyncErrorFactory> error_handler_; 166 scoped_ptr<syncer::SyncErrorFactory> error_handler_;
163 167
164 ObserverList<SupervisedUserSyncServiceObserver> observers_; 168 ObserverList<SupervisedUserSyncServiceObserver> observers_;
165 169
166 std::vector<SupervisedUsersCallback> callbacks_; 170 std::vector<SupervisedUsersCallback> callbacks_;
167 171
168 DISALLOW_COPY_AND_ASSIGN(SupervisedUserSyncService); 172 DISALLOW_COPY_AND_ASSIGN(SupervisedUserSyncService);
169 }; 173 };
170 174
171 #endif // CHROME_BROWSER_SUPERVISED_USER_LEGACY_SUPERVISED_USER_SYNC_SERVICE_H_ 175 #endif // CHROME_BROWSER_SUPERVISED_USER_LEGACY_SUPERVISED_USER_SYNC_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698