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

Side by Side Diff: chrome/browser/chromeos/login/users/avatar/user_image_sync_observer.h

Issue 2568973002: chromeos: Replace user image notifications with observer (Closed)
Patch Set: rebase Created 4 years 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 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 <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/observer_list.h" 11 #include "base/observer_list.h"
12 #include "components/sync_preferences/pref_service_syncable_observer.h" 12 #include "components/sync_preferences/pref_service_syncable_observer.h"
13 #include "components/user_manager/user_manager.h"
13 #include "content/public/browser/notification_observer.h" 14 #include "content/public/browser/notification_observer.h"
14 15
15 class PrefChangeRegistrar; 16 class PrefChangeRegistrar;
16 class Profile; 17 class Profile;
17 18
18 namespace content { 19 namespace content {
19 class NotificationRegistrar; 20 class NotificationRegistrar;
20 } 21 }
21 22
22 namespace sync_preferences { 23 namespace sync_preferences {
23 class PrefServiceSyncable; 24 class PrefServiceSyncable;
24 } 25 }
25 26
26 namespace user_prefs { 27 namespace user_prefs {
27 class PrefRegistrySyncable; 28 class PrefRegistrySyncable;
28 } 29 }
29 30
30 namespace user_manager { 31 namespace user_manager {
31 class User; 32 class User;
32 } 33 }
33 34
34 namespace chromeos { 35 namespace chromeos {
35 36
36 // This class is responsible for keeping local user image synced with 37 // This class is responsible for keeping local user image synced with
37 // image saved in syncable preference. 38 // image saved in syncable preference.
38 class UserImageSyncObserver 39 class UserImageSyncObserver
39 : public sync_preferences::PrefServiceSyncableObserver, 40 : public sync_preferences::PrefServiceSyncableObserver,
40 public content::NotificationObserver { 41 public content::NotificationObserver,
42 public user_manager::UserManager::Observer {
41 public: 43 public:
42 class Observer { 44 class Observer {
43 public: 45 public:
44 // Called right after image info synced (i.e. |is_synced| became |true|). 46 // Called right after image info synced (i.e. |is_synced| became |true|).
45 // |local_image_updated| indicates if we desided to update local image in 47 // |local_image_updated| indicates if we desided to update local image in
46 // result of sync. 48 // result of sync.
47 virtual void OnInitialSync(bool local_image_updated) = 0; 49 virtual void OnInitialSync(bool local_image_updated) = 0;
48 virtual ~Observer(); 50 virtual ~Observer();
49 }; 51 };
50 52
(...skipping 14 matching lines...) Expand all
65 67
66 private: 68 private:
67 // sync_preferences::PrefServiceSyncableObserver implementation. 69 // sync_preferences::PrefServiceSyncableObserver implementation.
68 void OnIsSyncingChanged() override; 70 void OnIsSyncingChanged() override;
69 71
70 // content::NotificationObserver implementation. 72 // content::NotificationObserver implementation.
71 void Observe(int type, 73 void Observe(int type,
72 const content::NotificationSource& source, 74 const content::NotificationSource& source,
73 const content::NotificationDetails& details) override; 75 const content::NotificationDetails& details) override;
74 76
77 // user_manager::UserManager::Observer implementation.
78 void OnUserImageChanged(const user_manager::User& user) override;
79
75 // Called after user profile was loaded. 80 // Called after user profile was loaded.
76 void OnProfileGained(Profile* profile); 81 void OnProfileGained(Profile* profile);
77 82
78 // Called when sync servise started it's work and we are able to sync needed 83 // Called when sync servise started it's work and we are able to sync needed
79 // preferences. 84 // preferences.
80 void OnInitialSync(); 85 void OnInitialSync();
81 86
82 // Called when preference |pref_name| was changed.j 87 // Called when preference |pref_name| was changed.j
83 void OnPreferenceChanged(const std::string& pref_name); 88 void OnPreferenceChanged(const std::string& pref_name);
84 89
(...skipping 16 matching lines...) Expand all
101 bool is_synced_; 106 bool is_synced_;
102 // Indicates if local user image changed during initialization. 107 // Indicates if local user image changed during initialization.
103 bool local_image_changed_; 108 bool local_image_changed_;
104 base::ObserverList<Observer> observer_list_; 109 base::ObserverList<Observer> observer_list_;
105 }; 110 };
106 111
107 } // namespace chromeos 112 } // namespace chromeos
108 113
109 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_SYNC_OBSERVER_H _ 114 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_SYNC_OBSERVER_H _
110 115
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698