| OLD | NEW |
| 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 "build/build_config.h" | 12 #include "build/build_config.h" |
| 12 #include "chrome/browser/profiles/profile_attributes_storage.h" | 13 #include "chrome/browser/profiles/profile_attributes_storage.h" |
| 13 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" | 14 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" |
| 14 | 15 |
| 15 #if defined(OS_CHROMEOS) | 16 #if defined(OS_CHROMEOS) |
| 16 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
| 17 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
| 18 #endif | 19 #endif |
| 19 | 20 |
| 20 class Profile; | 21 class Profile; |
| 21 | 22 |
| 22 namespace settings { | 23 namespace settings { |
| 23 | 24 |
| 24 class ProfileInfoHandler : public SettingsPageUIHandler, | 25 class ProfileInfoHandler : public SettingsPageUIHandler, |
| 25 #if defined(OS_CHROMEOS) | 26 #if defined(OS_CHROMEOS) |
| 26 public content::NotificationObserver, | 27 public content::NotificationObserver, |
| 27 #endif | 28 #endif |
| 28 public ProfileAttributesStorage::Observer { | 29 public ProfileAttributesStorage::Observer { |
| 29 public: | 30 public: |
| 30 static const char kProfileInfoChangedEventName[]; | 31 static const char kProfileInfoChangedEventName[]; |
| 31 | 32 |
| 32 explicit ProfileInfoHandler(Profile* profile); | 33 explicit ProfileInfoHandler(Profile* profile); |
| 33 ~ProfileInfoHandler() override {} | 34 ~ProfileInfoHandler() override; |
| 34 | 35 |
| 35 // SettingsPageUIHandler implementation. | 36 // SettingsPageUIHandler implementation. |
| 36 void RegisterMessages() override; | 37 void RegisterMessages() override; |
| 37 void OnJavascriptAllowed() override; | 38 void OnJavascriptAllowed() override; |
| 38 void OnJavascriptDisallowed() override; | 39 void OnJavascriptDisallowed() override; |
| 39 | 40 |
| 40 #if defined(OS_CHROMEOS) | 41 #if defined(OS_CHROMEOS) |
| 41 // content::NotificationObserver implementation. | 42 // content::NotificationObserver implementation. |
| 42 void Observe(int type, | 43 void Observe(int type, |
| 43 const content::NotificationSource& source, | 44 const content::NotificationSource& source, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 56 // Callbacks from the page. | 57 // Callbacks from the page. |
| 57 void HandleGetProfileInfo(const base::ListValue* args); | 58 void HandleGetProfileInfo(const base::ListValue* args); |
| 58 | 59 |
| 59 void PushProfileInfo(); | 60 void PushProfileInfo(); |
| 60 | 61 |
| 61 std::unique_ptr<base::DictionaryValue> GetAccountNameAndIcon() const; | 62 std::unique_ptr<base::DictionaryValue> GetAccountNameAndIcon() const; |
| 62 | 63 |
| 63 // Weak pointer. | 64 // Weak pointer. |
| 64 Profile* profile_; | 65 Profile* profile_; |
| 65 | 66 |
| 67 ScopedObserver<ProfileAttributesStorage, ProfileInfoHandler> |
| 68 profile_observer_; |
| 69 |
| 66 #if defined(OS_CHROMEOS) | 70 #if defined(OS_CHROMEOS) |
| 67 // Used to listen to ChromeOS user image changes. | 71 // Used to listen to ChromeOS user image changes. |
| 68 content::NotificationRegistrar registrar_; | 72 content::NotificationRegistrar registrar_; |
| 69 #endif | 73 #endif |
| 70 | 74 |
| 71 DISALLOW_COPY_AND_ASSIGN(ProfileInfoHandler); | 75 DISALLOW_COPY_AND_ASSIGN(ProfileInfoHandler); |
| 72 }; | 76 }; |
| 73 | 77 |
| 74 } // namespace settings | 78 } // namespace settings |
| 75 | 79 |
| 76 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_PROFILE_INFO_HANDLER_H_ | 80 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_PROFILE_INFO_HANDLER_H_ |
| OLD | NEW |