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

Side by Side Diff: chrome/browser/ui/views/toolbar/app_menu_button.h

Issue 2374803002: Remove a bunch of pre-MD toolbar code and assets. (Closed)
Patch Set: more cocoa stuff Created 4 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_TOOLBAR_APP_MENU_BUTTON_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_BUTTON_H_
6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_BUTTON_H_ 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_BUTTON_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/ui/toolbar/app_menu_icon_controller.h" 12 #include "chrome/browser/ui/toolbar/app_menu_icon_controller.h"
13 #include "chrome/browser/ui/toolbar/app_menu_icon_painter.h"
14 #include "ui/views/controls/button/menu_button.h" 13 #include "ui/views/controls/button/menu_button.h"
15 #include "ui/views/controls/button/menu_button_listener.h" 14 #include "ui/views/controls/button/menu_button_listener.h"
16 #include "ui/views/view.h" 15 #include "ui/views/view.h"
17 16
18 class AppMenu; 17 class AppMenu;
19 class AppMenuModel; 18 class AppMenuModel;
20 19
21 namespace views { 20 namespace views {
22 class LabelButtonBorder; 21 class LabelButtonBorder;
23 class MenuListener; 22 class MenuListener;
24 } 23 }
25 24
26 class ToolbarView; 25 class ToolbarView;
27 26
28 class AppMenuButton : public views::MenuButton, 27 class AppMenuButton : public views::MenuButton {
29 public AppMenuIconPainter::Delegate {
30 public: 28 public:
31 explicit AppMenuButton(ToolbarView* toolbar_view); 29 explicit AppMenuButton(ToolbarView* toolbar_view);
32 ~AppMenuButton() override; 30 ~AppMenuButton() override;
33 31
34 void SetSeverity(AppMenuIconController::IconType type, 32 void SetSeverity(AppMenuIconController::IconType type,
35 AppMenuIconPainter::Severity severity, 33 AppMenuIconController::Severity severity,
36 bool animate); 34 bool animate);
37 35
38 // Shows the app menu. |for_drop| indicates whether the menu is opened for a 36 // Shows the app menu. |for_drop| indicates whether the menu is opened for a
39 // drag-and-drop operation. 37 // drag-and-drop operation.
40 void ShowMenu(bool for_drop); 38 void ShowMenu(bool for_drop);
41 39
42 // Closes the app menu, if it's open. 40 // Closes the app menu, if it's open.
43 void CloseMenu(); 41 void CloseMenu();
44 42
45 AppMenu* app_menu_for_testing() { return menu_.get(); } 43 AppMenu* app_menu_for_testing() { return menu_.get(); }
46 44
47 // Whether the app/hotdogs menu is currently showing. 45 // Whether the app/hotdogs menu is currently showing.
48 bool IsMenuShowing() const; 46 bool IsMenuShowing() const;
49 47
50 // Adds a listener to receive a callback when the menu opens. 48 // Adds a listener to receive a callback when the menu opens.
51 void AddMenuListener(views::MenuListener* listener); 49 void AddMenuListener(views::MenuListener* listener);
52 50
53 // Removes a menu listener. 51 // Removes a menu listener.
54 void RemoveMenuListener(views::MenuListener* listener); 52 void RemoveMenuListener(views::MenuListener* listener);
55 53
56 // views::MenuButton: 54 // views::MenuButton:
57 gfx::Size GetPreferredSize() const override; 55 gfx::Size GetPreferredSize() const override;
58 56
59 // AppMenuIconPainter::Delegate:
60 void ScheduleAppMenuIconPaint() override;
61
62 // Updates the presentation according to |severity_| and the theme provider. 57 // Updates the presentation according to |severity_| and the theme provider.
63 // Only used in MD.
64 void UpdateIcon(); 58 void UpdateIcon();
65 59
66 // Sets |margin_trailing_| when the browser is maximized and updates layout 60 // Sets |margin_trailing_| when the browser is maximized and updates layout
67 // to make the focus rectangle centered. 61 // to make the focus rectangle centered.
68 void SetTrailingMargin(int margin); 62 void SetTrailingMargin(int margin);
69 63
70 // Opens the app menu immediately during a drag-and-drop operation. 64 // Opens the app menu immediately during a drag-and-drop operation.
71 // Used only in testing. 65 // Used only in testing.
72 static bool g_open_app_immediately_for_testing; 66 static bool g_open_app_immediately_for_testing;
73 67
74 private: 68 private:
75 // views::MenuButton: 69 // views::MenuButton:
76 const char* GetClassName() const override; 70 const char* GetClassName() const override;
77 std::unique_ptr<views::LabelButtonBorder> CreateDefaultBorder() 71 std::unique_ptr<views::LabelButtonBorder> CreateDefaultBorder()
78 const override; 72 const override;
79 gfx::Rect GetThemePaintRect() const override; 73 gfx::Rect GetThemePaintRect() const override;
80 bool GetDropFormats( 74 bool GetDropFormats(
81 int* formats, 75 int* formats,
82 std::set<ui::Clipboard::FormatType>* format_types) override; 76 std::set<ui::Clipboard::FormatType>* format_types) override;
83 bool AreDropTypesRequired() override; 77 bool AreDropTypesRequired() override;
84 bool CanDrop(const ui::OSExchangeData& data) override; 78 bool CanDrop(const ui::OSExchangeData& data) override;
85 void OnDragEntered(const ui::DropTargetEvent& event) override; 79 void OnDragEntered(const ui::DropTargetEvent& event) override;
86 int OnDragUpdated(const ui::DropTargetEvent& event) override; 80 int OnDragUpdated(const ui::DropTargetEvent& event) override;
87 void OnDragExited() override; 81 void OnDragExited() override;
88 int OnPerformDrop(const ui::DropTargetEvent& event) override; 82 int OnPerformDrop(const ui::DropTargetEvent& event) override;
89 void OnPaint(gfx::Canvas* canvas) override;
90 83
91 // Only used in pre-MD. 84 AppMenuIconController::Severity severity_;
92 std::unique_ptr<AppMenuIconPainter> icon_painter_;
93
94 // Only used in MD.
95 AppMenuIconPainter::Severity severity_;
96 AppMenuIconController::IconType type_; 85 AppMenuIconController::IconType type_;
97 86
98 // Our owning toolbar view. 87 // Our owning toolbar view.
99 ToolbarView* toolbar_view_; 88 ToolbarView* toolbar_view_;
100 89
101 // Whether or not we should allow dragging extension icons onto this button 90 // Whether or not we should allow dragging extension icons onto this button
102 // (in order to open the overflow in the app menu). 91 // (in order to open the overflow in the app menu).
103 bool allow_extension_dragging_; 92 bool allow_extension_dragging_;
104 93
105 // Listeners to call when the menu opens. 94 // Listeners to call when the menu opens.
106 base::ObserverList<views::MenuListener> menu_listeners_; 95 base::ObserverList<views::MenuListener> menu_listeners_;
107 96
108 // App model and menu. 97 // App model and menu.
109 // Note that the menu should be destroyed before the model it uses, so the 98 // Note that the menu should be destroyed before the model it uses, so the
110 // menu should be listed later. 99 // menu should be listed later.
111 std::unique_ptr<AppMenuModel> menu_model_; 100 std::unique_ptr<AppMenuModel> menu_model_;
112 std::unique_ptr<AppMenu> menu_; 101 std::unique_ptr<AppMenu> menu_;
113 102
114 // Any trailing margin to be applied. Used when the browser is in 103 // Any trailing margin to be applied. Used when the browser is in
115 // a maximized state to extend to the full window width. 104 // a maximized state to extend to the full window width.
116 int margin_trailing_; 105 int margin_trailing_;
117 106
118 // Used to spawn weak pointers for delayed tasks to open the overflow menu. 107 // Used to spawn weak pointers for delayed tasks to open the overflow menu.
119 base::WeakPtrFactory<AppMenuButton> weak_factory_; 108 base::WeakPtrFactory<AppMenuButton> weak_factory_;
120 109
121 DISALLOW_COPY_AND_ASSIGN(AppMenuButton); 110 DISALLOW_COPY_AND_ASSIGN(AppMenuButton);
122 }; 111 };
123 112
124 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_BUTTON_H_ 113 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_BUTTON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698