1 // Copyright 2019 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. 4 5 #ifndef CHROME_BROWSER_UI_EXTENSIONS_EXTENSIONS_CONTAINER_H_ 6 #define CHROME_BROWSER_UI_EXTENSIONS_EXTENSIONS_CONTAINER_H_ 7 8 #include <string> 9 10 #include "base/callback_forward.h" 11 #include "chrome/browser/extensions/extension_context_menu_model.h" 12 13 class ToolbarActionViewController; 14 class ToolbarActionsBarBubbleDelegate; 15 16 // An interface for containers in the toolbar that host extensions. 17 class ExtensionsContainer { 18 public: 19 // Returns the action for the given |id|, if one exists. 20 virtual ToolbarActionViewController* GetActionForId( 21 const std::string& action_id) = 0; 22 23 // Get the currently popped out action if any. 24 // TODO(pbos): Consider supporting multiple popped out actions for bubbles 25 // that relate to more than one extension. 26 virtual ToolbarActionViewController* GetPoppedOutAction() const = 0; 27 28 // Called when a context menu is shown so the container can perform any 29 // necessary setup. OnContextMenuShown(ToolbarActionViewController * extension)30 virtual void OnContextMenuShown(ToolbarActionViewController* extension) {} 31 32 // Called when a context menu is closed so the container can perform any 33 // necessary cleanup. OnContextMenuClosed(ToolbarActionViewController * extension)34 virtual void OnContextMenuClosed(ToolbarActionViewController* extension) {} 35 36 // Returns true if the given |action| is visible on the toolbar. 37 virtual bool IsActionVisibleOnToolbar( 38 const ToolbarActionViewController* action) const = 0; 39 40 // Returns the action's toolbar button visibility. 41 virtual extensions::ExtensionContextMenuModel::ButtonVisibility 42 GetActionVisibility(const ToolbarActionViewController* action) const = 0; 43 44 // Undoes the current "pop out"; i.e., moves the popped out action back into 45 // overflow. 46 virtual void UndoPopOut() = 0; 47 48 // Sets the active popup owner to be |popup_owner|. 49 virtual void SetPopupOwner(ToolbarActionViewController* popup_owner) = 0; 50 51 // Hides the actively showing popup, if any. 52 virtual void HideActivePopup() = 0; 53 54 // Closes the overflow menu, if it was open. Returns whether or not the 55 // overflow menu was closed. 56 virtual bool CloseOverflowMenuIfOpen() = 0; 57 58 // Pops out a given |action|, ensuring it is visible. 59 // |is_sticky| refers to whether or not the action will stay popped out if 60 // the overflow menu is opened. 61 // |closure| will be called once any animation is complete. 62 virtual void PopOutAction(ToolbarActionViewController* action, 63 bool is_sticky, 64 const base::Closure& closure) = 0; 65 66 // Shows the popup for the action with |id| as the result of an API call, 67 // returning true if a popup is shown. 68 virtual bool ShowToolbarActionPopupForAPICall( 69 const std::string& action_id) = 0; 70 71 // Displays the given |bubble| once the toolbar is no longer animating. 72 virtual void ShowToolbarActionBubble( 73 std::unique_ptr<ToolbarActionsBarBubbleDelegate> bubble) = 0; 74 75 // Same as above, but uses PostTask() in all cases. 76 virtual void ShowToolbarActionBubbleAsync( 77 std::unique_ptr<ToolbarActionsBarBubbleDelegate> bubble) = 0; 78 }; 79 80 #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSIONS_CONTAINER_H_ 81