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_AVATAR_BUTTON_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_BUTTON_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "chrome/browser/profiles/profile_attributes_storage.h" | 9 #include "chrome/browser/profiles/profile_attributes_storage.h" |
10 #include "chrome/browser/ui/avatar_button_error_controller.h" | 10 #include "chrome/browser/ui/avatar_button_error_controller.h" |
11 #include "chrome/browser/ui/avatar_button_error_controller_delegate.h" | 11 #include "chrome/browser/ui/avatar_button_error_controller_delegate.h" |
12 #include "chrome/browser/ui/views/profiles/avatar_button_style.h" | 12 #include "chrome/browser/ui/views/profiles/avatar_button_style.h" |
13 #include "ui/views/controls/button/label_button.h" | 13 #include "ui/views/controls/button/menu_button.h" |
14 | 14 |
15 class AvatarButtonDelegate; | |
16 class Profile; | 15 class Profile; |
17 | 16 |
18 // Avatar button that displays the active profile's name in the caption area. | 17 // Base class for avatar buttons that display the active profile's name in the |
19 class NewAvatarButton : public views::LabelButton, | 18 // caption area. |
20 public AvatarButtonErrorControllerDelegate, | 19 class AvatarButton : public views::MenuButton, |
21 public ProfileAttributesStorage::Observer { | 20 public AvatarButtonErrorControllerDelegate, |
| 21 public ProfileAttributesStorage::Observer { |
22 public: | 22 public: |
23 NewAvatarButton(AvatarButtonDelegate* delegate, | 23 ~AvatarButton() override; |
24 AvatarButtonStyle button_style, | |
25 Profile* profile); | |
26 ~NewAvatarButton() override; | |
27 | 24 |
28 // Views::LabelButton | 25 protected: |
29 bool OnMousePressed(const ui::MouseEvent& event) override; | 26 AvatarButton(views::MenuButtonListener* listener, Profile* profile); |
30 void OnMouseReleased(const ui::MouseEvent& event) override; | |
31 | 27 |
32 // Views | 28 // MenuButton |
33 void OnGestureEvent(ui::GestureEvent* event) override; | 29 bool IsTriggerableEvent(const ui::Event& event) override; |
| 30 |
| 31 // Called when the profile info cache or signin/sync error has changed, which |
| 32 // means we might have to update the icon/text of the button. |
| 33 void Update(); |
| 34 |
| 35 void set_generic_avatar(const gfx::ImageSkia& generic_avatar) { |
| 36 generic_avatar_ = generic_avatar; |
| 37 } |
34 | 38 |
35 private: | 39 private: |
36 friend class ProfileChooserViewExtensionsTest; | 40 friend class ProfileChooserViewExtensionsTest; |
37 | 41 |
38 // AvatarButtonErrorControllerDelegate: | 42 // AvatarButtonErrorControllerDelegate: |
39 void OnAvatarErrorChanged() override; | 43 void OnAvatarErrorChanged() override; |
40 | 44 |
41 // ProfileAttributesStorage::Observer: | 45 // ProfileAttributesStorage::Observer: |
42 void OnProfileAdded(const base::FilePath& profile_path) override; | 46 void OnProfileAdded(const base::FilePath& profile_path) override; |
43 void OnProfileWasRemoved(const base::FilePath& profile_path, | 47 void OnProfileWasRemoved(const base::FilePath& profile_path, |
44 const base::string16& profile_name) override; | 48 const base::string16& profile_name) override; |
45 void OnProfileNameChanged(const base::FilePath& profile_path, | 49 void OnProfileNameChanged(const base::FilePath& profile_path, |
46 const base::string16& old_profile_name) override; | 50 const base::string16& old_profile_name) override; |
47 void OnProfileSupervisedUserIdChanged( | 51 void OnProfileSupervisedUserIdChanged( |
48 const base::FilePath& profile_path) override; | 52 const base::FilePath& profile_path) override; |
49 | 53 |
50 // Called when the profile info cache or signin/sync error has changed, which | 54 void UpdateButton(bool use_generic_button); |
51 // means we might have to update the icon/text of the button. | |
52 void Update(); | |
53 | 55 |
54 AvatarButtonDelegate* delegate_; | |
55 AvatarButtonErrorController error_controller_; | 56 AvatarButtonErrorController error_controller_; |
56 Profile* profile_; | 57 Profile* profile_; |
57 | 58 |
58 // The icon displayed instead of the profile name in the local profile case. | 59 // The icon displayed instead of the profile name in the local profile case. |
59 // Different assets are used depending on the OS version. | 60 // Different assets are used depending on the OS version. |
60 gfx::ImageSkia generic_avatar_; | 61 gfx::ImageSkia generic_avatar_; |
61 | 62 |
62 // This is used to check if the bubble was showing during the mouse pressed | 63 DISALLOW_COPY_AND_ASSIGN(AvatarButton); |
63 // event. If this is true then the mouse released event is ignored to prevent | |
64 // the bubble from reshowing. | |
65 bool suppress_mouse_released_action_; | |
66 | |
67 DISALLOW_COPY_AND_ASSIGN(NewAvatarButton); | |
68 }; | 64 }; |
69 | 65 |
70 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_ | 66 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_BUTTON_H_ |
OLD | NEW |