OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_EXTENSIONS_TAB_HELPER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_TAB_HELPER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_TAB_HELPER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_TAB_HELPER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
16 #include "base/scoped_observer.h" | 16 #include "base/scoped_observer.h" |
17 #include "chrome/browser/extensions/active_tab_permission_granter.h" | 17 #include "chrome/browser/extensions/active_tab_permission_granter.h" |
18 #include "chrome/browser/extensions/extension_reenabler.h" | 18 #include "chrome/browser/extensions/extension_reenabler.h" |
19 #include "chrome/common/extensions/webstore_install_result.h" | 19 #include "chrome/common/extensions/webstore_install_result.h" |
20 #include "chrome/common/web_application_info.h" | 20 #include "chrome/common/web_application_info.h" |
21 #include "content/public/browser/notification_observer.h" | 21 #include "content/public/browser/notification_observer.h" |
22 #include "content/public/browser/notification_registrar.h" | 22 #include "content/public/browser/notification_registrar.h" |
23 #include "content/public/browser/web_contents_observer.h" | 23 #include "content/public/browser/web_contents_observer.h" |
24 #include "content/public/browser/web_contents_user_data.h" | 24 #include "content/public/browser/web_contents_user_data.h" |
25 #include "extensions/browser/extension_function_dispatcher.h" | 25 #include "extensions/browser/extension_function_dispatcher.h" |
26 #include "extensions/browser/extension_registry_observer.h" | 26 #include "extensions/browser/extension_registry_observer.h" |
27 #include "extensions/browser/script_execution_observer.h" | 27 #include "extensions/browser/script_execution_observer.h" |
28 #include "extensions/browser/script_executor.h" | 28 #include "extensions/browser/script_executor.h" |
| 29 #include "extensions/common/extension_id.h" |
29 #include "extensions/common/stack_frame.h" | 30 #include "extensions/common/stack_frame.h" |
30 #include "third_party/skia/include/core/SkBitmap.h" | 31 #include "third_party/skia/include/core/SkBitmap.h" |
31 | 32 |
32 class FaviconDownloader; | 33 class FaviconDownloader; |
33 | 34 |
34 namespace content { | 35 namespace content { |
35 struct LoadCommittedDetails; | 36 struct LoadCommittedDetails; |
36 class RenderFrameHost; | 37 class RenderFrameHost; |
37 } | 38 } |
38 | 39 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // the extension. It's up to consumers of WebContents to do that. | 76 // the extension. It's up to consumers of WebContents to do that. |
76 // | 77 // |
77 // NOTE: this should only be manipulated before the tab is added to a browser. | 78 // NOTE: this should only be manipulated before the tab is added to a browser. |
78 // TODO(sky): resolve if this is the right way to identify an app tab. If it | 79 // TODO(sky): resolve if this is the right way to identify an app tab. If it |
79 // is, than this should be passed in the constructor. | 80 // is, than this should be passed in the constructor. |
80 void SetExtensionApp(const Extension* extension); | 81 void SetExtensionApp(const Extension* extension); |
81 | 82 |
82 // Convenience for setting the app extension by id. This does nothing if | 83 // Convenience for setting the app extension by id. This does nothing if |
83 // |extension_app_id| is empty, or an extension can't be found given the | 84 // |extension_app_id| is empty, or an extension can't be found given the |
84 // specified id. | 85 // specified id. |
85 void SetExtensionAppById(const std::string& extension_app_id); | 86 void SetExtensionAppById(const ExtensionId& extension_app_id); |
86 | 87 |
87 // Set just the app icon, used by panels created by an extension. | 88 // Set just the app icon, used by panels created by an extension. |
88 void SetExtensionAppIconById(const std::string& extension_app_id); | 89 void SetExtensionAppIconById(const ExtensionId& extension_app_id); |
89 | 90 |
90 const Extension* extension_app() const { return extension_app_; } | 91 const Extension* extension_app() const { return extension_app_; } |
91 bool is_app() const { return extension_app_ != NULL; } | 92 bool is_app() const { return extension_app_ != NULL; } |
92 const WebApplicationInfo& web_app_info() const { | 93 const WebApplicationInfo& web_app_info() const { |
93 return web_app_info_; | 94 return web_app_info_; |
94 } | 95 } |
95 | 96 |
96 // If an app extension has been explicitly set for this WebContents its icon | 97 // If an app extension has been explicitly set for this WebContents its icon |
97 // is returned. | 98 // is returned. |
98 // | 99 // |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 content::RenderFrameHost* host, | 187 content::RenderFrameHost* host, |
187 const ScriptExecutionObserver::ExecutingScriptsMap& extension_ids, | 188 const ScriptExecutionObserver::ExecutingScriptsMap& extension_ids, |
188 const GURL& on_url); | 189 const GURL& on_url); |
189 | 190 |
190 // App extensions related methods: | 191 // App extensions related methods: |
191 | 192 |
192 // Resets app_icon_ and if |extension| is non-null uses ImageLoader to load | 193 // Resets app_icon_ and if |extension| is non-null uses ImageLoader to load |
193 // the extension's image asynchronously. | 194 // the extension's image asynchronously. |
194 void UpdateExtensionAppIcon(const Extension* extension); | 195 void UpdateExtensionAppIcon(const Extension* extension); |
195 | 196 |
196 const Extension* GetExtension(const std::string& extension_app_id); | 197 const Extension* GetExtension(const ExtensionId& extension_app_id); |
197 | 198 |
198 void OnImageLoaded(const gfx::Image& image); | 199 void OnImageLoaded(const gfx::Image& image); |
199 | 200 |
200 // WebstoreStandaloneInstaller::Callback. | 201 // WebstoreStandaloneInstaller::Callback. |
201 void OnInlineInstallComplete(int install_id, | 202 void OnInlineInstallComplete(int install_id, |
202 int return_route_id, | 203 int return_route_id, |
203 const std::string& extension_id, | 204 const ExtensionId& extension_id, |
204 bool success, | 205 bool success, |
205 const std::string& error, | 206 const std::string& error, |
206 webstore_install::Result result); | 207 webstore_install::Result result); |
207 | 208 |
208 // ExtensionReenabler::Callback. | 209 // ExtensionReenabler::Callback. |
209 void OnReenableComplete(int install_id, | 210 void OnReenableComplete(int install_id, |
210 int return_route_id, | 211 int return_route_id, |
211 const std::string& extension_id, | 212 const ExtensionId& extension_id, |
212 ExtensionReenabler::ReenableResult result); | 213 ExtensionReenabler::ReenableResult result); |
213 | 214 |
214 // content::NotificationObserver. | 215 // content::NotificationObserver. |
215 void Observe(int type, | 216 void Observe(int type, |
216 const content::NotificationSource& source, | 217 const content::NotificationSource& source, |
217 const content::NotificationDetails& details) override; | 218 const content::NotificationDetails& details) override; |
218 | 219 |
219 // Requests application info for the specified page. This is an asynchronous | 220 // Requests application info for the specified page. This is an asynchronous |
220 // request. The delegate is notified by way of OnDidGetApplicationInfo when | 221 // request. The delegate is notified by way of OnDidGetApplicationInfo when |
221 // the data is available. | 222 // the data is available. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 // Creates WebstoreInlineInstaller instances for inline install triggers. | 268 // Creates WebstoreInlineInstaller instances for inline install triggers. |
268 std::unique_ptr<WebstoreInlineInstallerFactory> | 269 std::unique_ptr<WebstoreInlineInstallerFactory> |
269 webstore_inline_installer_factory_; | 270 webstore_inline_installer_factory_; |
270 | 271 |
271 // The reenable prompt for disabled extensions, if any. | 272 // The reenable prompt for disabled extensions, if any. |
272 std::unique_ptr<ExtensionReenabler> extension_reenabler_; | 273 std::unique_ptr<ExtensionReenabler> extension_reenabler_; |
273 | 274 |
274 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 275 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
275 registry_observer_; | 276 registry_observer_; |
276 | 277 |
277 // Map of extension id -> InlineInstallObserver for inline installations that | 278 // Map of InlineInstallObservers for inline installations that have progress |
278 // have progress listeners. | 279 // listeners. |
279 std::map<std::string, std::unique_ptr<InlineInstallObserver>> | 280 std::map<ExtensionId, std::unique_ptr<InlineInstallObserver>> |
280 install_observers_; | 281 install_observers_; |
281 | 282 |
282 // The set of extension ids that are currently being installed. | 283 // The set of extension ids that are currently being installed. |
283 std::set<std::string> pending_inline_installations_; | 284 std::set<ExtensionId> pending_inline_installations_; |
284 | 285 |
285 // Vend weak pointers that can be invalidated to stop in-progress loads. | 286 // Vend weak pointers that can be invalidated to stop in-progress loads. |
286 base::WeakPtrFactory<TabHelper> image_loader_ptr_factory_; | 287 base::WeakPtrFactory<TabHelper> image_loader_ptr_factory_; |
287 | 288 |
288 // Generic weak ptr factory for posting callbacks. | 289 // Generic weak ptr factory for posting callbacks. |
289 base::WeakPtrFactory<TabHelper> weak_ptr_factory_; | 290 base::WeakPtrFactory<TabHelper> weak_ptr_factory_; |
290 | 291 |
291 DISALLOW_COPY_AND_ASSIGN(TabHelper); | 292 DISALLOW_COPY_AND_ASSIGN(TabHelper); |
292 }; | 293 }; |
293 | 294 |
294 } // namespace extensions | 295 } // namespace extensions |
295 | 296 |
296 #endif // CHROME_BROWSER_EXTENSIONS_TAB_HELPER_H_ | 297 #endif // CHROME_BROWSER_EXTENSIONS_TAB_HELPER_H_ |
OLD | NEW |