Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 18 matching lines...) Expand all Loading... | |
| 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 static const char kAcknowledged[]; | 36 static const char kAcknowledged[]; |
| 37 static const char kChromeAvatar[]; | 37 static const char kChromeAvatar[]; |
| 38 static const char kChromeOsAvatar[]; | 38 static const char kChromeOsAvatar[]; |
| 39 static const char kMasterKey[]; | |
| 39 static const char kName[]; | 40 static const char kName[]; |
| 40 static const char kMasterKey[]; | 41 static const int kNoAvatar; |
|
Bernhard Bauer
2013/09/13 20:17:24
Some grouping comments would be nice (in particula
ibra
2013/09/16 08:59:09
Done.
| |
| 41 | 42 |
| 42 virtual ~ManagedUserSyncService(); | 43 virtual ~ManagedUserSyncService(); |
| 43 | 44 |
| 44 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 45 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 45 | 46 |
| 46 // Extracts the avatar index from the input |avatar_str| and set | 47 // Extracts the avatar index from the input |avatar_str| and set |
| 47 // |avatar_index| to hold the extracted value. Returns true if the | 48 // |avatar_index| to hold the extracted value. Returns true if the |
| 48 // index was extracted successfully and false otherwise. | 49 // index was extracted successfully and false otherwise. |
| 49 // |avatar_str| should have the format: "chrome-avatar-index:INDEX" | 50 // |avatar_str| should have the format: "chrome-avatar-index:INDEX" |
| 50 // where INDEX is the integer to be extracted. |avatar_str| can be empty | 51 // 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 | 52 // in case there is no avatar synced for a managed user in which case |
| 52 // |avatar_index| is set to -1. | 53 // |avatar_index| is set to -1. |
| 53 static bool GetAvatarIndex(const std::string& avatar_str, int* avatar_index); | 54 static bool GetAvatarIndex(const std::string& avatar_str, int* avatar_index); |
| 54 | 55 |
| 55 // Given an |avatar_index|, it returns a string of the form: | 56 // Given an |avatar_index|, it returns a string of the form: |
| 56 // "chrome-avatar-index:INDEX" where INDEX = |avatar_index|. | 57 // "chrome-avatar-index:INDEX" where INDEX = |avatar_index|. |
| 57 // It is exposed for testing purposes only. | 58 // It is exposed for testing purposes only. |
| 58 static std::string BuildAvatarString(int avatar_index); | 59 static std::string BuildAvatarString(int avatar_index); |
| 59 | 60 |
| 60 void AddObserver(ManagedUserSyncServiceObserver* observer); | 61 void AddObserver(ManagedUserSyncServiceObserver* observer); |
| 61 void RemoveObserver(ManagedUserSyncServiceObserver* observer); | 62 void RemoveObserver(ManagedUserSyncServiceObserver* observer); |
| 62 | 63 |
| 63 void AddManagedUser(const std::string& id, | 64 void AddManagedUser(const std::string& id, |
| 64 const std::string& name, | 65 const std::string& name, |
| 65 const std::string& master_key, | 66 const std::string& master_key, |
| 66 int avatar_index); | 67 int avatar_index); |
| 67 void DeleteManagedUser(const std::string& id); | 68 void DeleteManagedUser(const std::string& id); |
| 68 | 69 |
| 70 // Updates the managed user avatar only if the managed user has | |
| 71 // no avatar and |avatar_index| is set to some value other than | |
| 72 // |kNoAvatar|. If |avatar_index| equals |kNoAvatar| and the | |
| 73 // managed user has an avatar, it will be cleared. | |
|
Bernhard Bauer
2013/09/13 20:17:24
Hm, this makes ClearManagedUserAvatar() basically
ibra
2013/09/16 08:59:09
Done.
| |
| 74 // Returns true if the avatar value is changed (either updated or cleared) | |
| 75 // and false otherwise. | |
| 76 bool UpdateManagedUserAvatarIfNeeded(const std::string& id, int avatar_index); | |
| 77 void ClearManagedUserAvatar(const std::string& id); | |
| 78 | |
| 69 // Returns a dictionary containing all managed users managed by this | 79 // Returns a dictionary containing all managed users managed by this |
| 70 // custodian. This method should only be called once this service has started | 80 // 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 | 81 // syncing managed users (i.e. has finished its initial merge of local and |
| 72 // server-side data, via MergeDataAndStartSyncing), as the stored data might | 82 // server-side data, via MergeDataAndStartSyncing), as the stored data might |
| 73 // be outdated before that. | 83 // be outdated before that. |
| 74 const base::DictionaryValue* GetManagedUsers(); | 84 const base::DictionaryValue* GetManagedUsers(); |
| 75 | 85 |
| 76 // Calls the passed |callback| with a dictionary containing all managed users | 86 // Calls the passed |callback| with a dictionary containing all managed users |
| 77 // managed by this custodian. | 87 // managed by this custodian. |
| 78 void GetManagedUsersAsync(const ManagedUsersCallback& callback); | 88 void GetManagedUsersAsync(const ManagedUsersCallback& callback); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 scoped_ptr<syncer::SyncErrorFactory> error_handler_; | 124 scoped_ptr<syncer::SyncErrorFactory> error_handler_; |
| 115 | 125 |
| 116 ObserverList<ManagedUserSyncServiceObserver> observers_; | 126 ObserverList<ManagedUserSyncServiceObserver> observers_; |
| 117 | 127 |
| 118 std::vector<ManagedUsersCallback> callbacks_; | 128 std::vector<ManagedUsersCallback> callbacks_; |
| 119 | 129 |
| 120 DISALLOW_COPY_AND_ASSIGN(ManagedUserSyncService); | 130 DISALLOW_COPY_AND_ASSIGN(ManagedUserSyncService); |
| 121 }; | 131 }; |
| 122 | 132 |
| 123 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SYNC_SERVICE_H_ | 133 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SYNC_SERVICE_H_ |
| OLD | NEW |