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

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

Issue 1409183003: Adds ripple animation to extension buttons on a toolbar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adds ripple animation to extension buttons on a toolbar Created 5 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_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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 94
92 ToolbarActionViewController* view_controller() { 95 ToolbarActionViewController* view_controller() {
93 return view_controller_; 96 return view_controller_;
94 } 97 }
95 98
96 // Returns button icon so it can be accessed during tests. 99 // Returns button icon so it can be accessed during tests.
97 gfx::ImageSkia GetIconForTest(); 100 gfx::ImageSkia GetIconForTest();
98 101
99 bool wants_to_run_for_testing() const { return wants_to_run_; } 102 bool wants_to_run_for_testing() const { return wants_to_run_; }
100 103
104 // views::InkDropHost:
105 void AddInkDropLayer(ui::Layer* ink_drop_layer) override;
106 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override;
107
108 protected:
109 // Returns the Point where the ink drop should be centered.
110 virtual gfx::Point CalculateInkDropCenter() const;
111
112 views::InkDropAnimationController* ink_drop_animation_controller() {
113 return ink_drop_animation_controller_.get();
114 }
115
101 private: 116 private:
102 // views::MenuButton: 117 // views::MenuButton:
103 gfx::Size GetPreferredSize() const override; 118 gfx::Size GetPreferredSize() const override;
119 void Layout() override;
120 bool OnMousePressed(const ui::MouseEvent& event) override;
121 void OnMouseReleased(const ui::MouseEvent& event) override;
104 void OnDragDone() override; 122 void OnDragDone() override;
105 void ViewHierarchyChanged( 123 void ViewHierarchyChanged(
106 const ViewHierarchyChangedDetails& details) override; 124 const ViewHierarchyChangedDetails& details) override;
107 125
108 // ToolbarActionViewDelegateViews: 126 // ToolbarActionViewDelegateViews:
109 views::View* GetAsView() override; 127 views::View* GetAsView() override;
110 views::FocusManager* GetFocusManagerForAccelerator() override; 128 views::FocusManager* GetFocusManagerForAccelerator() override;
111 views::View* GetReferenceViewForPopup() override; 129 views::View* GetReferenceViewForPopup() override;
112 bool IsMenuRunning() const override; 130 bool IsMenuRunning() const override;
113 void OnPopupShown(bool by_user) override; 131 void OnPopupShown(bool by_user) override;
(...skipping 25 matching lines...) Expand all
139 // Delegate that usually represents a container for ToolbarActionView. 157 // Delegate that usually represents a container for ToolbarActionView.
140 Delegate* delegate_; 158 Delegate* delegate_;
141 159
142 // Used to make sure we only register the command once. 160 // Used to make sure we only register the command once.
143 bool called_register_command_; 161 bool called_register_command_;
144 162
145 // The cached value of whether or not the action wants to run on the current 163 // The cached value of whether or not the action wants to run on the current
146 // tab. 164 // tab.
147 bool wants_to_run_; 165 bool wants_to_run_;
148 166
167 // Animation controller for the ink drop ripple effect.
168 scoped_ptr<views::InkDropAnimationController> ink_drop_animation_controller_;
169
149 // Responsible for running the menu. 170 // Responsible for running the menu.
150 scoped_ptr<views::MenuRunner> menu_runner_; 171 scoped_ptr<views::MenuRunner> menu_runner_;
151 172
152 // If non-null, this is the next toolbar action context menu that wants to run 173 // If non-null, this is the next toolbar action context menu that wants to run
153 // once the current owner (this one) is done. 174 // once the current owner (this one) is done.
154 base::Closure followup_context_menu_task_; 175 base::Closure followup_context_menu_task_;
155 176
156 // The time the popup was last closed. 177 // The time the popup was last closed.
157 base::TimeTicks popup_closed_time_; 178 base::TimeTicks popup_closed_time_;
158 179
159 content::NotificationRegistrar registrar_; 180 content::NotificationRegistrar registrar_;
160 181
161 base::WeakPtrFactory<ToolbarActionView> weak_factory_; 182 base::WeakPtrFactory<ToolbarActionView> weak_factory_;
162 183
163 DISALLOW_COPY_AND_ASSIGN(ToolbarActionView); 184 DISALLOW_COPY_AND_ASSIGN(ToolbarActionView);
164 }; 185 };
165 186
166 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_H_ 187 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698