| 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 <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 15 #include "chrome/browser/extensions/active_tab_permission_granter.h" | 15 #include "chrome/browser/extensions/active_tab_permission_granter.h" |
| 16 #include "chrome/browser/extensions/app_notify_channel_setup.h" | |
| 17 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 16 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 18 #include "chrome/common/web_apps.h" | 17 #include "chrome/common/web_apps.h" |
| 19 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
| 20 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 21 #include "content/public/browser/web_contents_observer.h" | 20 #include "content/public/browser/web_contents_observer.h" |
| 22 #include "content/public/browser/web_contents_user_data.h" | 21 #include "content/public/browser/web_contents_user_data.h" |
| 23 #include "third_party/skia/include/core/SkBitmap.h" | 22 #include "third_party/skia/include/core/SkBitmap.h" |
| 24 | 23 |
| 25 struct WebApplicationInfo; | 24 struct WebApplicationInfo; |
| 26 | 25 |
| 27 namespace content { | 26 namespace content { |
| 28 struct LoadCommittedDetails; | 27 struct LoadCommittedDetails; |
| 29 } | 28 } |
| 30 | 29 |
| 31 namespace gfx { | 30 namespace gfx { |
| 32 class Image; | 31 class Image; |
| 33 } | 32 } |
| 34 | 33 |
| 35 namespace extensions { | 34 namespace extensions { |
| 36 class Extension; | 35 class Extension; |
| 37 class LocationBarController; | 36 class LocationBarController; |
| 38 class RulesRegistryService; | 37 class RulesRegistryService; |
| 39 class ScriptBadgeController; | 38 class ScriptBadgeController; |
| 40 class ScriptBubbleController; | 39 class ScriptBubbleController; |
| 41 class ScriptExecutor; | 40 class ScriptExecutor; |
| 42 | 41 |
| 43 // Per-tab extension helper. Also handles non-extension apps. | 42 // Per-tab extension helper. Also handles non-extension apps. |
| 44 class TabHelper : public content::WebContentsObserver, | 43 class TabHelper : public content::WebContentsObserver, |
| 45 public ExtensionFunctionDispatcher::Delegate, | 44 public ExtensionFunctionDispatcher::Delegate, |
| 46 public AppNotifyChannelSetup::Delegate, | |
| 47 public base::SupportsWeakPtr<TabHelper>, | 45 public base::SupportsWeakPtr<TabHelper>, |
| 48 public content::NotificationObserver, | 46 public content::NotificationObserver, |
| 49 public content::WebContentsUserData<TabHelper> { | 47 public content::WebContentsUserData<TabHelper> { |
| 50 public: | 48 public: |
| 51 // Different types of action when web app info is available. | 49 // Different types of action when web app info is available. |
| 52 // OnDidGetApplicationInfo uses this to dispatch calls. | 50 // OnDidGetApplicationInfo uses this to dispatch calls. |
| 53 enum WebAppAction { | 51 enum WebAppAction { |
| 54 NONE, // No action at all. | 52 NONE, // No action at all. |
| 55 CREATE_SHORTCUT, // Bring up create application shortcut dialog. | 53 CREATE_SHORTCUT, // Bring up create application shortcut dialog. |
| 56 UPDATE_SHORTCUT // Update icon for app shortcut. | 54 UPDATE_SHORTCUT // Update icon for app shortcut. |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 const OVERRIDE; | 177 const OVERRIDE; |
| 180 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; | 178 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; |
| 181 | 179 |
| 182 // Message handlers. | 180 // Message handlers. |
| 183 void OnDidGetApplicationInfo(int32 page_id, const WebApplicationInfo& info); | 181 void OnDidGetApplicationInfo(int32 page_id, const WebApplicationInfo& info); |
| 184 void OnInstallApplication(const WebApplicationInfo& info); | 182 void OnInstallApplication(const WebApplicationInfo& info); |
| 185 void OnInlineWebstoreInstall(int install_id, | 183 void OnInlineWebstoreInstall(int install_id, |
| 186 int return_route_id, | 184 int return_route_id, |
| 187 const std::string& webstore_item_id, | 185 const std::string& webstore_item_id, |
| 188 const GURL& requestor_url); | 186 const GURL& requestor_url); |
| 189 void OnGetAppNotifyChannel(const GURL& requestor_url, | |
| 190 const std::string& client_id, | |
| 191 int return_route_id, | |
| 192 int callback_id); | |
| 193 void OnGetAppInstallState(const GURL& requestor_url, | 187 void OnGetAppInstallState(const GURL& requestor_url, |
| 194 int return_route_id, | 188 int return_route_id, |
| 195 int callback_id); | 189 int callback_id); |
| 196 void OnRequest(const ExtensionHostMsg_Request_Params& params); | 190 void OnRequest(const ExtensionHostMsg_Request_Params& params); |
| 197 void OnContentScriptsExecuting( | 191 void OnContentScriptsExecuting( |
| 198 const ScriptExecutionObserver::ExecutingScriptsMap& extension_ids, | 192 const ScriptExecutionObserver::ExecutingScriptsMap& extension_ids, |
| 199 int32 page_id, | 193 int32 page_id, |
| 200 const GURL& on_url); | 194 const GURL& on_url); |
| 201 void OnWatchedPageChange(const std::vector<std::string>& css_selectors); | 195 void OnWatchedPageChange(const std::vector<std::string>& css_selectors); |
| 202 | 196 |
| 203 // App extensions related methods: | 197 // App extensions related methods: |
| 204 | 198 |
| 205 // Resets app_icon_ and if |extension| is non-null uses ImageLoader to load | 199 // Resets app_icon_ and if |extension| is non-null uses ImageLoader to load |
| 206 // the extension's image asynchronously. | 200 // the extension's image asynchronously. |
| 207 void UpdateExtensionAppIcon(const Extension* extension); | 201 void UpdateExtensionAppIcon(const Extension* extension); |
| 208 | 202 |
| 209 const Extension* GetExtension(const std::string& extension_app_id); | 203 const Extension* GetExtension(const std::string& extension_app_id); |
| 210 | 204 |
| 211 void OnImageLoaded(const gfx::Image& image); | 205 void OnImageLoaded(const gfx::Image& image); |
| 212 | 206 |
| 213 // WebstoreStandaloneInstaller::Callback. | 207 // WebstoreStandaloneInstaller::Callback. |
| 214 virtual void OnInlineInstallComplete(int install_id, | 208 virtual void OnInlineInstallComplete(int install_id, |
| 215 int return_route_id, | 209 int return_route_id, |
| 216 bool success, | 210 bool success, |
| 217 const std::string& error); | 211 const std::string& error); |
| 218 | 212 |
| 219 // AppNotifyChannelSetup::Delegate. | |
| 220 virtual void AppNotifyChannelSetupComplete( | |
| 221 const std::string& channel_id, | |
| 222 const std::string& error, | |
| 223 const AppNotifyChannelSetup* setup) OVERRIDE; | |
| 224 | |
| 225 // content::NotificationObserver. | 213 // content::NotificationObserver. |
| 226 virtual void Observe(int type, | 214 virtual void Observe(int type, |
| 227 const content::NotificationSource& source, | 215 const content::NotificationSource& source, |
| 228 const content::NotificationDetails& details) OVERRIDE; | 216 const content::NotificationDetails& details) OVERRIDE; |
| 229 | 217 |
| 230 // Requests application info for the specified page. This is an asynchronous | 218 // Requests application info for the specified page. This is an asynchronous |
| 231 // request. The delegate is notified by way of OnDidGetApplicationInfo when | 219 // request. The delegate is notified by way of OnDidGetApplicationInfo when |
| 232 // the data is available. | 220 // the data is available. |
| 233 void GetApplicationInfo(int32 page_id); | 221 void GetApplicationInfo(int32 page_id); |
| 234 | 222 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 | 260 |
| 273 // Vend weak pointers that can be invalidated to stop in-progress loads. | 261 // Vend weak pointers that can be invalidated to stop in-progress loads. |
| 274 base::WeakPtrFactory<TabHelper> image_loader_ptr_factory_; | 262 base::WeakPtrFactory<TabHelper> image_loader_ptr_factory_; |
| 275 | 263 |
| 276 DISALLOW_COPY_AND_ASSIGN(TabHelper); | 264 DISALLOW_COPY_AND_ASSIGN(TabHelper); |
| 277 }; | 265 }; |
| 278 | 266 |
| 279 } // namespace extensions | 267 } // namespace extensions |
| 280 | 268 |
| 281 #endif // CHROME_BROWSER_EXTENSIONS_TAB_HELPER_H_ | 269 #endif // CHROME_BROWSER_EXTENSIONS_TAB_HELPER_H_ |
| OLD | NEW |