OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_DELEGATE_VIEWS_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_DELEGATE_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_DELEGATE_VIEWS_H_ |
7 | 7 |
8 namespace content { | 8 #include "chrome/browser/ui/toolbar/toolbar_action_view_delegate.h" |
9 class WebContents; | |
10 } | |
11 | 9 |
12 namespace views { | 10 namespace views { |
13 class FocusManager; | 11 class FocusManager; |
14 class MenuButton; | 12 class MenuButton; |
15 class View; | 13 class View; |
16 class Widget; | 14 class Widget; |
17 } | 15 } |
18 | 16 |
19 class ToolbarActionViewController; | 17 // The views-specific methods necessary for a ToolbarActionViewDelegate. |
20 | 18 class ToolbarActionViewDelegateViews : public ToolbarActionViewDelegate { |
21 // The view that surrounds an ToolbarAction and owns the | |
22 // ToolbarActionViewController. Since different actions can subclass | |
23 // different views, we don't derive views::View directly here. | |
24 class ToolbarActionViewDelegate { | |
25 public: | 19 public: |
26 // Returns |this| as a view. We need this because our subclasses implement | 20 // Returns |this| as a view. We need this because our subclasses implement |
27 // different kinds of views, and inheriting View here is a really bad idea. | 21 // different kinds of views, and inheriting View here is a really bad idea. |
28 virtual views::View* GetAsView() = 0; | 22 virtual views::View* GetAsView() = 0; |
29 | 23 |
30 // Returns true if this view is being shown inside a menu. | 24 // Returns true if this view is being shown inside a menu. |
31 virtual bool IsShownInMenu() = 0; | 25 virtual bool IsShownInMenu() = 0; |
32 | 26 |
33 // Returns the FocusManager to use when registering accelerators. | 27 // Returns the FocusManager to use when registering accelerators. |
34 virtual views::FocusManager* GetFocusManagerForAccelerator() = 0; | 28 virtual views::FocusManager* GetFocusManagerForAccelerator() = 0; |
35 | 29 |
36 // Returns the parent for the associated context menu. | 30 // Returns the parent for the associated context menu. |
37 virtual views::Widget* GetParentForContextMenu() = 0; | 31 virtual views::Widget* GetParentForContextMenu() = 0; |
38 | 32 |
39 // In some cases (such as when an action is shown in a menu), a substitute | |
40 // ToolbarActionViewController should be used for showing popups. This | |
41 // returns the preferred control. | |
42 virtual ToolbarActionViewController* GetPreferredPopupViewController() = 0; | |
43 | |
44 // Returns the reference view for the extension action's popup. | 33 // Returns the reference view for the extension action's popup. |
45 virtual views::View* GetReferenceViewForPopup() = 0; | 34 virtual views::View* GetReferenceViewForPopup() = 0; |
46 | 35 |
47 // Returns the MenuButton (if any) to use in showing the context menu (this | 36 // Returns the MenuButton (if any) to use in showing the context menu (this |
48 // allows views code to update the pressed state of the button). | 37 // allows views code to update the pressed state of the button). |
49 virtual views::MenuButton* GetContextMenuButton() = 0; | 38 virtual views::MenuButton* GetContextMenuButton() = 0; |
50 | 39 |
51 // Returns the current web contents. | |
52 virtual content::WebContents* GetCurrentWebContents() const = 0; | |
53 | |
54 // Hides whatever popup is active (even if it's not this one). | 40 // Hides whatever popup is active (even if it's not this one). |
55 virtual void HideActivePopup() = 0; | 41 virtual void HideActivePopup() = 0; |
56 | 42 |
57 // Called when the icon is updated; this is forwarded from the icon factory. | |
58 virtual void OnIconUpdated() = 0; | |
59 | |
60 // Called when a popup is shown. See ExecuteAction() for the definition of | 43 // Called when a popup is shown. See ExecuteAction() for the definition of |
61 // |grant_tab_permissions|. | 44 // |grant_tab_permissions|. |
62 virtual void OnPopupShown(bool grant_tab_permissions) {} | 45 virtual void OnPopupShown(bool grant_tab_permissions) {} |
63 | 46 |
64 // Does any additional cleanup after the popup is closed. | 47 // Does any additional cleanup after the popup is closed. |
65 virtual void CleanupPopup() {} | 48 virtual void CleanupPopup() {} |
66 | 49 |
67 protected: | 50 protected: |
68 virtual ~ToolbarActionViewDelegate() {} | 51 virtual ~ToolbarActionViewDelegateViews() {} |
69 }; | 52 }; |
70 | 53 |
71 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_DELEGATE_H_ | 54 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_DELEGATE_VIEWS_H_ |
OLD | NEW |