Chromium Code Reviews| 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" | 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 Loading... | |
| 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 22 matching lines...) Expand all Loading... | |
| 75 | 77 |
| 76 // views::MenuButtonListener: | 78 // views::MenuButtonListener: |
| 77 void OnMenuButtonClicked(views::View* sender, | 79 void OnMenuButtonClicked(views::View* sender, |
| 78 const gfx::Point& point) override; | 80 const gfx::Point& point) override; |
| 79 | 81 |
| 80 // content::NotificationObserver: | 82 // content::NotificationObserver: |
| 81 void Observe(int type, | 83 void Observe(int type, |
| 82 const content::NotificationSource& source, | 84 const content::NotificationSource& source, |
| 83 const content::NotificationDetails& details) override; | 85 const content::NotificationDetails& details) override; |
| 84 | 86 |
| 85 // views::MenuButton: | 87 // views::MenuButton: |
|
Peter Kasting
2015/11/24 20:42:01
WHile here: Group these MenuButton overrides with
varkha
2015/11/24 21:50:44
Done.
| |
| 86 scoped_ptr<views::LabelButtonBorder> CreateDefaultBorder() const override; | 88 scoped_ptr<views::LabelButtonBorder> CreateDefaultBorder() const override; |
| 87 void OnMouseEntered(const ui::MouseEvent& event) override; | 89 void OnMouseEntered(const ui::MouseEvent& event) override; |
| 88 bool ShouldEnterPushedState(const ui::Event& event) override; | 90 bool ShouldEnterPushedState(const ui::Event& event) override; |
| 89 | 91 |
| 90 // ToolbarActionViewDelegate: (public because called by others). | 92 // ToolbarActionViewDelegate: (public because called by others). |
|
Peter Kasting
2015/11/24 20:42:01
While here: Change this base class name to Toolbar
varkha
2015/11/24 21:50:44
Done.
| |
| 91 void UpdateState() override; | 93 void UpdateState() override; |
| 92 content::WebContents* GetCurrentWebContents() const override; | 94 content::WebContents* GetCurrentWebContents() const override; |
| 93 | 95 |
| 94 ToolbarActionViewController* view_controller() { | 96 ToolbarActionViewController* view_controller() { |
| 95 return view_controller_; | 97 return view_controller_; |
| 96 } | 98 } |
| 97 | 99 |
| 98 // Returns button icon so it can be accessed during tests. | 100 // Returns button icon so it can be accessed during tests. |
| 99 gfx::ImageSkia GetIconForTest(); | 101 gfx::ImageSkia GetIconForTest(); |
| 100 | 102 |
| 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*)>; |
|
Peter Kasting
2015/11/24 20:42:01
While here: Move this typedef up by the member cla
varkha
2015/11/24 21:50:44
Done.
| |
| 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: | |
|
Peter Kasting
2015/11/24 20:42:01
Place this above with the other override groups.
varkha
2015/11/24 21:50:44
Done.
| |
| 114 void AddInkDropLayer(ui::Layer* ink_drop_layer) override; | |
| 115 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override; | |
| 116 | |
| 117 protected: | |
|
Peter Kasting
2015/11/24 20:42:01
Are there subclasses that actually call these? If
varkha
2015/11/24 21:50:44
Done.
| |
| 118 // views::InkDropHost: | |
| 119 gfx::Point CalculateInkDropCenter() const override; | |
| 120 | |
| 121 // views::View: | |
|
Peter Kasting
2015/11/24 20:42:01
You don't directly subclass views::View. This sho
varkha
2015/11/24 21:50:44
Done.
| |
| 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 Loading... | |
| 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_ |
| OLD | NEW |