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; |
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); |
| 69 void UpdateManagedUserAvatar(const std::string& id, int avatar_index); |
| 70 void ClearManagedUserAvatar(const std::string& id); |
68 | 71 |
69 // Returns a dictionary containing all managed users managed by this | 72 // Returns a dictionary containing all managed users managed by this |
70 // custodian. This method should only be called once this service has started | 73 // 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 | 74 // syncing managed users (i.e. has finished its initial merge of local and |
72 // server-side data, via MergeDataAndStartSyncing), as the stored data might | 75 // server-side data, via MergeDataAndStartSyncing), as the stored data might |
73 // be outdated before that. | 76 // be outdated before that. |
74 const base::DictionaryValue* GetManagedUsers(); | 77 const base::DictionaryValue* GetManagedUsers(); |
75 | 78 |
76 // Calls the passed |callback| with a dictionary containing all managed users | 79 // Calls the passed |callback| with a dictionary containing all managed users |
77 // managed by this custodian. | 80 // managed by this custodian. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 scoped_ptr<syncer::SyncErrorFactory> error_handler_; | 117 scoped_ptr<syncer::SyncErrorFactory> error_handler_; |
115 | 118 |
116 ObserverList<ManagedUserSyncServiceObserver> observers_; | 119 ObserverList<ManagedUserSyncServiceObserver> observers_; |
117 | 120 |
118 std::vector<ManagedUsersCallback> callbacks_; | 121 std::vector<ManagedUsersCallback> callbacks_; |
119 | 122 |
120 DISALLOW_COPY_AND_ASSIGN(ManagedUserSyncService); | 123 DISALLOW_COPY_AND_ASSIGN(ManagedUserSyncService); |
121 }; | 124 }; |
122 | 125 |
123 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SYNC_SERVICE_H_ | 126 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SYNC_SERVICE_H_ |
OLD | NEW |