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 "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 namespace extensions { | 30 namespace extensions { |
31 class Extension; | 31 class Extension; |
32 class LocationBarController; | 32 class LocationBarController; |
33 class ScriptBadgeController; | 33 class ScriptBadgeController; |
34 class ScriptBubbleController; | 34 class ScriptBubbleController; |
35 class ScriptExecutor; | 35 class ScriptExecutor; |
36 | 36 |
37 // Per-tab extension helper. Also handles non-extension apps. | 37 // Per-tab extension helper. Also handles non-extension apps. |
38 class TabHelper : public content::WebContentsObserver, | 38 class TabHelper : public content::WebContentsObserver, |
39 public ExtensionFunctionDispatcher::Delegate, | 39 public ExtensionFunctionDispatcher::Delegate, |
40 public ImageLoadingTracker::Observer, | |
41 public AppNotifyChannelSetup::Delegate, | 40 public AppNotifyChannelSetup::Delegate, |
42 public base::SupportsWeakPtr<TabHelper>, | 41 public base::SupportsWeakPtr<TabHelper>, |
43 public content::NotificationObserver, | 42 public content::NotificationObserver, |
44 public content::WebContentsUserData<TabHelper> { | 43 public content::WebContentsUserData<TabHelper> { |
45 public: | 44 public: |
46 // Different types of action when web app info is available. | 45 // Different types of action when web app info is available. |
47 // OnDidGetApplicationInfo uses this to dispatch calls. | 46 // OnDidGetApplicationInfo uses this to dispatch calls. |
48 enum WebAppAction { | 47 enum WebAppAction { |
49 NONE, // No action at all. | 48 NONE, // No action at all. |
50 CREATE_SHORTCUT, // Bring up create application shortcut dialog. | 49 CREATE_SHORTCUT, // Bring up create application shortcut dialog. |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 const ScriptExecutionObserver::ExecutingScriptsMap& extension_ids, | 192 const ScriptExecutionObserver::ExecutingScriptsMap& extension_ids, |
194 int32 page_id, | 193 int32 page_id, |
195 const GURL& on_url); | 194 const GURL& on_url); |
196 | 195 |
197 // App extensions related methods: | 196 // App extensions related methods: |
198 | 197 |
199 // Resets app_icon_ and if |extension| is non-null creates a new | 198 // Resets app_icon_ and if |extension| is non-null creates a new |
200 // ImageLoadingTracker to load the extension's image. | 199 // ImageLoadingTracker to load the extension's image. |
201 void UpdateExtensionAppIcon(const Extension* extension); | 200 void UpdateExtensionAppIcon(const Extension* extension); |
202 | 201 |
203 const Extension* GetExtension( | 202 const Extension* GetExtension(const std::string& extension_app_id); |
204 const std::string& extension_app_id); | |
205 | 203 |
206 // ImageLoadingTracker::Observer. | 204 void OnImageLoaded(const gfx::Image& image); |
207 virtual void OnImageLoaded(const gfx::Image& image, | |
208 const std::string& extension_id, | |
209 int index) OVERRIDE; | |
210 | 205 |
211 // WebstoreStandaloneInstaller::Callback. | 206 // WebstoreStandaloneInstaller::Callback. |
212 virtual void OnInlineInstallComplete(int install_id, | 207 virtual void OnInlineInstallComplete(int install_id, |
213 int return_route_id, | 208 int return_route_id, |
214 bool success, | 209 bool success, |
215 const std::string& error); | 210 const std::string& error); |
216 | 211 |
217 // AppNotifyChannelSetup::Delegate. | 212 // AppNotifyChannelSetup::Delegate. |
218 virtual void AppNotifyChannelSetupComplete( | 213 virtual void AppNotifyChannelSetupComplete( |
219 const std::string& channel_id, | 214 const std::string& channel_id, |
(...skipping 20 matching lines...) Expand all Loading... |
240 // created for. | 235 // created for. |
241 const Extension* extension_app_; | 236 const Extension* extension_app_; |
242 | 237 |
243 // Icon for extension_app_ (if non-null) or a manually-set icon for | 238 // Icon for extension_app_ (if non-null) or a manually-set icon for |
244 // non-extension apps. | 239 // non-extension apps. |
245 SkBitmap extension_app_icon_; | 240 SkBitmap extension_app_icon_; |
246 | 241 |
247 // Process any extension messages coming from the tab. | 242 // Process any extension messages coming from the tab. |
248 ExtensionFunctionDispatcher extension_function_dispatcher_; | 243 ExtensionFunctionDispatcher extension_function_dispatcher_; |
249 | 244 |
250 // Used for loading extension_app_icon_. | |
251 scoped_ptr<ImageLoadingTracker> extension_app_image_loader_; | |
252 | |
253 // Cached web app info data. | 245 // Cached web app info data. |
254 WebApplicationInfo web_app_info_; | 246 WebApplicationInfo web_app_info_; |
255 | 247 |
256 // Which deferred action to perform when OnDidGetApplicationInfo is notified | 248 // Which deferred action to perform when OnDidGetApplicationInfo is notified |
257 // from a WebContents. | 249 // from a WebContents. |
258 WebAppAction pending_web_app_action_; | 250 WebAppAction pending_web_app_action_; |
259 | 251 |
260 content::NotificationRegistrar registrar_; | 252 content::NotificationRegistrar registrar_; |
261 | 253 |
262 scoped_ptr<ScriptExecutor> script_executor_; | 254 scoped_ptr<ScriptExecutor> script_executor_; |
263 | 255 |
264 scoped_ptr<LocationBarController> location_bar_controller_; | 256 scoped_ptr<LocationBarController> location_bar_controller_; |
265 | 257 |
266 scoped_ptr<ActiveTabPermissionGranter> active_tab_permission_granter_; | 258 scoped_ptr<ActiveTabPermissionGranter> active_tab_permission_granter_; |
267 | 259 |
268 scoped_ptr<ScriptBubbleController> script_bubble_controller_; | 260 scoped_ptr<ScriptBubbleController> script_bubble_controller_; |
269 | 261 |
270 Profile* profile_; | 262 Profile* profile_; |
271 | 263 |
| 264 // Vend weak pointers that can be invalidated to stop in-progress loads. |
| 265 base::WeakPtrFactory<TabHelper> image_loader_ptr_factory_; |
| 266 |
272 DISALLOW_COPY_AND_ASSIGN(TabHelper); | 267 DISALLOW_COPY_AND_ASSIGN(TabHelper); |
273 }; | 268 }; |
274 | 269 |
275 } // namespace extensions | 270 } // namespace extensions |
276 | 271 |
277 #endif // CHROME_BROWSER_EXTENSIONS_TAB_HELPER_H_ | 272 #endif // CHROME_BROWSER_EXTENSIONS_TAB_HELPER_H_ |
OLD | NEW |