| OLD | NEW |
| 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" | |
| 11 #include "content/public/browser/notification_registrar.h" | |
| 12 #include "ui/views/animation/ink_drop_host.h" | 10 #include "ui/views/animation/ink_drop_host.h" |
| 13 #include "ui/views/context_menu_controller.h" | 11 #include "ui/views/context_menu_controller.h" |
| 14 #include "ui/views/controls/button/menu_button.h" | 12 #include "ui/views/controls/button/menu_button.h" |
| 15 #include "ui/views/controls/button/menu_button_listener.h" | 13 #include "ui/views/controls/button/menu_button_listener.h" |
| 16 #include "ui/views/drag_controller.h" | 14 #include "ui/views/drag_controller.h" |
| 17 #include "ui/views/view.h" | 15 #include "ui/views/view.h" |
| 18 | 16 |
| 19 class ExtensionAction; | 17 class ExtensionAction; |
| 20 class Profile; | 18 class Profile; |
| 21 | 19 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 33 } | 31 } |
| 34 | 32 |
| 35 //////////////////////////////////////////////////////////////////////////////// | 33 //////////////////////////////////////////////////////////////////////////////// |
| 36 // ToolbarActionView | 34 // ToolbarActionView |
| 37 // A wrapper around a ToolbarActionViewController to display a toolbar action | 35 // A wrapper around a ToolbarActionViewController to display a toolbar action |
| 38 // action in the BrowserActionsContainer. | 36 // action in the BrowserActionsContainer. |
| 39 class ToolbarActionView : public views::MenuButton, | 37 class ToolbarActionView : public views::MenuButton, |
| 40 public ToolbarActionViewDelegateViews, | 38 public ToolbarActionViewDelegateViews, |
| 41 public views::MenuButtonListener, | 39 public views::MenuButtonListener, |
| 42 public views::ContextMenuController, | 40 public views::ContextMenuController, |
| 43 public content::NotificationObserver, | |
| 44 public views::InkDropHost { | 41 public views::InkDropHost { |
| 45 public: | 42 public: |
| 46 // Need DragController here because ToolbarActionView could be | 43 // Need DragController here because ToolbarActionView could be |
| 47 // dragged/dropped. | 44 // dragged/dropped. |
| 48 class Delegate : public views::DragController { | 45 class Delegate : public views::DragController { |
| 49 public: | 46 public: |
| 50 // Returns the current web contents. | 47 // Returns the current web contents. |
| 51 virtual content::WebContents* GetCurrentWebContents() = 0; | 48 virtual content::WebContents* GetCurrentWebContents() = 0; |
| 52 | 49 |
| 53 // Whether the container for this button is shown inside a menu. | 50 // Whether the container for this button is shown inside a menu. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 82 bool ShouldEnterPushedState(const ui::Event& event) override; | 79 bool ShouldEnterPushedState(const ui::Event& event) override; |
| 83 | 80 |
| 84 // ToolbarActionViewDelegateViews: | 81 // ToolbarActionViewDelegateViews: |
| 85 content::WebContents* GetCurrentWebContents() const override; | 82 content::WebContents* GetCurrentWebContents() const override; |
| 86 void UpdateState() override; | 83 void UpdateState() override; |
| 87 | 84 |
| 88 // views::MenuButtonListener: | 85 // views::MenuButtonListener: |
| 89 void OnMenuButtonClicked(views::View* sender, | 86 void OnMenuButtonClicked(views::View* sender, |
| 90 const gfx::Point& point) override; | 87 const gfx::Point& point) override; |
| 91 | 88 |
| 92 // content::NotificationObserver: | |
| 93 void Observe(int type, | |
| 94 const content::NotificationSource& source, | |
| 95 const content::NotificationDetails& details) override; | |
| 96 | |
| 97 // views::InkDropHost: | 89 // views::InkDropHost: |
| 98 void AddInkDropLayer(ui::Layer* ink_drop_layer) override; | 90 void AddInkDropLayer(ui::Layer* ink_drop_layer) override; |
| 99 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override; | 91 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override; |
| 100 | 92 |
| 101 ToolbarActionViewController* view_controller() { | 93 ToolbarActionViewController* view_controller() { |
| 102 return view_controller_; | 94 return view_controller_; |
| 103 } | 95 } |
| 104 | 96 |
| 105 // Returns button icon so it can be accessed during tests. | 97 // Returns button icon so it can be accessed during tests. |
| 106 gfx::ImageSkia GetIconForTest(); | 98 gfx::ImageSkia GetIconForTest(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 // shown. | 166 // shown. |
| 175 views::MenuItemView* menu_; | 167 views::MenuItemView* menu_; |
| 176 | 168 |
| 177 // If non-null, this is the next toolbar action context menu that wants to run | 169 // If non-null, this is the next toolbar action context menu that wants to run |
| 178 // once the current owner (this one) is done. | 170 // once the current owner (this one) is done. |
| 179 base::Closure followup_context_menu_task_; | 171 base::Closure followup_context_menu_task_; |
| 180 | 172 |
| 181 // The time the popup was last closed. | 173 // The time the popup was last closed. |
| 182 base::TimeTicks popup_closed_time_; | 174 base::TimeTicks popup_closed_time_; |
| 183 | 175 |
| 184 content::NotificationRegistrar registrar_; | |
| 185 | |
| 186 scoped_ptr<views::InkDropDelegate> ink_drop_delegate_; | 176 scoped_ptr<views::InkDropDelegate> ink_drop_delegate_; |
| 187 | 177 |
| 188 base::WeakPtrFactory<ToolbarActionView> weak_factory_; | 178 base::WeakPtrFactory<ToolbarActionView> weak_factory_; |
| 189 | 179 |
| 190 DISALLOW_COPY_AND_ASSIGN(ToolbarActionView); | 180 DISALLOW_COPY_AND_ASSIGN(ToolbarActionView); |
| 191 }; | 181 }; |
| 192 | 182 |
| 193 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_H_ | 183 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_H_ |
| OLD | NEW |