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

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

Issue 1009403002: Refactor the avatar button/icon class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 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_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/ui/views/profiles/avatar_base_button.h"
9 #include "components/signin/core/browser/signin_error_controller.h" 9 #include "components/signin/core/browser/signin_error_controller.h"
10 #include "ui/views/controls/button/label_button.h" 10 #include "ui/views/controls/button/label_button.h"
11 11
12 class Browser; 12 class Browser;
13 13
14 // 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.
15 class NewAvatarButton : public views::LabelButton, 15 class NewAvatarButton : public AvatarBaseButton,
16 public ProfileInfoCacheObserver, 16 public views::LabelButton,
17 public SigninErrorController::Observer { 17 public SigninErrorController::Observer {
18 public: 18 public:
19 // Different button styles that can be applied. 19 // Different button styles that can be applied.
20 enum AvatarButtonStyle { 20 enum AvatarButtonStyle {
21 THEMED_BUTTON, // Used in a themed browser window. 21 THEMED_BUTTON, // Used in a themed browser window.
22 NATIVE_BUTTON, // Used in a native aero or metro window. 22 NATIVE_BUTTON, // Used in a native aero or metro window.
23 }; 23 };
24 24
25 NewAvatarButton(views::ButtonListener* listener, 25 NewAvatarButton(views::ButtonListener* listener,
26 AvatarButtonStyle button_style, 26 AvatarButtonStyle button_style,
27 Browser* browser); 27 Browser* browser);
28 ~NewAvatarButton() override; 28 ~NewAvatarButton() override;
29 29
30 // Views::LabelButton 30 // Views::LabelButton
31 bool OnMousePressed(const ui::MouseEvent& event) override; 31 bool OnMousePressed(const ui::MouseEvent& event) override;
32 void OnMouseReleased(const ui::MouseEvent& event) override; 32 void OnMouseReleased(const ui::MouseEvent& event) override;
33 33
34 protected:
35 // AvatarBaseButton:
36 void Update() override;
37
34 private: 38 private:
35 friend class ProfileChooserViewExtensionsTest; 39 friend class ProfileChooserViewExtensionsTest;
36 40
37 // ProfileInfoCacheObserver:
38 void OnProfileAdded(const base::FilePath& profile_path) override;
39 void OnProfileWasRemoved(const base::FilePath& profile_path,
40 const base::string16& profile_name) override;
41 void OnProfileNameChanged(const base::FilePath& profile_path,
42 const base::string16& old_profile_name) override;
43 void OnProfileSupervisedUserIdChanged(
44 const base::FilePath& profile_path) override;
45
46 // SigninErrorController::Observer: 41 // SigninErrorController::Observer:
47 void OnErrorChanged() override; 42 void OnErrorChanged() override;
48 43
49 // Called when the profile info cache has changed, which means we might
50 // have to update the icon/text of the button.
51 void Update();
52
53 Browser* browser_;
54
55 // Whether the signed in profile has an authentication error. Used to display 44 // Whether the signed in profile has an authentication error. Used to display
56 // an error icon next to the button text. 45 // an error icon next to the button text.
57 bool has_auth_error_; 46 bool has_auth_error_;
58 47
59 // The icon displayed instead of the profile name in the local profile case. 48 // The icon displayed instead of the profile name in the local profile case.
60 // Different assets are used depending on the OS version. 49 // Different assets are used depending on the OS version.
61 gfx::ImageSkia generic_avatar_; 50 gfx::ImageSkia generic_avatar_;
62 51
63 // This is used to check if the bubble was showing during the mouse pressed 52 // This is used to check if the bubble was showing during the mouse pressed
64 // event. If this is true then the mouse released event is ignored to prevent 53 // event. If this is true then the mouse released event is ignored to prevent
65 // the bubble from reshowing. 54 // the bubble from reshowing.
66 bool suppress_mouse_released_action_; 55 bool suppress_mouse_released_action_;
67 56
68 DISALLOW_COPY_AND_ASSIGN(NewAvatarButton); 57 DISALLOW_COPY_AND_ASSIGN(NewAvatarButton);
69 }; 58 };
70 59
71 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_ 60 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/profiles/avatar_menu_button.cc ('k') | chrome/browser/ui/views/profiles/new_avatar_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698