| 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_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 "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "chrome/browser/extensions/app_notify_channel_setup.h" | 12 #include "chrome/browser/extensions/app_notify_channel_setup.h" |
| 13 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 13 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 14 #include "chrome/browser/extensions/image_loading_tracker.h" | 14 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 15 #include "chrome/browser/extensions/webstore_inline_installer.h" | 15 #include "chrome/browser/extensions/webstore_inline_installer.h" |
| 16 #include "chrome/common/web_apps.h" | 16 #include "chrome/common/web_apps.h" |
| 17 #include "content/public/browser/web_contents_observer.h" | 17 #include "content/public/browser/web_contents_observer.h" |
| 18 #include "third_party/skia/include/core/SkBitmap.h" | 18 #include "third_party/skia/include/core/SkBitmap.h" |
| 19 | 19 |
| 20 class ExtensionTabHelperDelegate; | 20 class ExtensionTabHelperDelegate; |
| 21 class TabContents; | 21 class TabContents; |
| 22 typedef TabContents TabContentsWrapper; | |
| 23 struct WebApplicationInfo; | 22 struct WebApplicationInfo; |
| 24 | 23 |
| 25 namespace content { | 24 namespace content { |
| 26 struct LoadCommittedDetails; | 25 struct LoadCommittedDetails; |
| 27 } | 26 } |
| 28 | 27 |
| 29 namespace extensions { | 28 namespace extensions { |
| 30 class Extension; | 29 class Extension; |
| 31 class LocationBarController; | 30 class LocationBarController; |
| 32 class ScriptBadgeController; | 31 class ScriptBadgeController; |
| 33 class ScriptExecutor; | 32 class ScriptExecutor; |
| 34 } | 33 } |
| 35 | 34 |
| 36 // Per-tab extension helper. Also handles non-extension apps. | 35 // Per-tab extension helper. Also handles non-extension apps. |
| 37 class ExtensionTabHelper | 36 class ExtensionTabHelper |
| 38 : public content::WebContentsObserver, | 37 : public content::WebContentsObserver, |
| 39 public ExtensionFunctionDispatcher::Delegate, | 38 public ExtensionFunctionDispatcher::Delegate, |
| 40 public ImageLoadingTracker::Observer, | 39 public ImageLoadingTracker::Observer, |
| 41 public WebstoreInlineInstaller::Delegate, | 40 public WebstoreInlineInstaller::Delegate, |
| 42 public AppNotifyChannelSetup::Delegate, | 41 public AppNotifyChannelSetup::Delegate, |
| 43 public base::SupportsWeakPtr<ExtensionTabHelper> { | 42 public base::SupportsWeakPtr<ExtensionTabHelper> { |
| 44 public: | 43 public: |
| 45 explicit ExtensionTabHelper(TabContentsWrapper* wrapper); | 44 explicit ExtensionTabHelper(TabContents* tab_contents); |
| 46 virtual ~ExtensionTabHelper(); | 45 virtual ~ExtensionTabHelper(); |
| 47 | 46 |
| 48 // Copies the internal state from another ExtensionTabHelper. | 47 // Copies the internal state from another ExtensionTabHelper. |
| 49 void CopyStateFrom(const ExtensionTabHelper& source); | 48 void CopyStateFrom(const ExtensionTabHelper& source); |
| 50 | 49 |
| 51 ExtensionTabHelperDelegate* delegate() const { return delegate_; } | 50 ExtensionTabHelperDelegate* delegate() const { return delegate_; } |
| 52 void set_delegate(ExtensionTabHelperDelegate* d) { delegate_ = d; } | 51 void set_delegate(ExtensionTabHelperDelegate* d) { delegate_ = d; } |
| 53 | 52 |
| 54 // Call this after updating a page action to notify clients about the changes. | 53 // Call this after updating a page action to notify clients about the changes. |
| 55 void PageActionStateChanged(); | 54 void PageActionStateChanged(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 84 return web_app_info_; | 83 return web_app_info_; |
| 85 } | 84 } |
| 86 | 85 |
| 87 // If an app extension has been explicitly set for this WebContents its icon | 86 // If an app extension has been explicitly set for this WebContents its icon |
| 88 // is returned. | 87 // is returned. |
| 89 // | 88 // |
| 90 // NOTE: the returned icon is larger than 16x16 (its size is | 89 // NOTE: the returned icon is larger than 16x16 (its size is |
| 91 // Extension::EXTENSION_ICON_SMALLISH). | 90 // Extension::EXTENSION_ICON_SMALLISH). |
| 92 SkBitmap* GetExtensionAppIcon(); | 91 SkBitmap* GetExtensionAppIcon(); |
| 93 | 92 |
| 94 TabContentsWrapper* tab_contents_wrapper() { | 93 TabContents* tab_contents() { |
| 95 return wrapper_; | 94 return tab_contents_; |
| 96 } | 95 } |
| 97 | 96 |
| 98 content::WebContents* web_contents() const { | 97 content::WebContents* web_contents() const { |
| 99 return content::WebContentsObserver::web_contents(); | 98 return content::WebContentsObserver::web_contents(); |
| 100 } | 99 } |
| 101 | 100 |
| 102 extensions::ScriptExecutor* script_executor(); | 101 extensions::ScriptExecutor* script_executor(); |
| 103 | 102 |
| 104 extensions::LocationBarController* location_bar_controller(); | 103 extensions::LocationBarController* location_bar_controller(); |
| 105 | 104 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 180 |
| 182 // Process any extension messages coming from the tab. | 181 // Process any extension messages coming from the tab. |
| 183 ExtensionFunctionDispatcher extension_function_dispatcher_; | 182 ExtensionFunctionDispatcher extension_function_dispatcher_; |
| 184 | 183 |
| 185 // Used for loading extension_app_icon_. | 184 // Used for loading extension_app_icon_. |
| 186 scoped_ptr<ImageLoadingTracker> extension_app_image_loader_; | 185 scoped_ptr<ImageLoadingTracker> extension_app_image_loader_; |
| 187 | 186 |
| 188 // Cached web app info data. | 187 // Cached web app info data. |
| 189 WebApplicationInfo web_app_info_; | 188 WebApplicationInfo web_app_info_; |
| 190 | 189 |
| 191 TabContentsWrapper* wrapper_; | 190 TabContents* tab_contents_; |
| 192 | 191 |
| 193 // Either script_executor/location_bar_controller will have values, or | 192 // Either script_executor/location_bar_controller will have values, or |
| 194 // script_badge_controller will have a value, depending on whether the action | 193 // script_badge_controller will have a value, depending on whether the action |
| 195 // box is turned on. | 194 // box is turned on. |
| 196 scoped_ptr<extensions::ScriptExecutor> script_executor_; | 195 scoped_ptr<extensions::ScriptExecutor> script_executor_; |
| 197 scoped_ptr<extensions::LocationBarController> location_bar_controller_; | 196 scoped_ptr<extensions::LocationBarController> location_bar_controller_; |
| 198 scoped_refptr<extensions::ScriptBadgeController> script_badge_controller_; | 197 scoped_refptr<extensions::ScriptBadgeController> script_badge_controller_; |
| 199 | 198 |
| 200 DISALLOW_COPY_AND_ASSIGN(ExtensionTabHelper); | 199 DISALLOW_COPY_AND_ASSIGN(ExtensionTabHelper); |
| 201 }; | 200 }; |
| 202 | 201 |
| 203 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_HELPER_H_ | 202 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_HELPER_H_ |
| OLD | NEW |