| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_PROFILE_INFO_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_PROFILE_INFO_HANDLER_H_ |
| 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "build/build_config.h" |
| 12 #include "chrome/browser/profiles/profile_attributes_storage.h" |
| 13 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" |
| 14 |
| 15 #if defined(OS_CHROMEOS) |
| 16 #include "content/public/browser/notification_observer.h" |
| 17 #include "content/public/browser/notification_registrar.h" |
| 18 #endif |
| 19 |
| 20 class Profile; |
| 21 |
| 22 namespace settings { |
| 23 |
| 24 class ProfileInfoHandler : public SettingsPageUIHandler, |
| 25 #if defined(OS_CHROMEOS) |
| 26 public content::NotificationObserver, |
| 27 #endif |
| 28 public ProfileAttributesStorage::Observer { |
| 29 public: |
| 30 static const char kProfileInfoChangedEventName[]; |
| 31 |
| 32 explicit ProfileInfoHandler(Profile* profile); |
| 33 ~ProfileInfoHandler() override {} |
| 34 |
| 35 // SettingsPageUIHandler implementation. |
| 36 void RegisterMessages() override; |
| 37 void RenderViewReused() override; |
| 38 |
| 39 #if defined(OS_CHROMEOS) |
| 40 // content::NotificationObserver implementation. |
| 41 void Observe(int type, |
| 42 const content::NotificationSource& source, |
| 43 const content::NotificationDetails& details) override; |
| 44 #endif |
| 45 |
| 46 // ProfileAttributesStorage::Observer implementation. |
| 47 void OnProfileNameChanged(const base::FilePath& profile_path, |
| 48 const base::string16& old_profile_name) override; |
| 49 void OnProfileAvatarChanged(const base::FilePath& profile_path) override; |
| 50 |
| 51 private: |
| 52 FRIEND_TEST_ALL_PREFIXES(ProfileInfoHandlerTest, GetProfileInfo); |
| 53 FRIEND_TEST_ALL_PREFIXES(ProfileInfoHandlerTest, PushProfileInfo); |
| 54 |
| 55 // Callbacks from the page. |
| 56 void HandleGetProfileInfo(const base::ListValue* args); |
| 57 |
| 58 void PushProfileInfo(); |
| 59 |
| 60 std::unique_ptr<base::DictionaryValue> GetAccountNameAndIcon() const; |
| 61 |
| 62 // Weak pointer. |
| 63 Profile* profile_; |
| 64 |
| 65 #if defined(OS_CHROMEOS) |
| 66 // Used to listen to ChromeOS user image changes. |
| 67 content::NotificationRegistrar registrar_; |
| 68 #endif |
| 69 |
| 70 bool observers_registered_; |
| 71 |
| 72 DISALLOW_COPY_AND_ASSIGN(ProfileInfoHandler); |
| 73 }; |
| 74 |
| 75 } // namespace settings |
| 76 |
| 77 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_PROFILE_INFO_HANDLER_H_ |
| OLD | NEW |