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

Side by Side Diff: chrome/browser/ui/webui/settings/profile_info_handler.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_UI_WEBUI_SETTINGS_PROFILE_INFO_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_PROFILE_INFO_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_PROFILE_INFO_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_PROFILE_INFO_HANDLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/scoped_observer.h" 11 #include "base/scoped_observer.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "chrome/browser/profiles/profile_attributes_storage.h" 13 #include "chrome/browser/profiles/profile_attributes_storage.h"
14 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" 14 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
15 #include "components/prefs/pref_change_registrar.h" 15 #include "components/prefs/pref_change_registrar.h"
16 16
17 #if defined(OS_CHROMEOS) 17 #if defined(OS_CHROMEOS)
18 #include "content/public/browser/notification_observer.h" 18 #include "components/user_manager/user_manager.h"
19 #include "content/public/browser/notification_registrar.h"
20 #endif 19 #endif
21 20
22 class Profile; 21 class Profile;
23 22
24 namespace settings { 23 namespace settings {
25 24
26 class ProfileInfoHandler : public SettingsPageUIHandler, 25 class ProfileInfoHandler : public SettingsPageUIHandler,
27 #if defined(OS_CHROMEOS) 26 #if defined(OS_CHROMEOS)
28 public content::NotificationObserver, 27 public user_manager::UserManager::Observer,
29 #endif 28 #endif
30 public ProfileAttributesStorage::Observer { 29 public ProfileAttributesStorage::Observer {
31 public: 30 public:
32 static const char kProfileInfoChangedEventName[]; 31 static const char kProfileInfoChangedEventName[];
33 static const char kProfileManagesSupervisedUsersChangedEventName[]; 32 static const char kProfileManagesSupervisedUsersChangedEventName[];
34 33
35 explicit ProfileInfoHandler(Profile* profile); 34 explicit ProfileInfoHandler(Profile* profile);
36 ~ProfileInfoHandler() override; 35 ~ProfileInfoHandler() override;
37 36
38 // SettingsPageUIHandler implementation. 37 // SettingsPageUIHandler implementation.
39 void RegisterMessages() override; 38 void RegisterMessages() override;
40 void OnJavascriptAllowed() override; 39 void OnJavascriptAllowed() override;
41 void OnJavascriptDisallowed() override; 40 void OnJavascriptDisallowed() override;
42 41
43 #if defined(OS_CHROMEOS) 42 #if defined(OS_CHROMEOS)
44 // content::NotificationObserver implementation. 43 // user_manager::UserManager::Observer implementation.
45 void Observe(int type, 44 void OnUserImageChanged(const user_manager::User& user) override;
46 const content::NotificationSource& source,
47 const content::NotificationDetails& details) override;
48 #endif 45 #endif
49 46
50 // ProfileAttributesStorage::Observer implementation. 47 // ProfileAttributesStorage::Observer implementation.
51 void OnProfileNameChanged(const base::FilePath& profile_path, 48 void OnProfileNameChanged(const base::FilePath& profile_path,
52 const base::string16& old_profile_name) override; 49 const base::string16& old_profile_name) override;
53 void OnProfileAvatarChanged(const base::FilePath& profile_path) override; 50 void OnProfileAvatarChanged(const base::FilePath& profile_path) override;
54 51
55 private: 52 private:
56 FRIEND_TEST_ALL_PREFIXES(ProfileInfoHandlerTest, GetProfileInfo); 53 FRIEND_TEST_ALL_PREFIXES(ProfileInfoHandlerTest, GetProfileInfo);
57 FRIEND_TEST_ALL_PREFIXES(ProfileInfoHandlerTest, PushProfileInfo); 54 FRIEND_TEST_ALL_PREFIXES(ProfileInfoHandlerTest, PushProfileInfo);
(...skipping 18 matching lines...) Expand all
76 73
77 // Weak pointer. 74 // Weak pointer.
78 Profile* profile_; 75 Profile* profile_;
79 76
80 ScopedObserver<ProfileAttributesStorage, ProfileInfoHandler> 77 ScopedObserver<ProfileAttributesStorage, ProfileInfoHandler>
81 profile_observer_; 78 profile_observer_;
82 79
83 // Used to listen for changes in the list of managed supervised users. 80 // Used to listen for changes in the list of managed supervised users.
84 PrefChangeRegistrar profile_pref_registrar_; 81 PrefChangeRegistrar profile_pref_registrar_;
85 82
86 #if defined(OS_CHROMEOS)
87 // Used to listen to ChromeOS user image changes.
88 content::NotificationRegistrar registrar_;
89 #endif
90
91 DISALLOW_COPY_AND_ASSIGN(ProfileInfoHandler); 83 DISALLOW_COPY_AND_ASSIGN(ProfileInfoHandler);
92 }; 84 };
93 85
94 } // namespace settings 86 } // namespace settings
95 87
96 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_PROFILE_INFO_HANDLER_H_ 88 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_PROFILE_INFO_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698