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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_ACTION_VIEW_DELEGATE_H_
6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_ACTION_VIEW_DELEGATE_H_
18 // The view that surrounds an ExtensionAction and owns the
19 // ExtensionActionViewController. Since different actions can subclass
20 // different views, we don't derive views::View directly here.
21 class ExtensionActionViewDelegate {
23 // Returns |this| as a view. We need this because our subclasses implement
24 // different kinds of views, and inheriting View here is a really bad idea.
25 virtual views::View* GetAsView() = 0;
27 // Returns true if this view is being shown inside a menu.
28 virtual bool IsShownInMenu() = 0;
30 // Returns the FocusManager to use when registering accelerators.
31 virtual views::FocusManager* GetFocusManagerForAccelerator() = 0;
33 // Returns the parent for the associated context menu.
34 virtual views::Widget* GetParentForContextMenu() = 0;
36 // Returns the reference view for the extension action's popup.
37 virtual views::View* GetReferenceViewForPopup() = 0;
39 // Returns the current web contents.
40 virtual content::WebContents* GetCurrentWebContents() = 0;
42 // Hides whatever popup is active (even if it's not this one).
43 virtual void HideActivePopup() = 0;
45 // Called when the icon is updated; this is forwarded from the icon factory.
46 virtual void OnIconUpdated() = 0;
48 // Called when a popup is shown. See ExecuteAction() for the definition of
49 // |grant_tab_permissions|.
50 virtual void OnPopupShown(bool grant_tab_permissions) {}
52 // Does any additional cleanup after the popup is closed.
53 virtual void CleanupPopup() {}
55 // Called immediately before the context menu is shown.
56 virtual void OnWillShowContextMenus() {}
58 // Called once the context menu has closed.
59 // This may not be called if the context menu is showing and |this| is
61 virtual void OnContextMenuDone() {}
64 virtual ~ExtensionActionViewDelegate() {}
67 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_ACTION_VIEW_DELEGATE_H_