| 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_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/profiles/profile_info_cache_observer.h" | 8 #include "chrome/browser/profiles/profile_info_cache_observer.h" |
| 9 #include "components/signin/core/browser/signin_error_controller.h" |
| 9 #include "ui/views/controls/button/menu_button.h" | 10 #include "ui/views/controls/button/menu_button.h" |
| 10 | 11 |
| 11 class Browser; | 12 class Browser; |
| 12 | 13 |
| 13 // Avatar button that displays the active profile's name in the caption area. | 14 // Avatar button that displays the active profile's name in the caption area. |
| 14 class NewAvatarButton : public views::MenuButton, | 15 class NewAvatarButton : public views::MenuButton, |
| 15 public ProfileInfoCacheObserver { | 16 public ProfileInfoCacheObserver, |
| 17 public SigninErrorController::Observer { |
| 16 public: | 18 public: |
| 17 // Different button styles that can be applied. | 19 // Different button styles that can be applied. |
| 18 enum AvatarButtonStyle { | 20 enum AvatarButtonStyle { |
| 19 THEMED_BUTTON, // Used in a themed browser window. | 21 THEMED_BUTTON, // Used in a themed browser window. |
| 20 NATIVE_BUTTON, // Used in a native aero or metro window. | 22 NATIVE_BUTTON, // Used in a native aero or metro window. |
| 21 }; | 23 }; |
| 22 | 24 |
| 23 NewAvatarButton(views::ButtonListener* listener, | 25 NewAvatarButton(views::ButtonListener* listener, |
| 24 const base::string16& profile_name, | 26 const base::string16& profile_name, |
| 25 AvatarButtonStyle button_style, | 27 AvatarButtonStyle button_style, |
| 26 Browser* browser); | 28 Browser* browser); |
| 27 virtual ~NewAvatarButton(); | 29 virtual ~NewAvatarButton(); |
| 28 | 30 |
| 29 // views::View: | 31 // views::TextButton: |
| 30 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 32 virtual void OnPaintText(gfx::Canvas* canvas, PaintButtonMode mode) OVERRIDE; |
| 31 | 33 |
| 32 private: | 34 private: |
| 33 friend class NewAvatarMenuButtonTest; | 35 friend class NewAvatarMenuButtonTest; |
| 34 friend class ProfileChooserViewBrowserTest; | 36 friend class ProfileChooserViewBrowserTest; |
| 35 FRIEND_TEST_ALL_PREFIXES(NewAvatarMenuButtonTest, SignOut); | 37 FRIEND_TEST_ALL_PREFIXES(NewAvatarMenuButtonTest, SignOut); |
| 36 FRIEND_TEST_ALL_PREFIXES(ProfileChooserViewBrowserTest, ViewProfileUMA); | 38 FRIEND_TEST_ALL_PREFIXES(ProfileChooserViewBrowserTest, ViewProfileUMA); |
| 37 | 39 |
| 38 // ProfileInfoCacheObserver: | 40 // ProfileInfoCacheObserver: |
| 39 virtual void OnProfileAdded(const base::FilePath& profile_path) OVERRIDE; | 41 virtual void OnProfileAdded(const base::FilePath& profile_path) OVERRIDE; |
| 40 virtual void OnProfileWasRemoved( | 42 virtual void OnProfileWasRemoved( |
| 41 const base::FilePath& profile_path, | 43 const base::FilePath& profile_path, |
| 42 const base::string16& profile_name) OVERRIDE; | 44 const base::string16& profile_name) OVERRIDE; |
| 43 virtual void OnProfileNameChanged( | 45 virtual void OnProfileNameChanged( |
| 44 const base::FilePath& profile_path, | 46 const base::FilePath& profile_path, |
| 45 const base::string16& old_profile_name) OVERRIDE; | 47 const base::string16& old_profile_name) OVERRIDE; |
| 46 | 48 |
| 49 // SigninErrorController::Observer: |
| 50 virtual void OnErrorChanged() OVERRIDE; |
| 51 |
| 47 // Called when the profile info cache has changed, which means we might | 52 // Called when the profile info cache has changed, which means we might |
| 48 // have to re-display the profile name. | 53 // have to re-display the profile name. |
| 49 void UpdateAvatarButtonAndRelayoutParent(); | 54 void UpdateAvatarButtonAndRelayoutParent(); |
| 50 | 55 |
| 51 Browser* browser_; | 56 Browser* browser_; |
| 52 | 57 |
| 53 DISALLOW_COPY_AND_ASSIGN(NewAvatarButton); | 58 DISALLOW_COPY_AND_ASSIGN(NewAvatarButton); |
| 54 }; | 59 }; |
| 55 | 60 |
| 56 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_ | 61 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_ |
| OLD | NEW |