| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_FRAME_AVATAR_BUTTON_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_AVATAR_BUTTON_MANAGER_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_FRAME_AVATAR_BUTTON_MANAGER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_FRAME_AVATAR_BUTTON_MANAGER_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/ui/views/profiles/avatar_button_delegate.h" | |
| 9 #include "chrome/browser/ui/views/profiles/avatar_button_style.h" | 8 #include "chrome/browser/ui/views/profiles/avatar_button_style.h" |
| 9 #include "ui/views/controls/button/button.h" |
| 10 | 10 |
| 11 class BrowserNonClientFrameView; | 11 class BrowserNonClientFrameView; |
| 12 | 12 |
| 13 // Manages an avatar button displayed in a browser frame. The button displays | 13 // Manages an avatar button displayed in a browser frame. The button displays |
| 14 // the name of the active or guest profile, and may be null. | 14 // the name of the active or guest profile, and may be null. |
| 15 class AvatarButtonManager : public AvatarButtonDelegate { | 15 class AvatarButtonManager : public views::ButtonListener { |
| 16 public: | 16 public: |
| 17 explicit AvatarButtonManager(BrowserNonClientFrameView* frame_view); | 17 explicit AvatarButtonManager(BrowserNonClientFrameView* frame_view); |
| 18 | 18 |
| 19 // Adds or removes the avatar button from the frame, based on the BrowserView | 19 // Adds or removes the avatar button from the frame, based on the BrowserView |
| 20 // properties. | 20 // properties. |
| 21 void Update(AvatarButtonStyle style); | 21 void Update(AvatarButtonStyle style); |
| 22 | 22 |
| 23 // Gets the avatar button as a view::View. | 23 // Gets the avatar button as a view::View. |
| 24 views::View* view() const { return view_; } | 24 views::View* view() const { return view_; } |
| 25 | 25 |
| 26 private: | |
| 27 // AvatarButtonDelegate: | |
| 28 void ButtonPreferredSizeChanged() override; | |
| 29 | |
| 30 // views::ButtonListener: | 26 // views::ButtonListener: |
| 31 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 27 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 32 | 28 |
| 29 private: |
| 33 BrowserNonClientFrameView* frame_view_; // Weak. Owns |this|. | 30 BrowserNonClientFrameView* frame_view_; // Weak. Owns |this|. |
| 34 | 31 |
| 35 // Menu button that displays the name of the active or guest profile. | 32 // Menu button that displays the name of the active or guest profile. |
| 36 // May be null and will not be displayed for off the record profiles. | 33 // May be null and will not be displayed for off the record profiles. |
| 37 views::View* view_; // Owned by views hierarchy. | 34 views::View* view_; // Owned by views hierarchy. |
| 38 | 35 |
| 39 DISALLOW_COPY_AND_ASSIGN(AvatarButtonManager); | 36 DISALLOW_COPY_AND_ASSIGN(AvatarButtonManager); |
| 40 }; | 37 }; |
| 41 | 38 |
| 42 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_AVATAR_BUTTON_MANAGER_H_ | 39 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_AVATAR_BUTTON_MANAGER_H_ |
| OLD | NEW |