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

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

Issue 1139943002: Revert of Refactor the avatar button/icon class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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_AVATAR_MENU_BUTTON_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_MENU_BUTTON_H_
6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_MENU_BUTTON_H_ 6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_MENU_BUTTON_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "chrome/browser/ui/views/profiles/avatar_base_button.h"
12 #include "ui/base/models/simple_menu_model.h" 11 #include "ui/base/models/simple_menu_model.h"
13 #include "ui/views/controls/button/menu_button.h" 12 #include "ui/views/controls/button/menu_button.h"
14 #include "ui/views/controls/button/menu_button_listener.h" 13 #include "ui/views/controls/button/menu_button_listener.h"
15 #include "ui/views/view_targeter_delegate.h" 14 #include "ui/views/view_targeter_delegate.h"
16 15
17 namespace gfx { 16 namespace gfx {
18 class Canvas; 17 class Canvas;
19 class Image; 18 class Image;
20 } 19 }
21 class Browser; 20 class Browser;
22 class Profile; 21 class Profile;
23 22
24 // AvatarMenuButton 23 // AvatarMenuButton
25 // 24 //
26 // A button used to show either the incognito avatar or the profile avatar. 25 // A button used to show either the incognito avatar or the profile avatar.
27 // The button can optionally have a menu attached to it. 26 // The button can optionally have a menu attached to it.
28 27
29 class AvatarMenuButton : public AvatarBaseButton, 28 class AvatarMenuButton : public views::MenuButton,
30 public views::MenuButton,
31 public views::MenuButtonListener, 29 public views::MenuButtonListener,
32 public views::ViewTargeterDelegate { 30 public views::ViewTargeterDelegate {
33 public: 31 public:
34 // Internal class name. 32 // Internal class name.
35 static const char kViewClassName[]; 33 static const char kViewClassName[];
36 34
37 // Creates a new button. Unless |disabled| is true, clicking on the button 35 // Creates a new button. Unless |disabled| is true, clicking on the button
38 // will cause the profile menu to be displayed. 36 // will cause the profile menu to be displayed.
39 AvatarMenuButton(Browser* browser, bool disabled); 37 AvatarMenuButton(Browser* browser, bool disabled);
40 38
(...skipping 15 matching lines...) Expand all
56 // Get avatar images for the profile. |avatar| is used in the browser window 54 // Get avatar images for the profile. |avatar| is used in the browser window
57 // whereas |taskbar_badge_avatar| is used for the OS taskbar. If 55 // whereas |taskbar_badge_avatar| is used for the OS taskbar. If
58 // |taskbar_badge_avatar| is empty then |avatar| should be used for the 56 // |taskbar_badge_avatar| is empty then |avatar| should be used for the
59 // taskbar as well. Returns false if the cache doesn't have an entry for a 57 // taskbar as well. Returns false if the cache doesn't have an entry for a
60 // Profile::REGULAR_PROFILE type |profile|, otherwise return true. 58 // Profile::REGULAR_PROFILE type |profile|, otherwise return true.
61 static bool GetAvatarImages(Profile* profile, 59 static bool GetAvatarImages(Profile* profile,
62 bool should_show_avatar_menu, 60 bool should_show_avatar_menu,
63 gfx::Image* avatar, 61 gfx::Image* avatar,
64 gfx::Image* taskbar_badge_avatar, 62 gfx::Image* taskbar_badge_avatar,
65 bool* is_rectangle); 63 bool* is_rectangle);
66 protected:
67 // AvatarBaseButton:
68 void Update() override;
69 64
70 private: 65 private:
71 // views::ViewTargeterDelegate: 66 // views::ViewTargeterDelegate:
72 bool DoesIntersectRect(const views::View* target, 67 bool DoesIntersectRect(const views::View* target,
73 const gfx::Rect& rect) const override; 68 const gfx::Rect& rect) const override;
74 69
75 // views::MenuButtonListener: 70 // views::MenuButtonListener:
76 void OnMenuButtonClicked(views::View* source, 71 void OnMenuButtonClicked(views::View* source,
77 const gfx::Point& point) override; 72 const gfx::Point& point) override;
78 73
74 Browser* browser_;
79 bool disabled_; 75 bool disabled_;
80 scoped_ptr<ui::MenuModel> menu_model_; 76 scoped_ptr<ui::MenuModel> menu_model_;
81 77
82 // Use a scoped ptr because gfx::Image doesn't have a default constructor. 78 // Use a scoped ptr because gfx::Image doesn't have a default constructor.
83 scoped_ptr<gfx::Image> icon_; 79 scoped_ptr<gfx::Image> icon_;
84 gfx::ImageSkia button_icon_; 80 gfx::ImageSkia button_icon_;
85 bool is_rectangle_; 81 bool is_rectangle_;
86 int old_height_; 82 int old_height_;
87 // True if the avatar button is on the right side of the browser window. 83 // True if the avatar button is on the right side of the browser window.
88 bool button_on_right_; 84 bool button_on_right_;
89 85
90 DISALLOW_COPY_AND_ASSIGN(AvatarMenuButton); 86 DISALLOW_COPY_AND_ASSIGN(AvatarMenuButton);
91 }; 87 };
92 88
93 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_MENU_BUTTON_H_ 89 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_MENU_BUTTON_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/profiles/avatar_base_button.cc ('k') | chrome/browser/ui/views/profiles/avatar_menu_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698