| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_EXTENSION_TAB_HELPER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_HELPER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_HELPER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_HELPER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "content/browser/tab_contents/tab_contents_observer.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "chrome/browser/extensions/app_notify_channel_setup.h" |
| 10 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 11 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 11 #include "chrome/browser/extensions/image_loading_tracker.h" | 12 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 12 #include "chrome/browser/extensions/webstore_inline_installer.h" | 13 #include "chrome/browser/extensions/webstore_inline_installer.h" |
| 13 #include "chrome/common/web_apps.h" | 14 #include "chrome/common/web_apps.h" |
| 15 #include "content/browser/tab_contents/tab_contents_observer.h" |
| 14 #include "third_party/skia/include/core/SkBitmap.h" | 16 #include "third_party/skia/include/core/SkBitmap.h" |
| 15 | 17 |
| 16 class Extension; | 18 class Extension; |
| 17 class TabContentsWrapper; | 19 class TabContentsWrapper; |
| 18 struct WebApplicationInfo; | 20 struct WebApplicationInfo; |
| 19 | 21 |
| 20 namespace content { | 22 namespace content { |
| 21 struct LoadCommittedDetails; | 23 struct LoadCommittedDetails; |
| 22 } | 24 } |
| 23 | 25 |
| 24 // Per-tab extension helper. Also handles non-extension apps. | 26 // Per-tab extension helper. Also handles non-extension apps. |
| 25 class ExtensionTabHelper : public TabContentsObserver, | 27 class ExtensionTabHelper |
| 26 public ExtensionFunctionDispatcher::Delegate, | 28 : public TabContentsObserver, |
| 27 public ImageLoadingTracker::Observer, | 29 public ExtensionFunctionDispatcher::Delegate, |
| 28 public WebstoreInlineInstaller::Delegate { | 30 public ImageLoadingTracker::Observer, |
| 31 public WebstoreInlineInstaller::Delegate, |
| 32 public AppNotifyChannelSetup::Delegate, |
| 33 public base::SupportsWeakPtr<ExtensionTabHelper> { |
| 29 public: | 34 public: |
| 30 explicit ExtensionTabHelper(TabContentsWrapper* wrapper); | 35 explicit ExtensionTabHelper(TabContentsWrapper* wrapper); |
| 31 virtual ~ExtensionTabHelper(); | 36 virtual ~ExtensionTabHelper(); |
| 32 | 37 |
| 33 // Copies the internal state from another ExtensionTabHelper. | 38 // Copies the internal state from another ExtensionTabHelper. |
| 34 void CopyStateFrom(const ExtensionTabHelper& source); | 39 void CopyStateFrom(const ExtensionTabHelper& source); |
| 35 | 40 |
| 36 // Call this after updating a page action to notify clients about the changes. | 41 // Call this after updating a page action to notify clients about the changes. |
| 37 void PageActionStateChanged(); | 42 void PageActionStateChanged(); |
| 38 | 43 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 virtual Browser* GetBrowser() OVERRIDE; | 98 virtual Browser* GetBrowser() OVERRIDE; |
| 94 virtual gfx::NativeView GetNativeViewOfHost() OVERRIDE; | 99 virtual gfx::NativeView GetNativeViewOfHost() OVERRIDE; |
| 95 virtual TabContents* GetAssociatedTabContents() const OVERRIDE; | 100 virtual TabContents* GetAssociatedTabContents() const OVERRIDE; |
| 96 | 101 |
| 97 // Message handlers. | 102 // Message handlers. |
| 98 void OnDidGetApplicationInfo(int32 page_id, const WebApplicationInfo& info); | 103 void OnDidGetApplicationInfo(int32 page_id, const WebApplicationInfo& info); |
| 99 void OnInstallApplication(const WebApplicationInfo& info); | 104 void OnInstallApplication(const WebApplicationInfo& info); |
| 100 void OnInlineWebstoreInstall(int install_id, | 105 void OnInlineWebstoreInstall(int install_id, |
| 101 const std::string& webstore_item_id, | 106 const std::string& webstore_item_id, |
| 102 const GURL& requestor_url); | 107 const GURL& requestor_url); |
| 108 void OnGetAppNotifyChannel(int request_id, |
| 109 const GURL& requestor_url, |
| 110 const std::string& client_id); |
| 103 void OnRequest(const ExtensionHostMsg_Request_Params& params); | 111 void OnRequest(const ExtensionHostMsg_Request_Params& params); |
| 104 | 112 |
| 105 // App extensions related methods: | 113 // App extensions related methods: |
| 106 | 114 |
| 107 // Resets app_icon_ and if |extension| is non-null creates a new | 115 // Resets app_icon_ and if |extension| is non-null creates a new |
| 108 // ImageLoadingTracker to load the extension's image. | 116 // ImageLoadingTracker to load the extension's image. |
| 109 void UpdateExtensionAppIcon(const Extension* extension); | 117 void UpdateExtensionAppIcon(const Extension* extension); |
| 110 | 118 |
| 111 // ImageLoadingTracker::Observer. | 119 // ImageLoadingTracker::Observer. |
| 112 virtual void OnImageLoaded(SkBitmap* image, const ExtensionResource& resource, | 120 virtual void OnImageLoaded(SkBitmap* image, const ExtensionResource& resource, |
| 113 int index) OVERRIDE; | 121 int index) OVERRIDE; |
| 114 | 122 |
| 115 // WebstoreInlineInstaller::Delegate. | 123 // WebstoreInlineInstaller::Delegate. |
| 116 virtual void OnInlineInstallSuccess(int install_id) OVERRIDE; | 124 virtual void OnInlineInstallSuccess(int install_id) OVERRIDE; |
| 117 virtual void OnInlineInstallFailure(int install_id, | 125 virtual void OnInlineInstallFailure(int install_id, |
| 118 const std::string& error) OVERRIDE; | 126 const std::string& error) OVERRIDE; |
| 119 | 127 |
| 128 // AppNotifyChannelSetup::Delegate. |
| 129 virtual void AppNotifyChannelSetupComplete(int request_id, |
| 130 const std::string& channel_id, |
| 131 const std::string& error); |
| 132 |
| 120 // Data for app extensions --------------------------------------------------- | 133 // Data for app extensions --------------------------------------------------- |
| 121 | 134 |
| 122 // If non-null this tab is an app tab and this is the extension the tab was | 135 // If non-null this tab is an app tab and this is the extension the tab was |
| 123 // created for. | 136 // created for. |
| 124 const Extension* extension_app_; | 137 const Extension* extension_app_; |
| 125 | 138 |
| 126 // Icon for extension_app_ (if non-null) or a manually-set icon for | 139 // Icon for extension_app_ (if non-null) or a manually-set icon for |
| 127 // non-extension apps. | 140 // non-extension apps. |
| 128 SkBitmap extension_app_icon_; | 141 SkBitmap extension_app_icon_; |
| 129 | 142 |
| 130 // Process any extension messages coming from the tab. | 143 // Process any extension messages coming from the tab. |
| 131 ExtensionFunctionDispatcher extension_function_dispatcher_; | 144 ExtensionFunctionDispatcher extension_function_dispatcher_; |
| 132 | 145 |
| 133 // Used for loading extension_app_icon_. | 146 // Used for loading extension_app_icon_. |
| 134 scoped_ptr<ImageLoadingTracker> extension_app_image_loader_; | 147 scoped_ptr<ImageLoadingTracker> extension_app_image_loader_; |
| 135 | 148 |
| 136 // Cached web app info data. | 149 // Cached web app info data. |
| 137 WebApplicationInfo web_app_info_; | 150 WebApplicationInfo web_app_info_; |
| 138 | 151 |
| 139 TabContentsWrapper* wrapper_; | 152 TabContentsWrapper* wrapper_; |
| 140 | 153 |
| 141 DISALLOW_COPY_AND_ASSIGN(ExtensionTabHelper); | 154 DISALLOW_COPY_AND_ASSIGN(ExtensionTabHelper); |
| 142 }; | 155 }; |
| 143 | 156 |
| 144 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_HELPER_H_ | 157 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_HELPER_H_ |
| OLD | NEW |