Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: chrome/browser/extensions/tab_helper.h

Issue 2791533002: Convert Web Store Inline Install IPCs to mojo (Closed)
Patch Set: Removed WebstoreBindingsHelper; Added bindings set to WebstoreBindings Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/observer_list.h" 15 #include "base/observer_list.h"
16 #include "base/scoped_observer.h" 16 #include "base/scoped_observer.h"
17 #include "chrome/browser/extensions/active_tab_permission_granter.h" 17 #include "chrome/browser/extensions/active_tab_permission_granter.h"
18 #include "chrome/browser/extensions/extension_reenabler.h" 18 #include "chrome/browser/extensions/extension_reenabler.h"
19 #include "chrome/common/extensions/mojo/inline_install.mojom.h"
19 #include "chrome/common/extensions/webstore_install_result.h" 20 #include "chrome/common/extensions/webstore_install_result.h"
20 #include "chrome/common/web_application_info.h" 21 #include "chrome/common/web_application_info.h"
21 #include "content/public/browser/notification_observer.h" 22 #include "content/public/browser/notification_observer.h"
22 #include "content/public/browser/notification_registrar.h" 23 #include "content/public/browser/notification_registrar.h"
24 #include "content/public/browser/web_contents_binding_set.h"
23 #include "content/public/browser/web_contents_observer.h" 25 #include "content/public/browser/web_contents_observer.h"
24 #include "content/public/browser/web_contents_user_data.h" 26 #include "content/public/browser/web_contents_user_data.h"
25 #include "extensions/browser/extension_function_dispatcher.h" 27 #include "extensions/browser/extension_function_dispatcher.h"
26 #include "extensions/browser/extension_registry_observer.h" 28 #include "extensions/browser/extension_registry_observer.h"
27 #include "extensions/browser/script_execution_observer.h" 29 #include "extensions/browser/script_execution_observer.h"
28 #include "extensions/browser/script_executor.h" 30 #include "extensions/browser/script_executor.h"
29 #include "extensions/common/extension_id.h" 31 #include "extensions/common/extension_id.h"
30 #include "extensions/common/stack_frame.h" 32 #include "extensions/common/stack_frame.h"
31 #include "third_party/skia/include/core/SkBitmap.h" 33 #include "third_party/skia/include/core/SkBitmap.h"
32 34
33 namespace gfx { 35 namespace gfx {
34 class Image; 36 class Image;
35 } 37 }
36 38
37 namespace extensions { 39 namespace extensions {
38 class ExtensionActionRunner; 40 class ExtensionActionRunner;
39 class BookmarkAppHelper; 41 class BookmarkAppHelper;
40 class Extension; 42 class Extension;
41 class WebstoreInlineInstallerFactory; 43 class WebstoreInlineInstallerFactory;
42 44
43 // Per-tab extension helper. Also handles non-extension apps. 45 // Per-tab extension helper. Also handles non-extension apps.
44 class TabHelper : public content::WebContentsObserver, 46 class TabHelper : public content::WebContentsObserver,
45 public ExtensionFunctionDispatcher::Delegate, 47 public ExtensionFunctionDispatcher::Delegate,
46 public ExtensionRegistryObserver, 48 public ExtensionRegistryObserver,
47 public content::NotificationObserver, 49 public content::NotificationObserver,
48 public content::WebContentsUserData<TabHelper> { 50 public content::WebContentsUserData<TabHelper>,
51 public mojom::InlineInstall {
49 public: 52 public:
50 ~TabHelper() override; 53 ~TabHelper() override;
51 54
52 void CreateHostedAppFromWebContents(); 55 void CreateHostedAppFromWebContents();
53 bool CanCreateBookmarkApp() const; 56 bool CanCreateBookmarkApp() const;
54 57
55 void UpdateShortcutOnLoadComplete() { 58 void UpdateShortcutOnLoadComplete() {
56 update_shortcut_on_load_complete_ = true; 59 update_shortcut_on_load_complete_ = true;
57 } 60 }
58 61
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 124
122 // Different types of action when web app info is available. 125 // Different types of action when web app info is available.
123 // OnDidGetApplicationInfo uses this to dispatch calls. 126 // OnDidGetApplicationInfo uses this to dispatch calls.
124 enum WebAppAction { 127 enum WebAppAction {
125 NONE, // No action at all. 128 NONE, // No action at all.
126 CREATE_HOSTED_APP, // Create and install a hosted app. 129 CREATE_HOSTED_APP, // Create and install a hosted app.
127 UPDATE_SHORTCUT // Update icon for app shortcut. 130 UPDATE_SHORTCUT // Update icon for app shortcut.
128 }; 131 };
129 132
130 explicit TabHelper(content::WebContents* web_contents); 133 explicit TabHelper(content::WebContents* web_contents);
134
131 friend class content::WebContentsUserData<TabHelper>; 135 friend class content::WebContentsUserData<TabHelper>;
132 136
133 // Displays UI for completion of creating a bookmark hosted app. 137 // Displays UI for completion of creating a bookmark hosted app.
134 void FinishCreateBookmarkApp(const extensions::Extension* extension, 138 void FinishCreateBookmarkApp(const extensions::Extension* extension,
135 const WebApplicationInfo& web_app_info); 139 const WebApplicationInfo& web_app_info);
136 140
137 // content::WebContentsObserver overrides. 141 // content::WebContentsObserver overrides.
138 void RenderFrameCreated(content::RenderFrameHost* host) override; 142 void RenderFrameCreated(content::RenderFrameHost* host) override;
139 void DidFinishNavigation( 143 void DidFinishNavigation(
140 content::NavigationHandle* navigation_handle) override; 144 content::NavigationHandle* navigation_handle) override;
141 bool OnMessageReceived(const IPC::Message& message) override; 145 bool OnMessageReceived(const IPC::Message& message) override;
142 bool OnMessageReceived(const IPC::Message& message, 146 bool OnMessageReceived(const IPC::Message& message,
143 content::RenderFrameHost* render_frame_host) override; 147 content::RenderFrameHost* render_frame_host) override;
144 void DidCloneToNewWebContents( 148 void DidCloneToNewWebContents(
145 content::WebContents* old_web_contents, 149 content::WebContents* old_web_contents,
146 content::WebContents* new_web_contents) override; 150 content::WebContents* new_web_contents) override;
147 151
148 // extensions::ExtensionFunctionDispatcher::Delegate overrides. 152 // extensions::ExtensionFunctionDispatcher::Delegate overrides.
149 extensions::WindowController* GetExtensionWindowController() const override; 153 extensions::WindowController* GetExtensionWindowController() const override;
150 content::WebContents* GetAssociatedWebContents() const override; 154 content::WebContents* GetAssociatedWebContents() const override;
151 155
152 // ExtensionRegistryObserver: 156 // ExtensionRegistryObserver:
153 void OnExtensionUnloaded(content::BrowserContext* browser_context, 157 void OnExtensionUnloaded(content::BrowserContext* browser_context,
154 const Extension* extension, 158 const Extension* extension,
155 UnloadedExtensionInfo::Reason reason) override; 159 UnloadedExtensionInfo::Reason reason) override;
156 160
161 // mojom::InlineInstall:
162 void DoInlineInstall(int install_id,
163 const std::string& webstore_item_id,
164 int listeners_mask,
165 extensions::mojom::InlineInstallProgressListenerPtr
166 install_progress_listener,
167 const DoInlineInstallCallback& callback) override;
168
157 // Message handlers. 169 // Message handlers.
158 void OnDidGetWebApplicationInfo(const WebApplicationInfo& info); 170 void OnDidGetWebApplicationInfo(const WebApplicationInfo& info);
159 void OnInlineWebstoreInstall(content::RenderFrameHost* host,
160 int install_id,
161 int return_route_id,
162 const std::string& webstore_item_id,
163 int listeners_mask);
164 void OnGetAppInstallState(content::RenderFrameHost* host, 171 void OnGetAppInstallState(content::RenderFrameHost* host,
165 const GURL& requestor_url, 172 const GURL& requestor_url,
166 int return_route_id, 173 int return_route_id,
167 int callback_id); 174 int callback_id);
168 void OnContentScriptsExecuting( 175 void OnContentScriptsExecuting(
169 content::RenderFrameHost* host, 176 content::RenderFrameHost* host,
170 const ScriptExecutionObserver::ExecutingScriptsMap& extension_ids, 177 const ScriptExecutionObserver::ExecutingScriptsMap& extension_ids,
171 const GURL& on_url); 178 const GURL& on_url);
172 179
173 // App extensions related methods: 180 // App extensions related methods:
174 181
175 // Resets app_icon_ and if |extension| is non-null uses ImageLoader to load 182 // Resets app_icon_ and if |extension| is non-null uses ImageLoader to load
176 // the extension's image asynchronously. 183 // the extension's image asynchronously.
177 void UpdateExtensionAppIcon(const Extension* extension); 184 void UpdateExtensionAppIcon(const Extension* extension);
178 185
179 const Extension* GetExtension(const ExtensionId& extension_app_id); 186 const Extension* GetExtension(const ExtensionId& extension_app_id);
180 187
181 void OnImageLoaded(const gfx::Image& image); 188 void OnImageLoaded(const gfx::Image& image);
182 189
183 // WebstoreStandaloneInstaller::Callback. 190 // WebstoreStandaloneInstaller::Callback.
184 void OnInlineInstallComplete(int install_id, 191 void OnInlineInstallComplete(const DoInlineInstallCallback& callback,
185 int return_route_id, 192 int install_id,
186 const ExtensionId& extension_id, 193 const ExtensionId& extension_id,
187 bool success, 194 bool success,
188 const std::string& error, 195 const std::string& error,
189 webstore_install::Result result); 196 webstore_install::Result result);
190 197
191 // ExtensionReenabler::Callback. 198 // ExtensionReenabler::Callback.
192 void OnReenableComplete(int install_id, 199 void OnReenableComplete(int install_id,
193 int return_route_id,
194 const ExtensionId& extension_id, 200 const ExtensionId& extension_id,
201 const DoInlineInstallCallback& callback,
195 ExtensionReenabler::ReenableResult result); 202 ExtensionReenabler::ReenableResult result);
196 203
197 // content::NotificationObserver. 204 // content::NotificationObserver.
198 void Observe(int type, 205 void Observe(int type,
199 const content::NotificationSource& source, 206 const content::NotificationSource& source,
200 const content::NotificationDetails& details) override; 207 const content::NotificationDetails& details) override;
201 208
202 // Requests application info for the specified page. This is an asynchronous 209 // Requests application info for the specified page. This is an asynchronous
203 // request. The delegate is notified by way of OnDidGetApplicationInfo when 210 // request. The delegate is notified by way of OnDidGetApplicationInfo when
204 // the data is available. 211 // the data is available.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 registry_observer_; 263 registry_observer_;
257 264
258 // Map of InlineInstallObservers for inline installations that have progress 265 // Map of InlineInstallObservers for inline installations that have progress
259 // listeners. 266 // listeners.
260 std::map<ExtensionId, std::unique_ptr<InlineInstallObserver>> 267 std::map<ExtensionId, std::unique_ptr<InlineInstallObserver>>
261 install_observers_; 268 install_observers_;
262 269
263 // The set of extension ids that are currently being installed. 270 // The set of extension ids that are currently being installed.
264 std::set<ExtensionId> pending_inline_installations_; 271 std::set<ExtensionId> pending_inline_installations_;
265 272
273 content::WebContentsFrameBindingSet<extensions::mojom::InlineInstall>
274 bindings_;
275
266 // Vend weak pointers that can be invalidated to stop in-progress loads. 276 // Vend weak pointers that can be invalidated to stop in-progress loads.
267 base::WeakPtrFactory<TabHelper> image_loader_ptr_factory_; 277 base::WeakPtrFactory<TabHelper> image_loader_ptr_factory_;
268 278
269 // Generic weak ptr factory for posting callbacks. 279 // Generic weak ptr factory for posting callbacks.
270 base::WeakPtrFactory<TabHelper> weak_ptr_factory_; 280 base::WeakPtrFactory<TabHelper> weak_ptr_factory_;
271 281
272 DISALLOW_COPY_AND_ASSIGN(TabHelper); 282 DISALLOW_COPY_AND_ASSIGN(TabHelper);
273 }; 283 };
274 284
275 } // namespace extensions 285 } // namespace extensions
276 286
277 #endif // CHROME_BROWSER_EXTENSIONS_TAB_HELPER_H_ 287 #endif // CHROME_BROWSER_EXTENSIONS_TAB_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698