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

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: Refactor ink drop animations (Moving more generic functionality into ScopedTargetHandler) 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 "base/callback.h" 8 #include "base/callback.h"
9 #include "chrome/browser/ui/views/toolbar/toolbar_action_view_delegate_views.h" 9 #include "chrome/browser/ui/views/toolbar/toolbar_action_view_delegate_views.h"
10 #include "content/public/browser/notification_observer.h" 10 #include "content/public/browser/notification_observer.h"
11 #include "content/public/browser/notification_registrar.h" 11 #include "content/public/browser/notification_registrar.h"
12 #include "ui/views/animation/ink_drop_host.h"
12 #include "ui/views/context_menu_controller.h" 13 #include "ui/views/context_menu_controller.h"
13 #include "ui/views/controls/button/menu_button.h" 14 #include "ui/views/controls/button/menu_button.h"
14 #include "ui/views/controls/button/menu_button_listener.h" 15 #include "ui/views/controls/button/menu_button_listener.h"
15 #include "ui/views/drag_controller.h" 16 #include "ui/views/drag_controller.h"
16 #include "ui/views/view.h" 17 #include "ui/views/view.h"
17 18
18 class ExtensionAction; 19 class ExtensionAction;
19 class Profile; 20 class Profile;
20 21
21 namespace extensions { 22 namespace extensions {
(...skipping 10 matching lines...) Expand all
32 } 33 }
33 34
34 //////////////////////////////////////////////////////////////////////////////// 35 ////////////////////////////////////////////////////////////////////////////////
35 // ToolbarActionView 36 // ToolbarActionView
36 // A wrapper around a ToolbarActionViewController to display a toolbar action 37 // A wrapper around a ToolbarActionViewController to display a toolbar action
37 // action in the BrowserActionsContainer. 38 // action in the BrowserActionsContainer.
38 class ToolbarActionView : public views::MenuButton, 39 class ToolbarActionView : public views::MenuButton,
39 public ToolbarActionViewDelegateViews, 40 public ToolbarActionViewDelegateViews,
40 public views::MenuButtonListener, 41 public views::MenuButtonListener,
41 public views::ContextMenuController, 42 public views::ContextMenuController,
42 public content::NotificationObserver { 43 public content::NotificationObserver,
44 public views::InkDropHost {
43 public: 45 public:
44 // Need DragController here because ToolbarActionView could be 46 // Need DragController here because ToolbarActionView could be
45 // dragged/dropped. 47 // dragged/dropped.
46 class Delegate : public views::DragController { 48 class Delegate : public views::DragController {
47 public: 49 public:
48 // Returns the current web contents. 50 // Returns the current web contents.
49 virtual content::WebContents* GetCurrentWebContents() = 0; 51 virtual content::WebContents* GetCurrentWebContents() = 0;
50 52
51 // Whether the container for this button is shown inside a menu. 53 // Whether the container for this button is shown inside a menu.
52 virtual bool ShownInsideMenu() const = 0; 54 virtual bool ShownInsideMenu() const = 0;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 bool wants_to_run_for_testing() const { return wants_to_run_; } 103 bool wants_to_run_for_testing() const { return wants_to_run_; }
102 104
103 using ContextMenuCallback = base::Callback<void(ToolbarActionView*)>; 105 using ContextMenuCallback = base::Callback<void(ToolbarActionView*)>;
104 // Set a callback to be called directly before the context menu is shown. 106 // Set a callback to be called directly before the context menu is shown.
105 // The toolbar action opening the menu will be passed in. 107 // The toolbar action opening the menu will be passed in.
106 static void set_context_menu_callback_for_testing( 108 static void set_context_menu_callback_for_testing(
107 ContextMenuCallback* callback); 109 ContextMenuCallback* callback);
108 110
109 views::MenuItemView* menu_for_testing() { return menu_; } 111 views::MenuItemView* menu_for_testing() { return menu_; }
110 112
113 // views::InkDropHost:
114 void AddInkDropLayer(ui::Layer* ink_drop_layer) override;
115 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override;
116
117 protected:
118 // views::InkDropHost:
119 gfx::Point CalculateInkDropCenter() const override;
120
121 // views::View:
122 views::InkDropDelegate* GetInkDropDelegate() const override;
123
111 private: 124 private:
112 // views::MenuButton: 125 // views::MenuButton:
113 gfx::Size GetPreferredSize() const override; 126 gfx::Size GetPreferredSize() const override;
127 bool OnMousePressed(const ui::MouseEvent& event) override;
128 void OnGestureEvent(ui::GestureEvent* event) override;
114 void OnDragDone() override; 129 void OnDragDone() override;
115 void ViewHierarchyChanged( 130 void ViewHierarchyChanged(
116 const ViewHierarchyChangedDetails& details) override; 131 const ViewHierarchyChangedDetails& details) override;
117 132
118 // ToolbarActionViewDelegateViews: 133 // ToolbarActionViewDelegateViews:
119 views::View* GetAsView() override; 134 views::View* GetAsView() override;
120 views::FocusManager* GetFocusManagerForAccelerator() override; 135 views::FocusManager* GetFocusManagerForAccelerator() override;
121 views::View* GetReferenceViewForPopup() override; 136 views::View* GetReferenceViewForPopup() override;
122 bool IsMenuRunning() const override; 137 bool IsMenuRunning() const override;
123 void OnPopupShown(bool by_user) override; 138 void OnPopupShown(bool by_user) override;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 180
166 // If non-null, this is the next toolbar action context menu that wants to run 181 // If non-null, this is the next toolbar action context menu that wants to run
167 // once the current owner (this one) is done. 182 // once the current owner (this one) is done.
168 base::Closure followup_context_menu_task_; 183 base::Closure followup_context_menu_task_;
169 184
170 // The time the popup was last closed. 185 // The time the popup was last closed.
171 base::TimeTicks popup_closed_time_; 186 base::TimeTicks popup_closed_time_;
172 187
173 content::NotificationRegistrar registrar_; 188 content::NotificationRegistrar registrar_;
174 189
190 // Animation delegate for the ink drop ripple effect.
191 scoped_ptr<views::InkDropDelegate> ink_drop_delegate_;
192
175 base::WeakPtrFactory<ToolbarActionView> weak_factory_; 193 base::WeakPtrFactory<ToolbarActionView> weak_factory_;
176 194
177 DISALLOW_COPY_AND_ASSIGN(ToolbarActionView); 195 DISALLOW_COPY_AND_ASSIGN(ToolbarActionView);
178 }; 196 };
179 197
180 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_H_ 198 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698