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_AVATAR_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_BUTTON_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_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 "base/scoped_observer.h" | 9 #include "base/scoped_observer.h" |
10 #include "chrome/browser/profiles/profile_attributes_storage.h" | 10 #include "chrome/browser/profiles/profile_attributes_storage.h" |
11 #include "chrome/browser/ui/avatar_button_error_controller.h" | 11 #include "chrome/browser/ui/avatar_button_error_controller.h" |
12 #include "chrome/browser/ui/avatar_button_error_controller_delegate.h" | 12 #include "chrome/browser/ui/avatar_button_error_controller_delegate.h" |
13 #include "chrome/browser/ui/views/profiles/avatar_button_style.h" | 13 #include "chrome/browser/ui/views/profiles/avatar_button_style.h" |
14 #include "ui/views/controls/button/label_button.h" | 14 #include "ui/views/controls/button/label_button.h" |
| 15 #include "ui/views/widget/widget_observer.h" |
15 | 16 |
16 class Profile; | 17 class Profile; |
17 | 18 |
18 // Base class for avatar buttons that display the active profile's name in the | 19 // Base class for avatar buttons that display the active profile's name in the |
19 // caption area. | 20 // caption area. |
20 class AvatarButton : public views::LabelButton, | 21 class AvatarButton : public views::LabelButton, |
21 public AvatarButtonErrorControllerDelegate, | 22 public AvatarButtonErrorControllerDelegate, |
22 public ProfileAttributesStorage::Observer { | 23 public ProfileAttributesStorage::Observer, |
| 24 public views::WidgetObserver { |
23 public: | 25 public: |
24 AvatarButton(views::ButtonListener* listener, | 26 AvatarButton(views::ButtonListener* listener, |
25 AvatarButtonStyle button_style, | 27 AvatarButtonStyle button_style, |
26 Profile* profile); | 28 Profile* profile); |
27 ~AvatarButton() override; | 29 ~AvatarButton() override; |
28 | 30 |
29 // views::LabelButton: | 31 // views::LabelButton: |
30 void OnGestureEvent(ui::GestureEvent* event) override; | 32 void OnGestureEvent(ui::GestureEvent* event) override; |
31 gfx::Size GetMinimumSize() const override; | 33 gfx::Size GetMinimumSize() const override; |
32 gfx::Size GetPreferredSize() const override; | 34 gfx::Size GetPreferredSize() const override; |
33 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() | 35 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() |
34 const override; | 36 const override; |
| 37 std::unique_ptr<views::InkDropMask> CreateInkDropMask() const override; |
| 38 void NotifyClick(const ui::Event& event) override; |
35 | 39 |
36 protected: | 40 protected: |
37 // views::LabelButton: | 41 // views::LabelButton: |
| 42 bool ShouldEnterPushedState(const ui::Event& event) override; |
38 bool ShouldUseFloodFillInkDrop() const override; | 43 bool ShouldUseFloodFillInkDrop() const override; |
39 | 44 |
40 private: | 45 private: |
41 friend class ProfileChooserViewExtensionsTest; | 46 friend class ProfileChooserViewExtensionsTest; |
42 | 47 |
43 // AvatarButtonErrorControllerDelegate: | 48 // AvatarButtonErrorControllerDelegate: |
44 void OnAvatarErrorChanged() override; | 49 void OnAvatarErrorChanged() override; |
45 | 50 |
46 // ProfileAttributesStorage::Observer: | 51 // ProfileAttributesStorage::Observer: |
47 void OnProfileAdded(const base::FilePath& profile_path) override; | 52 void OnProfileAdded(const base::FilePath& profile_path) override; |
48 void OnProfileWasRemoved(const base::FilePath& profile_path, | 53 void OnProfileWasRemoved(const base::FilePath& profile_path, |
49 const base::string16& profile_name) override; | 54 const base::string16& profile_name) override; |
50 void OnProfileNameChanged(const base::FilePath& profile_path, | 55 void OnProfileNameChanged(const base::FilePath& profile_path, |
51 const base::string16& old_profile_name) override; | 56 const base::string16& old_profile_name) override; |
52 void OnProfileSupervisedUserIdChanged( | 57 void OnProfileSupervisedUserIdChanged( |
53 const base::FilePath& profile_path) override; | 58 const base::FilePath& profile_path) override; |
54 | 59 |
| 60 // views::WidgetObserver |
| 61 void OnWidgetClosing(views::Widget* widget) override; |
| 62 |
55 // Called when the profile info cache or signin/sync error has changed, which | 63 // Called when the profile info cache or signin/sync error has changed, which |
56 // means we might have to update the icon/text of the button. | 64 // means we might have to update the icon/text of the button. |
57 void Update(); | 65 void Update(); |
58 | 66 |
59 // Sets generic_avatar_ to the image with the specified IDR. | 67 // Sets generic_avatar_ to the image with the specified IDR. |
60 void SetButtonAvatar(int avatar_idr); | 68 void SetButtonAvatar(int avatar_idr); |
61 | 69 |
| 70 // Returns true when the button can get smaller to accomodate a more crowded |
| 71 // browser frame. |
| 72 bool IsCondensible() const; |
| 73 |
62 AvatarButtonErrorController error_controller_; | 74 AvatarButtonErrorController error_controller_; |
63 Profile* profile_; | 75 Profile* profile_; |
64 ScopedObserver<ProfileAttributesStorage, AvatarButton> profile_observer_; | 76 ScopedObserver<ProfileAttributesStorage, AvatarButton> profile_observer_; |
65 | 77 |
66 // The icon displayed instead of the profile name in the local profile case. | 78 // The icon displayed instead of the profile name in the local profile case. |
67 // Different assets are used depending on the OS version. | 79 // Different assets are used depending on the OS version. |
68 gfx::ImageSkia generic_avatar_; | 80 gfx::ImageSkia generic_avatar_; |
69 | 81 |
70 // True to use the Windows 10 native (non-themed) button, which is drawn using | 82 AvatarButtonStyle button_style_; |
71 // a vector icon and can change height to slide atop the tabstrip. False to | |
72 // use the old PNG, fixed-size icon button or a themed button. | |
73 bool use_win10_native_button_; | |
74 | 83 |
75 DISALLOW_COPY_AND_ASSIGN(AvatarButton); | 84 DISALLOW_COPY_AND_ASSIGN(AvatarButton); |
76 }; | 85 }; |
77 | 86 |
78 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_BUTTON_H_ | 87 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_BUTTON_H_ |
OLD | NEW |