| 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 15 matching lines...) Expand all Loading... |
| 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 static const char kAcknowledged[]; |
| 37 static const char kChromeAvatar[]; |
| 38 static const char kChromeOsAvatar[]; |
| 39 static const char kName[]; |
| 40 static const char kMasterKey[]; |
| 41 |
| 36 virtual ~ManagedUserSyncService(); | 42 virtual ~ManagedUserSyncService(); |
| 37 | 43 |
| 38 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 44 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 39 | 45 |
| 46 // Extracts the avatar index from the input |avatar_str| and set |
| 47 // |avatar_index| to hold the extracted value. Returns true if the |
| 48 // index was extracted successfully and false otherwise. |
| 49 // |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 // in case there is no avatar synced for a managed user in which case |
| 52 // |avatar_index| is set to -1. |
| 53 static bool GetAvatarIndex(const std::string& avatar_str, int* avatar_index); |
| 54 |
| 55 // Given an |avatar_index|, it returns a string of the form: |
| 56 // "chrome-avatar-index:INDEX" where INDEX = |avatar_index|. |
| 57 // It is exposed for testing purposes only. |
| 58 static std::string BuildAvatarString(int avatar_index); |
| 59 |
| 40 void AddObserver(ManagedUserSyncServiceObserver* observer); | 60 void AddObserver(ManagedUserSyncServiceObserver* observer); |
| 41 void RemoveObserver(ManagedUserSyncServiceObserver* observer); | 61 void RemoveObserver(ManagedUserSyncServiceObserver* observer); |
| 42 | 62 |
| 43 void AddManagedUser(const std::string& id, | 63 void AddManagedUser(const std::string& id, |
| 44 const std::string& name, | 64 const std::string& name, |
| 45 const std::string& master_key, | 65 const std::string& master_key, |
| 46 int avatar_index); | 66 int avatar_index); |
| 47 void DeleteManagedUser(const std::string& id); | 67 void DeleteManagedUser(const std::string& id); |
| 48 | 68 |
| 49 // Returns a dictionary containing all managed users managed by this | 69 // Returns a dictionary containing all managed users managed by this |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 scoped_ptr<syncer::SyncErrorFactory> error_handler_; | 114 scoped_ptr<syncer::SyncErrorFactory> error_handler_; |
| 95 | 115 |
| 96 ObserverList<ManagedUserSyncServiceObserver> observers_; | 116 ObserverList<ManagedUserSyncServiceObserver> observers_; |
| 97 | 117 |
| 98 std::vector<ManagedUsersCallback> callbacks_; | 118 std::vector<ManagedUsersCallback> callbacks_; |
| 99 | 119 |
| 100 DISALLOW_COPY_AND_ASSIGN(ManagedUserSyncService); | 120 DISALLOW_COPY_AND_ASSIGN(ManagedUserSyncService); |
| 101 }; | 121 }; |
| 102 | 122 |
| 103 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SYNC_SERVICE_H_ | 123 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SYNC_SERVICE_H_ |
| OLD | NEW |