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