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/memory/weak_ptr.h" |
9 #include "base/scoped_observer.h" | 9 #include "base/scoped_observer.h" |
10 #include "chrome/browser/extensions/extension_action_icon_factory.h" | 10 #include "chrome/browser/extensions/extension_action_icon_factory.h" |
11 #include "chrome/browser/extensions/extension_context_menu_model.h" | 11 #include "chrome/browser/extensions/extension_context_menu_model.h" |
| 12 #include "chrome/browser/extensions/sidebar_manager_observer.h" |
12 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" | 13 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" |
13 #include "extensions/browser/extension_host_observer.h" | 14 #include "extensions/browser/extension_host_observer.h" |
14 #include "ui/gfx/image/image.h" | 15 #include "ui/gfx/image/image.h" |
15 | 16 |
16 class Browser; | 17 class Browser; |
17 class ExtensionAction; | 18 class ExtensionAction; |
18 class ExtensionActionPlatformDelegate; | 19 class ExtensionActionPlatformDelegate; |
19 class GURL; | 20 class GURL; |
20 class ToolbarActionsBar; | 21 class ToolbarActionsBar; |
21 | 22 |
22 namespace extensions { | 23 namespace extensions { |
23 class Command; | 24 class Command; |
24 class Extension; | 25 class Extension; |
25 class ExtensionRegistry; | 26 class ExtensionRegistry; |
26 class ExtensionViewHost; | 27 class ExtensionViewHost; |
27 } | 28 } |
28 | 29 |
29 // The platform-independent controller for an ExtensionAction that is shown on | 30 // The platform-independent controller for an ExtensionAction that is shown on |
30 // the toolbar (such as a page or browser action). | 31 // the toolbar (such as a page or browser action). |
31 // Since this class doesn't own the extension or extension action in question, | 32 // Since this class doesn't own the extension or extension action in question, |
32 // be sure to check for validity using ExtensionIsValid() before using those | 33 // be sure to check for validity using ExtensionIsValid() before using those |
33 // members (see also comments above ExtensionIsValid()). | 34 // members (see also comments above ExtensionIsValid()). |
34 class ExtensionActionViewController | 35 class ExtensionActionViewController |
35 : public ToolbarActionViewController, | 36 : public ToolbarActionViewController, |
36 public ExtensionActionIconFactory::Observer, | 37 public ExtensionActionIconFactory::Observer, |
37 public ExtensionContextMenuModel::PopupDelegate, | 38 public ExtensionContextMenuModel::PopupDelegate, |
| 39 public SidebarManagerObserver, |
38 public extensions::ExtensionHostObserver { | 40 public extensions::ExtensionHostObserver { |
39 public: | 41 public: |
40 // The different options for showing a popup. | 42 // The different options for showing a popup. |
41 enum PopupShowAction { SHOW_POPUP, SHOW_POPUP_AND_INSPECT }; | 43 enum PopupShowAction { SHOW_POPUP, SHOW_POPUP_AND_INSPECT }; |
42 | 44 |
43 ExtensionActionViewController(const extensions::Extension* extension, | 45 ExtensionActionViewController(const extensions::Extension* extension, |
44 Browser* browser, | 46 Browser* browser, |
45 ExtensionAction* extension_action, | 47 ExtensionAction* extension_action, |
46 ToolbarActionsBar* toolbar_actions_bar); | 48 ToolbarActionsBar* toolbar_actions_bar); |
47 ~ExtensionActionViewController() override; | 49 ~ExtensionActionViewController() override; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 bool grant_tab_permissions); | 130 bool grant_tab_permissions); |
129 | 131 |
130 // Shows the popup with the given |host|. | 132 // Shows the popup with the given |host|. |
131 void ShowPopup(scoped_ptr<extensions::ExtensionViewHost> host, | 133 void ShowPopup(scoped_ptr<extensions::ExtensionViewHost> host, |
132 bool grant_tab_permissions, | 134 bool grant_tab_permissions, |
133 PopupShowAction show_action); | 135 PopupShowAction show_action); |
134 | 136 |
135 // Handles cleanup after the popup closes. | 137 // Handles cleanup after the popup closes. |
136 void OnPopupClosed(); | 138 void OnPopupClosed(); |
137 | 139 |
| 140 void OnPopupShown(bool grant_tab_permissions); |
| 141 |
| 142 // Handles sidebar events |
| 143 void OnSidebarHidden(content::WebContents* tab, |
| 144 const std::string& content_id) override; |
| 145 |
| 146 void OnSidebarSwitched(content::WebContents* old_tab, |
| 147 const std::string& old_content_id, |
| 148 content::WebContents* new_tab, |
| 149 const std::string& new_content_id) override; |
| 150 |
138 // The extension associated with the action we're displaying. | 151 // The extension associated with the action we're displaying. |
139 scoped_refptr<const extensions::Extension> extension_; | 152 scoped_refptr<const extensions::Extension> extension_; |
140 | 153 |
141 // The corresponding browser. | 154 // The corresponding browser. |
142 Browser* browser_; | 155 Browser* browser_; |
143 | 156 |
144 // The browser action this view represents. The ExtensionAction is not owned | 157 // The browser action this view represents. The ExtensionAction is not owned |
145 // by this class. | 158 // by this class. |
146 ExtensionAction* extension_action_; | 159 ExtensionAction* extension_action_; |
147 | 160 |
(...skipping 25 matching lines...) Expand all Loading... |
173 // An additional observer that we need to notify when the icon of the button | 186 // An additional observer that we need to notify when the icon of the button |
174 // has been updated. | 187 // has been updated. |
175 ExtensionActionIconFactory::Observer* icon_observer_; | 188 ExtensionActionIconFactory::Observer* icon_observer_; |
176 | 189 |
177 // The associated ExtensionRegistry; cached for quick checking. | 190 // The associated ExtensionRegistry; cached for quick checking. |
178 extensions::ExtensionRegistry* extension_registry_; | 191 extensions::ExtensionRegistry* extension_registry_; |
179 | 192 |
180 ScopedObserver<extensions::ExtensionHost, extensions::ExtensionHostObserver> | 193 ScopedObserver<extensions::ExtensionHost, extensions::ExtensionHostObserver> |
181 popup_host_observer_; | 194 popup_host_observer_; |
182 | 195 |
| 196 std::set<content::WebContents*> active_in_webcontents_; |
| 197 |
183 base::WeakPtrFactory<ExtensionActionViewController> weak_factory_; | 198 base::WeakPtrFactory<ExtensionActionViewController> weak_factory_; |
184 | 199 |
185 DISALLOW_COPY_AND_ASSIGN(ExtensionActionViewController); | 200 DISALLOW_COPY_AND_ASSIGN(ExtensionActionViewController); |
186 }; | 201 }; |
187 | 202 |
188 #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ACTION_VIEW_CONTROLLER_H_ | 203 #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ACTION_VIEW_CONTROLLER_H_ |
OLD | NEW |