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

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

Issue 2880033003: Apply MD style to Linux avatar buttons. (Closed)
Patch Set: tweaks Created 3 years, 7 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_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:
38 bool ShouldUseFloodFillInkDrop() const override; 42 bool ShouldUseFloodFillInkDrop() const override;
39 43
40 private: 44 private:
41 friend class ProfileChooserViewExtensionsTest; 45 friend class ProfileChooserViewExtensionsTest;
42 46
43 // AvatarButtonErrorControllerDelegate: 47 // AvatarButtonErrorControllerDelegate:
44 void OnAvatarErrorChanged() override; 48 void OnAvatarErrorChanged() override;
45 49
46 // ProfileAttributesStorage::Observer: 50 // ProfileAttributesStorage::Observer:
47 void OnProfileAdded(const base::FilePath& profile_path) override; 51 void OnProfileAdded(const base::FilePath& profile_path) override;
48 void OnProfileWasRemoved(const base::FilePath& profile_path, 52 void OnProfileWasRemoved(const base::FilePath& profile_path,
49 const base::string16& profile_name) override; 53 const base::string16& profile_name) override;
50 void OnProfileNameChanged(const base::FilePath& profile_path, 54 void OnProfileNameChanged(const base::FilePath& profile_path,
51 const base::string16& old_profile_name) override; 55 const base::string16& old_profile_name) override;
52 void OnProfileSupervisedUserIdChanged( 56 void OnProfileSupervisedUserIdChanged(
53 const base::FilePath& profile_path) override; 57 const base::FilePath& profile_path) override;
54 58
59 // views::WidgetObserver
Peter Kasting 2017/05/15 21:51:28 Nit: Trailing colon
60 void OnWidgetClosing(views::Widget* widget) override;
61
55 // Called when the profile info cache or signin/sync error has changed, which 62 // 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. 63 // means we might have to update the icon/text of the button.
57 void Update(); 64 void Update();
58 65
59 // Sets generic_avatar_ to the image with the specified IDR. 66 // Sets generic_avatar_ to the image with the specified IDR.
60 void SetButtonAvatar(int avatar_idr); 67 void SetButtonAvatar(int avatar_idr);
61 68
69 // Returns true when the button can get smaller to accomodate a more crowded
70 // browser frame.
71 bool IsCondensible() const;
72
62 AvatarButtonErrorController error_controller_; 73 AvatarButtonErrorController error_controller_;
63 Profile* profile_; 74 Profile* profile_;
64 ScopedObserver<ProfileAttributesStorage, AvatarButton> profile_observer_; 75 ScopedObserver<ProfileAttributesStorage, AvatarButton> profile_observer_;
65 76
66 // The icon displayed instead of the profile name in the local profile case. 77 // The icon displayed instead of the profile name in the local profile case.
67 // Different assets are used depending on the OS version. 78 // Different assets are used depending on the OS version.
68 gfx::ImageSkia generic_avatar_; 79 gfx::ImageSkia generic_avatar_;
69 80
70 // True to use the Windows 10 native (non-themed) button, which is drawn using 81 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 82
75 DISALLOW_COPY_AND_ASSIGN(AvatarButton); 83 DISALLOW_COPY_AND_ASSIGN(AvatarButton);
76 }; 84 };
77 85
78 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_BUTTON_H_ 86 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_BUTTON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698