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

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

Issue 2791533002: Convert Web Store Inline Install IPCs to mojo (Closed)
Patch Set: Addressed Devlin's comments Created 3 years, 6 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
« no previous file with comments | « chrome/browser/extensions/BUILD.gn ('k') | chrome/browser/extensions/tab_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/mojom/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::InlineInstaller {
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 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 // ExtensionFunctionDispatcher::Delegate overrides.
149 extensions::WindowController* GetExtensionWindowController() const override; 153 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 UnloadedExtensionReason reason) override; 159 UnloadedExtensionReason reason) override;
156 160
161 // mojom::InlineInstall:
162 void DoInlineInstall(
163 const std::string& webstore_item_id,
164 int listeners_mask,
165 mojom::InlineInstallProgressListenerPtr install_progress_listener,
166 DoInlineInstallCallback callback) override;
167
157 // Message handlers. 168 // Message handlers.
158 void OnDidGetWebApplicationInfo(const WebApplicationInfo& info); 169 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, 170 void OnGetAppInstallState(content::RenderFrameHost* host,
165 const GURL& requestor_url, 171 const GURL& requestor_url,
166 int return_route_id, 172 int return_route_id,
167 int callback_id); 173 int callback_id);
168 void OnContentScriptsExecuting( 174 void OnContentScriptsExecuting(
169 content::RenderFrameHost* host, 175 content::RenderFrameHost* host,
170 const ScriptExecutionObserver::ExecutingScriptsMap& extension_ids, 176 const ScriptExecutionObserver::ExecutingScriptsMap& extension_ids,
171 const GURL& on_url); 177 const GURL& on_url);
172 178
173 // App extensions related methods: 179 // App extensions related methods:
174 180
175 // Resets app_icon_ and if |extension| is non-null uses ImageLoader to load 181 // Resets app_icon_ and if |extension| is non-null uses ImageLoader to load
176 // the extension's image asynchronously. 182 // the extension's image asynchronously.
177 void UpdateExtensionAppIcon(const Extension* extension); 183 void UpdateExtensionAppIcon(const Extension* extension);
178 184
179 const Extension* GetExtension(const ExtensionId& extension_app_id); 185 const Extension* GetExtension(const ExtensionId& extension_app_id);
180 186
181 void OnImageLoaded(const gfx::Image& image); 187 void OnImageLoaded(const gfx::Image& image);
182 188
183 // WebstoreStandaloneInstaller::Callback. 189 // WebstoreStandaloneInstaller::Callback.
184 void OnInlineInstallComplete(int install_id, 190 void OnInlineInstallComplete(const ExtensionId& extension_id,
185 int return_route_id,
186 const ExtensionId& extension_id,
187 bool success, 191 bool success,
188 const std::string& error, 192 const std::string& error,
189 webstore_install::Result result); 193 webstore_install::Result result);
190 194
191 // ExtensionReenabler::Callback. 195 // ExtensionReenabler::Callback.
192 void OnReenableComplete(int install_id, 196 void OnReenableComplete(const ExtensionId& extension_id,
193 int return_route_id,
194 const ExtensionId& extension_id,
195 ExtensionReenabler::ReenableResult result); 197 ExtensionReenabler::ReenableResult result);
196 198
197 // content::NotificationObserver. 199 // content::NotificationObserver.
198 void Observe(int type, 200 void Observe(int type,
199 const content::NotificationSource& source, 201 const content::NotificationSource& source,
200 const content::NotificationDetails& details) override; 202 const content::NotificationDetails& details) override;
201 203
202 // Requests application info for the specified page. This is an asynchronous 204 // Requests application info for the specified page. This is an asynchronous
203 // request. The delegate is notified by way of OnDidGetApplicationInfo when 205 // request. The delegate is notified by way of OnDidGetApplicationInfo when
204 // the data is available. 206 // the data is available.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 std::unique_ptr<ExtensionReenabler> extension_reenabler_; 255 std::unique_ptr<ExtensionReenabler> extension_reenabler_;
254 256
255 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> 257 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
256 registry_observer_; 258 registry_observer_;
257 259
258 // Map of InlineInstallObservers for inline installations that have progress 260 // Map of InlineInstallObservers for inline installations that have progress
259 // listeners. 261 // listeners.
260 std::map<ExtensionId, std::unique_ptr<InlineInstallObserver>> 262 std::map<ExtensionId, std::unique_ptr<InlineInstallObserver>>
261 install_observers_; 263 install_observers_;
262 264
263 // The set of extension ids that are currently being installed. 265 // Map of function callbacks that are invoked when the inline installation for
264 std::set<ExtensionId> pending_inline_installations_; 266 // a particular extension (hence ExtensionId) completes.
267 std::map<ExtensionId, DoInlineInstallCallback> install_callbacks_;
268
269 content::WebContentsFrameBindingSet<mojom::InlineInstaller> bindings_;
270
271 std::map<ExtensionId, mojom::InlineInstallProgressListenerPtr>
272 inline_install_progress_listeners_;
265 273
266 // Vend weak pointers that can be invalidated to stop in-progress loads. 274 // Vend weak pointers that can be invalidated to stop in-progress loads.
267 base::WeakPtrFactory<TabHelper> image_loader_ptr_factory_; 275 base::WeakPtrFactory<TabHelper> image_loader_ptr_factory_;
268 276
269 // Generic weak ptr factory for posting callbacks. 277 // Generic weak ptr factory for posting callbacks.
270 base::WeakPtrFactory<TabHelper> weak_ptr_factory_; 278 base::WeakPtrFactory<TabHelper> weak_ptr_factory_;
271 279
272 DISALLOW_COPY_AND_ASSIGN(TabHelper); 280 DISALLOW_COPY_AND_ASSIGN(TabHelper);
273 }; 281 };
274 282
275 } // namespace extensions 283 } // namespace extensions
276 284
277 #endif // CHROME_BROWSER_EXTENSIONS_TAB_HELPER_H_ 285 #endif // CHROME_BROWSER_EXTENSIONS_TAB_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/BUILD.gn ('k') | chrome/browser/extensions/tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698