| 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_EXTENSIONS_EXTENSION_ACTION_VIEW_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ACTION_VIEW_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ACTION_VIEW_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ACTION_VIEW_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" |
| 8 #include "base/scoped_observer.h" | 9 #include "base/scoped_observer.h" |
| 9 #include "chrome/browser/extensions/extension_action_icon_factory.h" | 10 #include "chrome/browser/extensions/extension_action_icon_factory.h" |
| 10 #include "chrome/browser/extensions/extension_context_menu_model.h" | 11 #include "chrome/browser/extensions/extension_context_menu_model.h" |
| 11 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" | 12 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" |
| 12 #include "extensions/browser/extension_host_observer.h" | 13 #include "extensions/browser/extension_host_observer.h" |
| 13 #include "ui/gfx/image/image.h" | 14 #include "ui/gfx/image/image.h" |
| 14 | 15 |
| 15 class Browser; | 16 class Browser; |
| 16 class ExtensionAction; | 17 class ExtensionAction; |
| 17 class ExtensionActionPlatformDelegate; | 18 class ExtensionActionPlatformDelegate; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 const gfx::Rect& bounds, | 69 const gfx::Rect& bounds, |
| 69 content::WebContents* web_contents) const override; | 70 content::WebContents* web_contents) const override; |
| 70 void RegisterCommand() override; | 71 void RegisterCommand() override; |
| 71 | 72 |
| 72 // ExtensionContextMenuModel::PopupDelegate: | 73 // ExtensionContextMenuModel::PopupDelegate: |
| 73 void InspectPopup() override; | 74 void InspectPopup() override; |
| 74 | 75 |
| 75 // Closes the active popup (whether it was this action's popup or not). | 76 // Closes the active popup (whether it was this action's popup or not). |
| 76 void HideActivePopup(); | 77 void HideActivePopup(); |
| 77 | 78 |
| 79 // Handles cleanup after a menu closes. |
| 80 void OnMenuClosed(); |
| 81 |
| 78 // Populates |command| with the command associated with |extension|, if one | 82 // Populates |command| with the command associated with |extension|, if one |
| 79 // exists. Returns true if |command| was populated. | 83 // exists. Returns true if |command| was populated. |
| 80 bool GetExtensionCommand(extensions::Command* command); | 84 bool GetExtensionCommand(extensions::Command* command); |
| 81 | 85 |
| 82 const extensions::Extension* extension() const { return extension_; } | 86 const extensions::Extension* extension() const { return extension_; } |
| 83 Browser* browser() { return browser_; } | 87 Browser* browser() { return browser_; } |
| 84 ExtensionAction* extension_action() { return extension_action_; } | 88 ExtensionAction* extension_action() { return extension_action_; } |
| 85 const ExtensionAction* extension_action() const { return extension_action_; } | 89 const ExtensionAction* extension_action() const { return extension_action_; } |
| 86 ToolbarActionViewDelegate* view_delegate() { return view_delegate_; } | 90 ToolbarActionViewDelegate* view_delegate() { return view_delegate_; } |
| 87 bool is_showing_popup() const { return popup_host_ != nullptr; } | 91 bool is_showing_popup() const { return popup_host_ != nullptr; } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 107 // ToolbarActionViewController should be used for showing popups. This | 111 // ToolbarActionViewController should be used for showing popups. This |
| 108 // returns the preferred controller. | 112 // returns the preferred controller. |
| 109 ExtensionActionViewController* GetPreferredPopupViewController(); | 113 ExtensionActionViewController* GetPreferredPopupViewController(); |
| 110 | 114 |
| 111 // Executes the extension action with |show_action|. If | 115 // Executes the extension action with |show_action|. If |
| 112 // |grant_tab_permissions| is true, this will grant the extension active tab | 116 // |grant_tab_permissions| is true, this will grant the extension active tab |
| 113 // permissions. Only do this if this was done through a user action (and not | 117 // permissions. Only do this if this was done through a user action (and not |
| 114 // e.g. an API). Returns true if a popup is shown. | 118 // e.g. an API). Returns true if a popup is shown. |
| 115 bool ExecuteAction(PopupShowAction show_action, bool grant_tab_permissions); | 119 bool ExecuteAction(PopupShowAction show_action, bool grant_tab_permissions); |
| 116 | 120 |
| 117 // Shows the popup for the extension action, given the associated |popup_url|. | 121 // Begins the process of showing the popup for the extension action, given the |
| 118 // |grant_tab_permissions| is true if active tab permissions should be given | 122 // associated |popup_url|. |grant_tab_permissions| is true if active tab |
| 119 // to the extension; this is only true if the popup is opened through a user | 123 // permissions should be given to the extension; this is only true if the |
| 120 // action. | 124 // popup is opened through a user action. |
| 121 // Returns true if a popup is successfully shown. | 125 // The popup may not be shown synchronously if the extension is hidden and |
| 122 bool ShowPopupWithUrl(PopupShowAction show_action, | 126 // first needs to slide itself out. |
| 123 const GURL& popup_url, | 127 // Returns true if a popup will be shown. |
| 124 bool grant_tab_permissions); | 128 bool TriggerPopupWithUrl(PopupShowAction show_action, |
| 129 const GURL& popup_url, |
| 130 bool grant_tab_permissions); |
| 131 |
| 132 // Shows the popup with the given |host|. |
| 133 void ShowPopup(scoped_ptr<extensions::ExtensionViewHost> host, |
| 134 bool grant_tab_permissions, |
| 135 PopupShowAction show_action); |
| 125 | 136 |
| 126 // Handles cleanup after the popup closes. | 137 // Handles cleanup after the popup closes. |
| 127 void OnPopupClosed(); | 138 void OnPopupClosed(); |
| 128 | 139 |
| 129 // The extension associated with the action we're displaying. | 140 // The extension associated with the action we're displaying. |
| 130 const extensions::Extension* extension_; | 141 const extensions::Extension* extension_; |
| 131 | 142 |
| 132 // The corresponding browser. | 143 // The corresponding browser. |
| 133 Browser* browser_; | 144 Browser* browser_; |
| 134 | 145 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 164 // An additional observer that we need to notify when the icon of the button | 175 // An additional observer that we need to notify when the icon of the button |
| 165 // has been updated. | 176 // has been updated. |
| 166 ExtensionActionIconFactory::Observer* icon_observer_; | 177 ExtensionActionIconFactory::Observer* icon_observer_; |
| 167 | 178 |
| 168 // The associated ExtensionRegistry; cached for quick checking. | 179 // The associated ExtensionRegistry; cached for quick checking. |
| 169 extensions::ExtensionRegistry* extension_registry_; | 180 extensions::ExtensionRegistry* extension_registry_; |
| 170 | 181 |
| 171 ScopedObserver<extensions::ExtensionHost, extensions::ExtensionHostObserver> | 182 ScopedObserver<extensions::ExtensionHost, extensions::ExtensionHostObserver> |
| 172 popup_host_observer_; | 183 popup_host_observer_; |
| 173 | 184 |
| 185 base::WeakPtrFactory<ExtensionActionViewController> weak_factory_; |
| 186 |
| 174 DISALLOW_COPY_AND_ASSIGN(ExtensionActionViewController); | 187 DISALLOW_COPY_AND_ASSIGN(ExtensionActionViewController); |
| 175 }; | 188 }; |
| 176 | 189 |
| 177 #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ACTION_VIEW_CONTROLLER_H_ | 190 #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ACTION_VIEW_CONTROLLER_H_ |
| OLD | NEW |