Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: chrome/browser/ui/views/profiles/new_avatar_button.h

Issue 2832823002: Update avatar button to MD (Closed)
Patch Set: Fix for --force-device-scale-factor, vector icon, review comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "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/frame/browser_view.h"
12 #include "chrome/browser/ui/views/profiles/avatar_button_style.h" 13 #include "chrome/browser/ui/views/profiles/avatar_button_style.h"
13 #include "ui/views/controls/button/label_button.h" 14 #include "ui/views/animation/ink_drop.h"
15 #include "ui/views/controls/button/menu_button.h"
14 16
15 class AvatarButtonDelegate; 17 class AvatarButtonDelegate;
16 class Profile; 18 class Profile;
17 19
18 // Avatar button that displays the active profile's name in the caption area. 20 class AvatarButton : public views::MenuButton,
19 class NewAvatarButton : public views::LabelButton, 21 public AvatarButtonErrorControllerDelegate,
20 public AvatarButtonErrorControllerDelegate, 22 public ProfileAttributesStorage::Observer {
21 public ProfileAttributesStorage::Observer {
22 public: 23 public:
23 NewAvatarButton(AvatarButtonDelegate* delegate, 24 AvatarButton(AvatarButtonDelegate* delegate, Profile* profile);
24 AvatarButtonStyle button_style, 25 ~AvatarButton() override;
25 Profile* profile);
26 ~NewAvatarButton() override;
27 26
28 // Views::LabelButton 27 // Update the avatar button height previously calculated by GetPreferredSize,
29 bool OnMousePressed(const ui::MouseEvent& event) override; 28 // if needed, now that the button's position is known.
30 void OnMouseReleased(const ui::MouseEvent& event) override; 29 virtual void UpdateButtonHeightForPosition(const int button_x,
30 int* button_height) const {}
31 31
32 // Views 32 protected:
33 void OnGestureEvent(ui::GestureEvent* event) override; 33 // MenuButton
34 bool IsTriggerableEvent(const ui::Event& event) override;
35
36 // Called when the profile info cache or signin/sync error has changed, which
37 // means we might have to update the icon/text of the button.
38 void Update();
39
40 void set_generic_avatar(gfx::ImageSkia generic_avatar) {
Evan Stade 2017/04/27 01:30:55 const ref
emx 2017/04/27 16:30:58 Done.
41 generic_avatar_ = generic_avatar;
42 }
34 43
35 private: 44 private:
36 friend class ProfileChooserViewExtensionsTest; 45 friend class ProfileChooserViewExtensionsTest;
37 46
38 // AvatarButtonErrorControllerDelegate: 47 // AvatarButtonErrorControllerDelegate:
39 void OnAvatarErrorChanged() override; 48 void OnAvatarErrorChanged() override;
40 49
41 // ProfileAttributesStorage::Observer: 50 // ProfileAttributesStorage::Observer:
42 void OnProfileAdded(const base::FilePath& profile_path) override; 51 void OnProfileAdded(const base::FilePath& profile_path) override;
43 void OnProfileWasRemoved(const base::FilePath& profile_path, 52 void OnProfileWasRemoved(const base::FilePath& profile_path,
44 const base::string16& profile_name) override; 53 const base::string16& profile_name) override;
45 void OnProfileNameChanged(const base::FilePath& profile_path, 54 void OnProfileNameChanged(const base::FilePath& profile_path,
46 const base::string16& old_profile_name) override; 55 const base::string16& old_profile_name) override;
47 void OnProfileSupervisedUserIdChanged( 56 void OnProfileSupervisedUserIdChanged(
48 const base::FilePath& profile_path) override; 57 const base::FilePath& profile_path) override;
49 58
50 // Called when the profile info cache or signin/sync error has changed, which 59 void UpdateButton(bool use_generic_button,
51 // means we might have to update the icon/text of the button. 60 Profile* profile,
Evan Stade 2017/04/27 01:30:55 why does this take a profile param instead of usin
emx 2017/04/27 16:30:58 Mistakenly left over from an earlier implementatio
52 void Update(); 61 AvatarButtonErrorController* error_controller);
53 62
54 AvatarButtonDelegate* delegate_; 63 AvatarButtonDelegate* delegate_;
55 AvatarButtonErrorController error_controller_; 64 AvatarButtonErrorController error_controller_;
56 Profile* profile_; 65 Profile* profile_;
57 66
58 // The icon displayed instead of the profile name in the local profile case. 67 // The icon displayed instead of the profile name in the local profile case.
59 // Different assets are used depending on the OS version. 68 // Different assets are used depending on the OS version.
60 gfx::ImageSkia generic_avatar_; 69 gfx::ImageSkia generic_avatar_;
61 70
62 // This is used to check if the bubble was showing during the mouse pressed 71 DISALLOW_COPY_AND_ASSIGN(AvatarButton);
63 // event. If this is true then the mouse released event is ignored to prevent 72 };
64 // the bubble from reshowing. 73
65 bool suppress_mouse_released_action_; 74 // Avatar button that displays the active profile's name in the caption area.
75 class NewAvatarButton : public AvatarButton {
Evan Stade 2017/04/27 01:30:55 This should be called something like ThemedAvatarB
emx 2017/04/27 16:30:58 This isn't only used for themes, though, it's also
Evan Stade 2017/04/27 17:03:30 You're right, it's always used on Linux. But using
76 public:
77 NewAvatarButton(AvatarButtonDelegate* delegate,
78 AvatarButtonStyle button_style,
79 Profile* profile);
80 ~NewAvatarButton() override;
81
82 protected:
83 gfx::Size GetPreferredSize() const override;
84
85 private:
86 std::unique_ptr<views::Border> CreateBorder(
87 const int normal_image_set[],
88 const int hot_image_set[],
89 const int pushed_image_set[]) const;
90 // Sets generic_avatar_ to the image with the specified IDR.
91 void SetButtonAvatar(const int avatar_idr);
Evan Stade 2017/04/27 01:30:55 nit: no const on POD parameters
emx 2017/04/27 16:30:59 Done.
66 92
67 DISALLOW_COPY_AND_ASSIGN(NewAvatarButton); 93 DISALLOW_COPY_AND_ASSIGN(NewAvatarButton);
68 }; 94 };
69 95
96 class MaterialDesignAvatarButton : public AvatarButton {
Evan Stade 2017/04/27 01:30:55 This should be called something like Win10NativeAv
emx 2017/04/27 16:30:59 "Win10NativeAvatarButton" sounds good to me. I'll
97 public:
98 MaterialDesignAvatarButton(AvatarButtonDelegate* delegate,
99 Profile* profile,
100 BrowserView* browser_view);
101 ~MaterialDesignAvatarButton() override;
102
103 void UpdateButtonHeightForPosition(const int button_x,
104 int* button_height) const override;
105
106 protected:
107 gfx::Size GetPreferredSize() const override;
108 std::unique_ptr<views::InkDrop> CreateInkDrop() override;
109 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override;
110 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
111 const override;
112
113 private:
114 std::unique_ptr<views::Border> CreateBorder() const;
115
116 BrowserView* browser_view_;
117
118 DISALLOW_COPY_AND_ASSIGN(MaterialDesignAvatarButton);
119 };
120
70 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_ 121 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698