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

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

Issue 23691045: Update managed user registration to allow updating the avatar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bauerb@+ 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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_SYNC_SERVICE_H_ 5 #ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SYNC_SERVICE_H_
6 #define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SYNC_SERVICE_H_ 6 #define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SYNC_SERVICE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
(...skipping 15 matching lines...) Expand all
26 26
27 class PrefService; 27 class PrefService;
28 28
29 class ManagedUserSyncService : public BrowserContextKeyedService, 29 class ManagedUserSyncService : public BrowserContextKeyedService,
30 public syncer::SyncableService { 30 public syncer::SyncableService {
31 public: 31 public:
32 // For use with GetAllManagedUsers() below. 32 // For use with GetAllManagedUsers() below.
33 typedef base::Callback<void(const base::DictionaryValue*)> 33 typedef base::Callback<void(const base::DictionaryValue*)>
34 ManagedUsersCallback; 34 ManagedUsersCallback;
35 35
36 // Dictionary keys for entry values of |prefs::kManagedUsers|.
36 static const char kAcknowledged[]; 37 static const char kAcknowledged[];
37 static const char kChromeAvatar[]; 38 static const char kChromeAvatar[];
38 static const char kChromeOsAvatar[]; 39 static const char kChromeOsAvatar[];
40 static const char kMasterKey[];
39 static const char kName[]; 41 static const char kName[];
40 static const char kMasterKey[]; 42
43 // Represents a non-existing avatar on Chrome and Chrome OS.
44 static const int kNoAvatar;
41 45
42 virtual ~ManagedUserSyncService(); 46 virtual ~ManagedUserSyncService();
43 47
44 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 48 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
45 49
46 // Extracts the avatar index from the input |avatar_str| and set 50 // Extracts the avatar index from the input |avatar_str| and set
47 // |avatar_index| to hold the extracted value. Returns true if the 51 // |avatar_index| to hold the extracted value. Returns true if the
48 // index was extracted successfully and false otherwise. 52 // index was extracted successfully and false otherwise.
49 // |avatar_str| should have the format: "chrome-avatar-index:INDEX" 53 // |avatar_str| should have the format: "chrome-avatar-index:INDEX"
50 // where INDEX is the integer to be extracted. |avatar_str| can be empty 54 // where INDEX is the integer to be extracted. |avatar_str| can be empty
51 // in case there is no avatar synced for a managed user in which case 55 // in case there is no avatar synced for a managed user in which case
52 // |avatar_index| is set to -1. 56 // |avatar_index| is set to -1.
53 static bool GetAvatarIndex(const std::string& avatar_str, int* avatar_index); 57 static bool GetAvatarIndex(const std::string& avatar_str, int* avatar_index);
54 58
55 // Given an |avatar_index|, it returns a string of the form: 59 // Given an |avatar_index|, it returns a string of the form:
56 // "chrome-avatar-index:INDEX" where INDEX = |avatar_index|. 60 // "chrome-avatar-index:INDEX" where INDEX = |avatar_index|.
57 // It is exposed for testing purposes only. 61 // It is exposed for testing purposes only.
58 static std::string BuildAvatarString(int avatar_index); 62 static std::string BuildAvatarString(int avatar_index);
59 63
60 void AddObserver(ManagedUserSyncServiceObserver* observer); 64 void AddObserver(ManagedUserSyncServiceObserver* observer);
61 void RemoveObserver(ManagedUserSyncServiceObserver* observer); 65 void RemoveObserver(ManagedUserSyncServiceObserver* observer);
62 66
63 void AddManagedUser(const std::string& id, 67 void AddManagedUser(const std::string& id,
64 const std::string& name, 68 const std::string& name,
65 const std::string& master_key, 69 const std::string& master_key,
66 int avatar_index); 70 int avatar_index);
67 void DeleteManagedUser(const std::string& id); 71 void DeleteManagedUser(const std::string& id);
68 72
73 // Updates the managed user avatar only if the managed user has
74 // no avatar and |avatar_index| is set to some value other than
75 // |kNoAvatar|. If |avatar_index| equals |kNoAvatar| and the
76 // managed user has an avatar, it will be cleared. However,
77 // to clear an avatar call the convenience method |ClearManagedUserAvatar()|.
78 // Returns true if the avatar value is changed (either updated or cleared)
79 // and false otherwise.
80 bool UpdateManagedUserAvatarIfNeeded(const std::string& id, int avatar_index);
81 void ClearManagedUserAvatar(const std::string& id);
82
69 // Returns a dictionary containing all managed users managed by this 83 // Returns a dictionary containing all managed users managed by this
70 // custodian. This method should only be called once this service has started 84 // custodian. This method should only be called once this service has started
71 // syncing managed users (i.e. has finished its initial merge of local and 85 // syncing managed users (i.e. has finished its initial merge of local and
72 // server-side data, via MergeDataAndStartSyncing), as the stored data might 86 // server-side data, via MergeDataAndStartSyncing), as the stored data might
73 // be outdated before that. 87 // be outdated before that.
74 const base::DictionaryValue* GetManagedUsers(); 88 const base::DictionaryValue* GetManagedUsers();
75 89
76 // Calls the passed |callback| with a dictionary containing all managed users 90 // Calls the passed |callback| with a dictionary containing all managed users
77 // managed by this custodian. 91 // managed by this custodian.
78 void GetManagedUsersAsync(const ManagedUsersCallback& callback); 92 void GetManagedUsersAsync(const ManagedUsersCallback& callback);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 scoped_ptr<syncer::SyncErrorFactory> error_handler_; 128 scoped_ptr<syncer::SyncErrorFactory> error_handler_;
115 129
116 ObserverList<ManagedUserSyncServiceObserver> observers_; 130 ObserverList<ManagedUserSyncServiceObserver> observers_;
117 131
118 std::vector<ManagedUsersCallback> callbacks_; 132 std::vector<ManagedUsersCallback> callbacks_;
119 133
120 DISALLOW_COPY_AND_ASSIGN(ManagedUserSyncService); 134 DISALLOW_COPY_AND_ASSIGN(ManagedUserSyncService);
121 }; 135 };
122 136
123 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SYNC_SERVICE_H_ 137 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SYNC_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698