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

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

Issue 1411833006: Refactoring to make adding ink drop animations easier (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Attempt to refactor ink drop animations Created 5 years, 1 month 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_TOOLBAR_ACTION_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_H_
7 7
8 #include "chrome/browser/ui/views/toolbar/toolbar_action_view_delegate_views.h" 8 #include "chrome/browser/ui/views/toolbar/toolbar_action_view_delegate_views.h"
9 #include "content/public/browser/notification_observer.h" 9 #include "content/public/browser/notification_observer.h"
10 #include "content/public/browser/notification_registrar.h" 10 #include "content/public/browser/notification_registrar.h"
11 #include "ui/views/animation/ink_drop_host.h"
11 #include "ui/views/context_menu_controller.h" 12 #include "ui/views/context_menu_controller.h"
12 #include "ui/views/controls/button/menu_button.h" 13 #include "ui/views/controls/button/menu_button.h"
13 #include "ui/views/controls/button/menu_button_listener.h" 14 #include "ui/views/controls/button/menu_button_listener.h"
14 #include "ui/views/drag_controller.h" 15 #include "ui/views/drag_controller.h"
15 #include "ui/views/view.h" 16 #include "ui/views/view.h"
16 17
17 class ExtensionAction; 18 class ExtensionAction;
18 class Profile; 19 class Profile;
19 20
20 namespace extensions { 21 namespace extensions {
21 class Extension; 22 class Extension;
22 } 23 }
23 24
24 namespace gfx { 25 namespace gfx {
25 class Image; 26 class Image;
26 } 27 }
27 28
28 namespace views { 29 namespace views {
30 class InkDropAnimationController;
29 class MenuRunner; 31 class MenuRunner;
30 } 32 }
31 33
32 //////////////////////////////////////////////////////////////////////////////// 34 ////////////////////////////////////////////////////////////////////////////////
33 // ToolbarActionView 35 // ToolbarActionView
34 // A wrapper around a ToolbarActionViewController to display a toolbar action 36 // A wrapper around a ToolbarActionViewController to display a toolbar action
35 // action in the BrowserActionsContainer. 37 // action in the BrowserActionsContainer.
36 class ToolbarActionView : public views::MenuButton, 38 class ToolbarActionView : public views::MenuButton,
37 public ToolbarActionViewDelegateViews, 39 public ToolbarActionViewDelegateViews,
38 public views::MenuButtonListener, 40 public views::MenuButtonListener,
39 public views::ContextMenuController, 41 public views::ContextMenuController,
40 public content::NotificationObserver { 42 public content::NotificationObserver,
43 public views::InkDropHost {
41 public: 44 public:
42 // Need DragController here because ToolbarActionView could be 45 // Need DragController here because ToolbarActionView could be
43 // dragged/dropped. 46 // dragged/dropped.
44 class Delegate : public views::DragController { 47 class Delegate : public views::DragController {
45 public: 48 public:
46 // Returns the current web contents. 49 // Returns the current web contents.
47 virtual content::WebContents* GetCurrentWebContents() = 0; 50 virtual content::WebContents* GetCurrentWebContents() = 0;
48 51
49 // Whether the container for this button is shown inside a menu. 52 // Whether the container for this button is shown inside a menu.
50 virtual bool ShownInsideMenu() const = 0; 53 virtual bool ShownInsideMenu() const = 0;
(...skipping 16 matching lines...) Expand all
67 Profile* profile, 70 Profile* profile,
68 Delegate* delegate); 71 Delegate* delegate);
69 ~ToolbarActionView() override; 72 ~ToolbarActionView() override;
70 73
71 // views::MenuButton: 74 // views::MenuButton:
72 void GetAccessibleState(ui::AXViewState* state) override; 75 void GetAccessibleState(ui::AXViewState* state) override;
73 76
74 // views::MenuButtonListener: 77 // views::MenuButtonListener:
75 void OnMenuButtonClicked(views::View* sender, 78 void OnMenuButtonClicked(views::View* sender,
76 const gfx::Point& point) override; 79 const gfx::Point& point) override;
80 void OnMenuButtonClickCanceled(views::View* sender) override;
77 81
78 // content::NotificationObserver: 82 // content::NotificationObserver:
79 void Observe(int type, 83 void Observe(int type,
80 const content::NotificationSource& source, 84 const content::NotificationSource& source,
81 const content::NotificationDetails& details) override; 85 const content::NotificationDetails& details) override;
82 86
83 // views::MenuButton: 87 // views::MenuButton:
84 scoped_ptr<views::LabelButtonBorder> CreateDefaultBorder() const override; 88 scoped_ptr<views::LabelButtonBorder> CreateDefaultBorder() const override;
85 void OnMouseEntered(const ui::MouseEvent& event) override; 89 void OnMouseEntered(const ui::MouseEvent& event) override;
86 bool ShouldEnterPushedState(const ui::Event& event) override; 90 bool ShouldEnterPushedState(const ui::Event& event) override;
87 91
88 // ToolbarActionViewDelegate: (public because called by others). 92 // ToolbarActionViewDelegate: (public because called by others).
89 void UpdateState() override; 93 void UpdateState() override;
90 content::WebContents* GetCurrentWebContents() const override; 94 content::WebContents* GetCurrentWebContents() const override;
91 95
92 ToolbarActionViewController* view_controller() { 96 ToolbarActionViewController* view_controller() {
93 return view_controller_; 97 return view_controller_;
94 } 98 }
95 99
96 // Returns button icon so it can be accessed during tests. 100 // Returns button icon so it can be accessed during tests.
97 gfx::ImageSkia GetIconForTest(); 101 gfx::ImageSkia GetIconForTest();
98 102
99 bool wants_to_run_for_testing() const { return wants_to_run_; } 103 bool wants_to_run_for_testing() const { return wants_to_run_; }
100 104
105 // views::InkDropHost:
106 void AddInkDropLayer(ui::Layer* ink_drop_layer) override;
107 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override;
108
109 protected:
110 // Returns the Point where the ink drop should be centered.
111 virtual gfx::Point CalculateInkDropCenter() const;
112
113 views::InkDropAnimationController* ink_drop_animation_controller() {
114 return ink_drop_animation_controller_.get();
115 }
116
117 views::InkDropDelegate* GetInkDropDelegate() const override;
118
101 private: 119 private:
102 // views::MenuButton: 120 // views::MenuButton:
103 gfx::Size GetPreferredSize() const override; 121 gfx::Size GetPreferredSize() const override;
122 void Layout() override;
123 bool OnMousePressed(const ui::MouseEvent& event) override;
124 void OnGestureEvent(ui::GestureEvent* event) override;
104 void OnDragDone() override; 125 void OnDragDone() override;
105 void ViewHierarchyChanged( 126 void ViewHierarchyChanged(
106 const ViewHierarchyChangedDetails& details) override; 127 const ViewHierarchyChangedDetails& details) override;
107 128
108 // ToolbarActionViewDelegateViews: 129 // ToolbarActionViewDelegateViews:
109 views::View* GetAsView() override; 130 views::View* GetAsView() override;
110 views::FocusManager* GetFocusManagerForAccelerator() override; 131 views::FocusManager* GetFocusManagerForAccelerator() override;
111 views::View* GetReferenceViewForPopup() override; 132 views::View* GetReferenceViewForPopup() override;
112 bool IsMenuRunning() const override; 133 bool IsMenuRunning() const override;
113 void OnPopupShown(bool by_user) override; 134 void OnPopupShown(bool by_user) override;
(...skipping 25 matching lines...) Expand all
139 // Delegate that usually represents a container for ToolbarActionView. 160 // Delegate that usually represents a container for ToolbarActionView.
140 Delegate* delegate_; 161 Delegate* delegate_;
141 162
142 // Used to make sure we only register the command once. 163 // Used to make sure we only register the command once.
143 bool called_register_command_; 164 bool called_register_command_;
144 165
145 // The cached value of whether or not the action wants to run on the current 166 // The cached value of whether or not the action wants to run on the current
146 // tab. 167 // tab.
147 bool wants_to_run_; 168 bool wants_to_run_;
148 169
170 // Indicates if menu is currently showing.
171 bool menu_showing_;
172
149 // Responsible for running the menu. 173 // Responsible for running the menu.
150 scoped_ptr<views::MenuRunner> menu_runner_; 174 scoped_ptr<views::MenuRunner> menu_runner_;
151 175
152 // If non-null, this is the next toolbar action context menu that wants to run 176 // If non-null, this is the next toolbar action context menu that wants to run
153 // once the current owner (this one) is done. 177 // once the current owner (this one) is done.
154 base::Closure followup_context_menu_task_; 178 base::Closure followup_context_menu_task_;
155 179
156 // The time the popup was last closed. 180 // The time the popup was last closed.
157 base::TimeTicks popup_closed_time_; 181 base::TimeTicks popup_closed_time_;
158 182
159 content::NotificationRegistrar registrar_; 183 content::NotificationRegistrar registrar_;
160 184
185 // Animation controller for the ink drop ripple effect.
186 scoped_ptr<views::InkDropAnimationController> ink_drop_animation_controller_;
187
188 scoped_ptr<views::InkDropDelegate> ink_drop_delegate_;
189
161 base::WeakPtrFactory<ToolbarActionView> weak_factory_; 190 base::WeakPtrFactory<ToolbarActionView> weak_factory_;
162 191
163 DISALLOW_COPY_AND_ASSIGN(ToolbarActionView); 192 DISALLOW_COPY_AND_ASSIGN(ToolbarActionView);
164 }; 193 };
165 194
166 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_H_ 195 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698