new_avatar_button.h revision 6d86b77056ed63eb6871182f42a9fd5f07550f90
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.
4
5#ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_
6#define CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_
7
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/menu_button.h"
11
12class Browser;
13
14// Avatar button that displays the active profile's name in the caption area.
15class NewAvatarButton : public views::MenuButton,
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.
23  };
24
25  NewAvatarButton(views::ButtonListener* listener,
26                  const base::string16& profile_name,
27                  AvatarButtonStyle button_style,
28                  Browser* browser);
29  virtual ~NewAvatarButton();
30
31 private:
32  friend class NewAvatarMenuButtonTest;
33  friend class ProfileChooserViewBrowserTest;
34  FRIEND_TEST_ALL_PREFIXES(NewAvatarMenuButtonTest, SignOut);
35  FRIEND_TEST_ALL_PREFIXES(ProfileChooserViewBrowserTest, ViewProfileUMA);
36
37  // ProfileInfoCacheObserver:
38  virtual void OnProfileAdded(const base::FilePath& profile_path) OVERRIDE;
39  virtual void OnProfileWasRemoved(
40      const base::FilePath& profile_path,
41      const base::string16& profile_name) OVERRIDE;
42  virtual void OnProfileNameChanged(
43      const base::FilePath& profile_path,
44      const base::string16& old_profile_name) OVERRIDE;
45  virtual void OnProfileSupervisedUserIdChanged(
46      const base::FilePath& profile_path) OVERRIDE;
47
48  // SigninErrorController::Observer:
49  virtual void OnErrorChanged() OVERRIDE;
50
51  // Called when the profile info cache has changed, which means we might
52  // have to re-display the profile name.
53  void UpdateAvatarButtonAndRelayoutParent();
54
55  Browser* browser_;
56
57  DISALLOW_COPY_AND_ASSIGN(NewAvatarButton);
58};
59
60#endif  // CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_
61