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 "content/browser/tab_contents/tab_contents_observer.h" |
10 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 10 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
11 #include "chrome/browser/extensions/image_loading_tracker.h" | 11 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 12 #include "chrome/browser/extensions/webstore_inline_installer.h" |
12 #include "chrome/common/web_apps.h" | 13 #include "chrome/common/web_apps.h" |
13 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
14 | 15 |
15 class Extension; | 16 class Extension; |
16 class TabContentsWrapper; | 17 class TabContentsWrapper; |
17 struct WebApplicationInfo; | 18 struct WebApplicationInfo; |
18 | 19 |
19 namespace content { | 20 namespace content { |
20 struct LoadCommittedDetails; | 21 struct LoadCommittedDetails; |
21 } | 22 } |
22 | 23 |
23 // Per-tab extension helper. Also handles non-extension apps. | 24 // Per-tab extension helper. Also handles non-extension apps. |
24 class ExtensionTabHelper : public TabContentsObserver, | 25 class ExtensionTabHelper : public TabContentsObserver, |
25 public ExtensionFunctionDispatcher::Delegate, | 26 public ExtensionFunctionDispatcher::Delegate, |
26 public ImageLoadingTracker::Observer { | 27 public ImageLoadingTracker::Observer, |
| 28 public WebstoreInlineInstaller::Delegate { |
27 public: | 29 public: |
28 explicit ExtensionTabHelper(TabContentsWrapper* wrapper); | 30 explicit ExtensionTabHelper(TabContentsWrapper* wrapper); |
29 virtual ~ExtensionTabHelper(); | 31 virtual ~ExtensionTabHelper(); |
30 | 32 |
31 // Copies the internal state from another ExtensionTabHelper. | 33 // Copies the internal state from another ExtensionTabHelper. |
32 void CopyStateFrom(const ExtensionTabHelper& source); | 34 void CopyStateFrom(const ExtensionTabHelper& source); |
33 | 35 |
34 // Call this after updating a page action to notify clients about the changes. | 36 // Call this after updating a page action to notify clients about the changes. |
35 void PageActionStateChanged(); | 37 void PageActionStateChanged(); |
36 | 38 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 80 |
79 // Sets a non-extension app icon associated with TabContents and fires an | 81 // Sets a non-extension app icon associated with TabContents and fires an |
80 // INVALIDATE_TITLE navigation state change to trigger repaint of title. | 82 // INVALIDATE_TITLE navigation state change to trigger repaint of title. |
81 void SetAppIcon(const SkBitmap& app_icon); | 83 void SetAppIcon(const SkBitmap& app_icon); |
82 | 84 |
83 private: | 85 private: |
84 // TabContentsObserver overrides. | 86 // TabContentsObserver overrides. |
85 virtual void DidNavigateMainFramePostCommit( | 87 virtual void DidNavigateMainFramePostCommit( |
86 const content::LoadCommittedDetails& details, | 88 const content::LoadCommittedDetails& details, |
87 const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE; | 89 const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE; |
88 virtual bool OnMessageReceived(const IPC::Message& message); | 90 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
89 | 91 |
90 // ExtensionFunctionDispatcher::Delegate overrides. | 92 // ExtensionFunctionDispatcher::Delegate overrides. |
91 virtual Browser* GetBrowser(); | 93 virtual Browser* GetBrowser() OVERRIDE; |
92 virtual gfx::NativeView GetNativeViewOfHost(); | 94 virtual gfx::NativeView GetNativeViewOfHost() OVERRIDE; |
93 virtual gfx::NativeWindow GetCustomFrameNativeWindow(); | 95 virtual TabContents* GetAssociatedTabContents() const OVERRIDE; |
94 virtual TabContents* GetAssociatedTabContents() const; | |
95 | 96 |
96 // Message handlers. | 97 // Message handlers. |
97 void OnDidGetApplicationInfo(int32 page_id, const WebApplicationInfo& info); | 98 void OnDidGetApplicationInfo(int32 page_id, const WebApplicationInfo& info); |
98 void OnInstallApplication(const WebApplicationInfo& info); | 99 void OnInstallApplication(const WebApplicationInfo& info); |
99 void OnInlineWebstoreInstall(const std::string& webstore_item_id); | 100 void OnInlineWebstoreInstall(const std::string& webstore_item_id); |
100 void OnRequest(const ExtensionHostMsg_Request_Params& params); | 101 void OnRequest(const ExtensionHostMsg_Request_Params& params); |
101 | 102 |
102 // App extensions related methods: | 103 // App extensions related methods: |
103 | 104 |
104 // Resets app_icon_ and if |extension| is non-null creates a new | 105 // Resets app_icon_ and if |extension| is non-null creates a new |
105 // ImageLoadingTracker to load the extension's image. | 106 // ImageLoadingTracker to load the extension's image. |
106 void UpdateExtensionAppIcon(const Extension* extension); | 107 void UpdateExtensionAppIcon(const Extension* extension); |
107 | 108 |
108 // ImageLoadingTracker::Observer. | 109 // ImageLoadingTracker::Observer. |
109 virtual void OnImageLoaded(SkBitmap* image, const ExtensionResource& resource, | 110 virtual void OnImageLoaded(SkBitmap* image, const ExtensionResource& resource, |
110 int index); | 111 int index) OVERRIDE; |
| 112 |
| 113 // WebstoreInlineInstaller::Delegate. |
| 114 virtual void OnInlineInstallSuccess() OVERRIDE; |
| 115 virtual void OnInlineInstallFailure(const std::string& error) OVERRIDE; |
111 | 116 |
112 // Data for app extensions --------------------------------------------------- | 117 // Data for app extensions --------------------------------------------------- |
113 | 118 |
114 // If non-null this tab is an app tab and this is the extension the tab was | 119 // If non-null this tab is an app tab and this is the extension the tab was |
115 // created for. | 120 // created for. |
116 const Extension* extension_app_; | 121 const Extension* extension_app_; |
117 | 122 |
118 // Icon for extension_app_ (if non-null) or a manually-set icon for | 123 // Icon for extension_app_ (if non-null) or a manually-set icon for |
119 // non-extension apps. | 124 // non-extension apps. |
120 SkBitmap extension_app_icon_; | 125 SkBitmap extension_app_icon_; |
121 | 126 |
122 // Process any extension messages coming from the tab. | 127 // Process any extension messages coming from the tab. |
123 ExtensionFunctionDispatcher extension_function_dispatcher_; | 128 ExtensionFunctionDispatcher extension_function_dispatcher_; |
124 | 129 |
125 // Used for loading extension_app_icon_. | 130 // Used for loading extension_app_icon_. |
126 scoped_ptr<ImageLoadingTracker> extension_app_image_loader_; | 131 scoped_ptr<ImageLoadingTracker> extension_app_image_loader_; |
127 | 132 |
128 // Cached web app info data. | 133 // Cached web app info data. |
129 WebApplicationInfo web_app_info_; | 134 WebApplicationInfo web_app_info_; |
130 | 135 |
131 TabContentsWrapper* wrapper_; | 136 TabContentsWrapper* wrapper_; |
132 | 137 |
133 DISALLOW_COPY_AND_ASSIGN(ExtensionTabHelper); | 138 DISALLOW_COPY_AND_ASSIGN(ExtensionTabHelper); |
134 }; | 139 }; |
135 | 140 |
136 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_HELPER_H_ | 141 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_HELPER_H_ |
OLD | NEW |