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

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

Issue 1972033002: Simplify some old avatar menu button code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reinstate ash browser test fix Created 4 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
(Empty)
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_AVATAR_MENU_BUTTON_H_
6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_MENU_BUTTON_H_
7
8 #include <string>
9
10 #include "base/compiler_specific.h"
11 #include "base/macros.h"
12 #include "ui/base/models/simple_menu_model.h"
13 #include "ui/views/controls/button/menu_button.h"
14 #include "ui/views/controls/button/menu_button_listener.h"
15 #include "ui/views/view_targeter_delegate.h"
16
17 namespace gfx {
18 class Canvas;
19 class Image;
20 }
21 class BrowserNonClientFrameView;
22 class BrowserView;
23 class Profile;
24
25 // AvatarMenuButton
26 //
27 // A button used to show either the incognito avatar or the profile avatar.
28 // The button can optionally have a menu attached to it.
29
30 class AvatarMenuButton : public views::MenuButton,
31 public views::MenuButtonListener,
32 public views::ViewTargeterDelegate {
33 public:
34 // Internal class name.
35 static const char kViewClassName[];
36
37 // Creates a new button for the given browser view.
38 explicit AvatarMenuButton(BrowserView* browser_view);
39
40 ~AvatarMenuButton() override;
41
42 // views::MenuButton:
43 const char* GetClassName() const override;
44 void OnPaint(gfx::Canvas* canvas) override;
45
46 // Sets the image for the avatar button. Rectangular images, as opposed
47 // to Chrome avatar icons, will be resized and modified for the title bar.
48 virtual void SetAvatarIcon(const gfx::Image& icon, bool is_rectangle);
49
50 // Get avatar images. |avatar| is used in the browser window whereas
51 // |taskbar_badge_avatar| is used for the OS taskbar. If
52 // |taskbar_badge_avatar| is empty then |avatar| should be used for the
53 // taskbar as well. Returns false if the cache doesn't have an entry for a
54 // Profile::REGULAR_PROFILE type Profile, otherwise return true.
55 static bool GetAvatarImages(const BrowserNonClientFrameView* frame_view,
56 bool should_show_avatar_menu,
57 gfx::Image* avatar,
58 gfx::Image* taskbar_badge_avatar,
59 bool* is_rectangle);
60
61 private:
62 // views::ViewTargeterDelegate:
63 bool DoesIntersectRect(const views::View* target,
64 const gfx::Rect& rect) const override;
65
66 // views::MenuButtonListener:
67 void OnMenuButtonClicked(views::MenuButton* source,
68 const gfx::Point& point,
69 const ui::Event* event) override;
70
71 BrowserView* browser_view_;
72 bool enabled_;
73 std::unique_ptr<ui::MenuModel> menu_model_;
74
75 // Use a scoped ptr because gfx::Image doesn't have a default constructor.
76 std::unique_ptr<gfx::Image> icon_;
77 gfx::ImageSkia button_icon_;
78 bool is_rectangle_;
79 int old_height_;
80
81 DISALLOW_COPY_AND_ASSIGN(AvatarMenuButton);
82 };
83
84 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_MENU_BUTTON_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/taskbar_decorator_win.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