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