| OLD | NEW |
| 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_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_SYNC_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_SYNC_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_SYNC_OBSERVER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_SYNC_OBSERVER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 class Observer { | 36 class Observer { |
| 37 public: | 37 public: |
| 38 // Called right after image info synced (i.e. |is_synced| became |true|). | 38 // Called right after image info synced (i.e. |is_synced| became |true|). |
| 39 // |local_image_updated| indicates if we desided to update local image in | 39 // |local_image_updated| indicates if we desided to update local image in |
| 40 // result of sync. | 40 // result of sync. |
| 41 virtual void OnInitialSync(bool local_image_updated) = 0; | 41 virtual void OnInitialSync(bool local_image_updated) = 0; |
| 42 virtual ~Observer(); | 42 virtual ~Observer(); |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 public: | 45 public: |
| 46 explicit UserImageSyncObserver(const User* user); | 46 explicit UserImageSyncObserver(const user_manager::User* user); |
| 47 virtual ~UserImageSyncObserver(); | 47 virtual ~UserImageSyncObserver(); |
| 48 | 48 |
| 49 // Register syncable preference for profile. | 49 // Register syncable preference for profile. |
| 50 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 50 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 51 | 51 |
| 52 // Returns |true| if sync was initialized and prefs have actual state. | 52 // Returns |true| if sync was initialized and prefs have actual state. |
| 53 bool is_synced() const { return is_synced_; } | 53 bool is_synced() const { return is_synced_; } |
| 54 | 54 |
| 55 // Adds |observer| into observers list. | 55 // Adds |observer| into observers list. |
| 56 void AddObserver(Observer* observer); | 56 void AddObserver(Observer* observer); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 81 | 81 |
| 82 // Saves sync preferences to local state and updates user image. | 82 // Saves sync preferences to local state and updates user image. |
| 83 void UpdateLocalImageFromSynced(); | 83 void UpdateLocalImageFromSynced(); |
| 84 | 84 |
| 85 // Gets synced image index. Returns false if user has no needed preferences. | 85 // Gets synced image index. Returns false if user has no needed preferences. |
| 86 bool GetSyncedImageIndex(int* result); | 86 bool GetSyncedImageIndex(int* result); |
| 87 | 87 |
| 88 // If it is allowed to change user image now. | 88 // If it is allowed to change user image now. |
| 89 bool CanUpdateLocalImageNow(); | 89 bool CanUpdateLocalImageNow(); |
| 90 | 90 |
| 91 const User* user_; | 91 const user_manager::User* user_; |
| 92 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; | 92 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; |
| 93 scoped_ptr<content::NotificationRegistrar> notification_registrar_; | 93 scoped_ptr<content::NotificationRegistrar> notification_registrar_; |
| 94 PrefServiceSyncable* prefs_; | 94 PrefServiceSyncable* prefs_; |
| 95 bool is_synced_; | 95 bool is_synced_; |
| 96 // Indicates if local user image changed during initialization. | 96 // Indicates if local user image changed during initialization. |
| 97 bool local_image_changed_; | 97 bool local_image_changed_; |
| 98 ObserverList<Observer> observer_list_; | 98 ObserverList<Observer> observer_list_; |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 } // namespace chromeos | 101 } // namespace chromeos |
| 102 | 102 |
| 103 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_SYNC_OBSERVER_H
_ | 103 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_SYNC_OBSERVER_H
_ |
| 104 | 104 |
| OLD | NEW |