Chromium Code Reviews| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 } | 80 } |
| 76 | 81 |
| 77 TabContents* tab_contents() const { | 82 TabContents* tab_contents() const { |
| 78 return TabContentsObserver::tab_contents(); | 83 return TabContentsObserver::tab_contents(); |
| 79 } | 84 } |
| 80 | 85 |
| 81 // Sets a non-extension app icon associated with TabContents and fires an | 86 // Sets a non-extension app icon associated with TabContents and fires an |
| 82 // INVALIDATE_TITLE navigation state change to trigger repaint of title. | 87 // INVALIDATE_TITLE navigation state change to trigger repaint of title. |
| 83 void SetAppIcon(const SkBitmap& app_icon); | 88 void SetAppIcon(const SkBitmap& app_icon); |
| 84 | 89 |
| 90 // Implementing the AppNotifyChannelSetup::Delegate interface. | |
|
Aaron Boodman
2011/10/06 20:29:28
Note that you can implement interfaces in C++ priv
asargent_no_longer_on_chrome
2011/10/06 22:37:38
Good idea. Done.
| |
| 91 virtual void AppNotifyChannelSetupComplete(int request_id, | |
| 92 const std::string& channel_id, | |
| 93 const std::string& error); | |
| 94 | |
| 85 private: | 95 private: |
| 86 // TabContentsObserver overrides. | 96 // TabContentsObserver overrides. |
| 87 virtual void DidNavigateMainFramePostCommit( | 97 virtual void DidNavigateMainFramePostCommit( |
| 88 const content::LoadCommittedDetails& details, | 98 const content::LoadCommittedDetails& details, |
| 89 const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE; | 99 const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE; |
| 90 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 100 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 91 | 101 |
| 92 // ExtensionFunctionDispatcher::Delegate overrides. | 102 // ExtensionFunctionDispatcher::Delegate overrides. |
| 93 virtual Browser* GetBrowser() OVERRIDE; | 103 virtual Browser* GetBrowser() OVERRIDE; |
| 94 virtual gfx::NativeView GetNativeViewOfHost() OVERRIDE; | 104 virtual gfx::NativeView GetNativeViewOfHost() OVERRIDE; |
| 95 virtual TabContents* GetAssociatedTabContents() const OVERRIDE; | 105 virtual TabContents* GetAssociatedTabContents() const OVERRIDE; |
| 96 | 106 |
| 97 // Message handlers. | 107 // Message handlers. |
| 98 void OnDidGetApplicationInfo(int32 page_id, const WebApplicationInfo& info); | 108 void OnDidGetApplicationInfo(int32 page_id, const WebApplicationInfo& info); |
| 99 void OnInstallApplication(const WebApplicationInfo& info); | 109 void OnInstallApplication(const WebApplicationInfo& info); |
| 100 void OnInlineWebstoreInstall(int install_id, | 110 void OnInlineWebstoreInstall(int install_id, |
| 101 const std::string& webstore_item_id, | 111 const std::string& webstore_item_id, |
| 102 const GURL& requestor_url); | 112 const GURL& requestor_url); |
| 113 void OnGetAppNotifyChannel(int request_id, | |
| 114 const GURL& requestor_url, | |
| 115 const std::string& client_id); | |
| 103 void OnRequest(const ExtensionHostMsg_Request_Params& params); | 116 void OnRequest(const ExtensionHostMsg_Request_Params& params); |
| 104 | 117 |
| 105 // App extensions related methods: | 118 // App extensions related methods: |
| 106 | 119 |
| 107 // Resets app_icon_ and if |extension| is non-null creates a new | 120 // Resets app_icon_ and if |extension| is non-null creates a new |
| 108 // ImageLoadingTracker to load the extension's image. | 121 // ImageLoadingTracker to load the extension's image. |
| 109 void UpdateExtensionAppIcon(const Extension* extension); | 122 void UpdateExtensionAppIcon(const Extension* extension); |
| 110 | 123 |
| 111 // ImageLoadingTracker::Observer. | 124 // ImageLoadingTracker::Observer. |
| 112 virtual void OnImageLoaded(SkBitmap* image, const ExtensionResource& resource, | 125 virtual void OnImageLoaded(SkBitmap* image, const ExtensionResource& resource, |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 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 |