Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / views / profiles / new_avatar_button.h
blob818110761f51759e7898d69c7dcd2bd59075b129
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_
6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_
8 #include "chrome/browser/profiles/profile_info_cache_observer.h"
9 #include "components/signin/core/browser/signin_error_controller.h"
10 #include "ui/views/controls/button/label_button.h"
12 class Browser;
14 // Avatar button that displays the active profile's name in the caption area.
15 class NewAvatarButton : public views::LabelButton,
16 public ProfileInfoCacheObserver,
17 public SigninErrorController::Observer {
18 public:
19 // Different button styles that can be applied.
20 enum AvatarButtonStyle {
21 THEMED_BUTTON, // Used in a themed browser window.
22 NATIVE_BUTTON, // Used in a native aero or metro window.
25 NewAvatarButton(views::ButtonListener* listener,
26 AvatarButtonStyle button_style,
27 Browser* browser);
28 ~NewAvatarButton() override;
30 // Views::LabelButton
31 bool OnMousePressed(const ui::MouseEvent& event) override;
32 void OnMouseReleased(const ui::MouseEvent& event) override;
34 // Views
35 void OnGestureEvent(ui::GestureEvent* event) override;
37 private:
38 friend class ProfileChooserViewExtensionsTest;
40 // ProfileInfoCacheObserver:
41 void OnProfileAdded(const base::FilePath& profile_path) override;
42 void OnProfileWasRemoved(const base::FilePath& profile_path,
43 const base::string16& profile_name) override;
44 void OnProfileNameChanged(const base::FilePath& profile_path,
45 const base::string16& old_profile_name) override;
46 void OnProfileSupervisedUserIdChanged(
47 const base::FilePath& profile_path) override;
49 // SigninErrorController::Observer:
50 void OnErrorChanged() override;
52 // Called when the profile info cache has changed, which means we might
53 // have to update the icon/text of the button.
54 void Update();
56 Browser* browser_;
58 // Whether the signed in profile has an authentication error. Used to display
59 // an error icon next to the button text.
60 bool has_auth_error_;
62 // The icon displayed instead of the profile name in the local profile case.
63 // Different assets are used depending on the OS version.
64 gfx::ImageSkia generic_avatar_;
66 // This is used to check if the bubble was showing during the mouse pressed
67 // event. If this is true then the mouse released event is ignored to prevent
68 // the bubble from reshowing.
69 bool suppress_mouse_released_action_;
71 DISALLOW_COPY_AND_ASSIGN(NewAvatarButton);
74 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_