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

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

Issue 2791533002: Convert Web Store Inline Install IPCs to mojo (Closed)
Patch Set: Created 3 years, 8 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"
20 #include "chrome/common/extensions/mojo/inline_install_status.mojom.h"
19 #include "chrome/common/extensions/webstore_install_result.h" 21 #include "chrome/common/extensions/webstore_install_result.h"
20 #include "chrome/common/web_application_info.h" 22 #include "chrome/common/web_application_info.h"
21 #include "content/public/browser/notification_observer.h" 23 #include "content/public/browser/notification_observer.h"
22 #include "content/public/browser/notification_registrar.h" 24 #include "content/public/browser/notification_registrar.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"
(...skipping 10 matching lines...) Expand all
39 class BookmarkAppHelper; 41 class BookmarkAppHelper;
40 class Extension; 42 class Extension;
41 class LocationBarController; 43 class LocationBarController;
42 class WebstoreInlineInstallerFactory; 44 class WebstoreInlineInstallerFactory;
43 45
44 // Per-tab extension helper. Also handles non-extension apps. 46 // Per-tab extension helper. Also handles non-extension apps.
45 class TabHelper : public content::WebContentsObserver, 47 class TabHelper : public content::WebContentsObserver,
46 public ExtensionFunctionDispatcher::Delegate, 48 public ExtensionFunctionDispatcher::Delegate,
47 public ExtensionRegistryObserver, 49 public ExtensionRegistryObserver,
48 public content::NotificationObserver, 50 public content::NotificationObserver,
49 public content::WebContentsUserData<TabHelper> { 51 public content::WebContentsUserData<TabHelper>,
52 public mojom::InlineInstall {
50 public: 53 public:
51 ~TabHelper() override; 54 ~TabHelper() override;
52 55
56 static void BindInlineInstallRequest(content::WebContents* web_contents,
57 mojom::InlineInstallRequest request);
58
53 void CreateApplicationShortcuts(); 59 void CreateApplicationShortcuts();
54 void CreateHostedAppFromWebContents(); 60 void CreateHostedAppFromWebContents();
55 bool CanCreateApplicationShortcuts() const; 61 bool CanCreateApplicationShortcuts() const;
56 bool CanCreateBookmarkApp() const; 62 bool CanCreateBookmarkApp() const;
57 63
58 void UpdateShortcutOnLoadComplete() { 64 void UpdateShortcutOnLoadComplete() {
59 update_shortcut_on_load_complete_ = true; 65 update_shortcut_on_load_complete_ = true;
60 } 66 }
61 67
62 // ScriptExecutionObserver::Delegate 68 // ScriptExecutionObserver::Delegate
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 117
112 // Sets a non-extension app icon associated with WebContents and fires an 118 // Sets a non-extension app icon associated with WebContents and fires an
113 // INVALIDATE_TYPE_TITLE navigation state change to trigger repaint of title. 119 // INVALIDATE_TYPE_TITLE navigation state change to trigger repaint of title.
114 void SetAppIcon(const SkBitmap& app_icon); 120 void SetAppIcon(const SkBitmap& app_icon);
115 121
116 // Sets the factory used to create inline webstore item installers. 122 // Sets the factory used to create inline webstore item installers.
117 // Used for testing. Takes ownership of the factory instance. 123 // Used for testing. Takes ownership of the factory instance.
118 void SetWebstoreInlineInstallerFactoryForTests( 124 void SetWebstoreInlineInstallerFactoryForTests(
119 WebstoreInlineInstallerFactory* factory); 125 WebstoreInlineInstallerFactory* factory);
120 126
127 explicit TabHelper(content::WebContents* web_contents);
128
129 protected:
130 extensions::mojom::InlineInstallStatusPtr inline_install_status_;
131
121 private: 132 private:
122 class InlineInstallObserver; 133 class InlineInstallObserver;
123 134
124 // Utility function to invoke member functions on all relevant 135 // Utility function to invoke member functions on all relevant
125 // ContentRulesRegistries. 136 // ContentRulesRegistries.
126 template <class Func> 137 template <class Func>
127 void InvokeForContentRulesRegistries(const Func& func); 138 void InvokeForContentRulesRegistries(const Func& func);
128 139
129 // Different types of action when web app info is available. 140 // Different types of action when web app info is available.
130 // OnDidGetApplicationInfo uses this to dispatch calls. 141 // OnDidGetApplicationInfo uses this to dispatch calls.
131 enum WebAppAction { 142 enum WebAppAction {
132 NONE, // No action at all. 143 NONE, // No action at all.
133 CREATE_SHORTCUT, // Bring up create application shortcut dialog. 144 CREATE_SHORTCUT, // Bring up create application shortcut dialog.
134 CREATE_HOSTED_APP, // Create and install a hosted app. 145 CREATE_HOSTED_APP, // Create and install a hosted app.
135 UPDATE_SHORTCUT // Update icon for app shortcut. 146 UPDATE_SHORTCUT // Update icon for app shortcut.
136 }; 147 };
137 148
138 explicit TabHelper(content::WebContents* web_contents);
139 friend class content::WebContentsUserData<TabHelper>; 149 friend class content::WebContentsUserData<TabHelper>;
140 150
141 // Displays UI for completion of creating a bookmark hosted app. 151 // Displays UI for completion of creating a bookmark hosted app.
142 void FinishCreateBookmarkApp(const extensions::Extension* extension, 152 void FinishCreateBookmarkApp(const extensions::Extension* extension,
143 const WebApplicationInfo& web_app_info); 153 const WebApplicationInfo& web_app_info);
144 154
145 // content::WebContentsObserver overrides. 155 // content::WebContentsObserver overrides.
146 void RenderFrameCreated(content::RenderFrameHost* host) override; 156 void RenderFrameCreated(content::RenderFrameHost* host) override;
147 void DidFinishNavigation( 157 void DidFinishNavigation(
148 content::NavigationHandle* navigation_handle) override; 158 content::NavigationHandle* navigation_handle) override;
149 bool OnMessageReceived(const IPC::Message& message) override; 159 bool OnMessageReceived(const IPC::Message& message) override;
150 bool OnMessageReceived(const IPC::Message& message, 160 bool OnMessageReceived(const IPC::Message& message,
151 content::RenderFrameHost* render_frame_host) override; 161 content::RenderFrameHost* render_frame_host) override;
152 void DidCloneToNewWebContents( 162 void DidCloneToNewWebContents(
153 content::WebContents* old_web_contents, 163 content::WebContents* old_web_contents,
154 content::WebContents* new_web_contents) override; 164 content::WebContents* new_web_contents) override;
155 165
156 // extensions::ExtensionFunctionDispatcher::Delegate overrides. 166 // extensions::ExtensionFunctionDispatcher::Delegate overrides.
157 extensions::WindowController* GetExtensionWindowController() const override; 167 extensions::WindowController* GetExtensionWindowController() const override;
158 content::WebContents* GetAssociatedWebContents() const override; 168 content::WebContents* GetAssociatedWebContents() const override;
159 169
160 // ExtensionRegistryObserver: 170 // ExtensionRegistryObserver:
161 void OnExtensionUnloaded(content::BrowserContext* browser_context, 171 void OnExtensionUnloaded(content::BrowserContext* browser_context,
162 const Extension* extension, 172 const Extension* extension,
163 UnloadedExtensionInfo::Reason reason) override; 173 UnloadedExtensionInfo::Reason reason) override;
164 174
175 // mojom::InlineInstall
176 void InlineWebstoreInstall(int install_id,
177 int return_route_id,
178 const std::string& webstore_item_id,
179 int listeners_mask) override;
180
165 // Message handlers. 181 // Message handlers.
166 void OnDidGetWebApplicationInfo(const WebApplicationInfo& info); 182 void OnDidGetWebApplicationInfo(const WebApplicationInfo& info);
167 void OnInlineWebstoreInstall(content::RenderFrameHost* host,
168 int install_id,
169 int return_route_id,
170 const std::string& webstore_item_id,
171 int listeners_mask);
172 void OnGetAppInstallState(content::RenderFrameHost* host, 183 void OnGetAppInstallState(content::RenderFrameHost* host,
173 const GURL& requestor_url, 184 const GURL& requestor_url,
174 int return_route_id, 185 int return_route_id,
175 int callback_id); 186 int callback_id);
176 void OnContentScriptsExecuting( 187 void OnContentScriptsExecuting(
177 content::RenderFrameHost* host, 188 content::RenderFrameHost* host,
178 const ScriptExecutionObserver::ExecutingScriptsMap& extension_ids, 189 const ScriptExecutionObserver::ExecutingScriptsMap& extension_ids,
179 const GURL& on_url); 190 const GURL& on_url);
180 191
181 // App extensions related methods: 192 // App extensions related methods:
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 289
279 // Generic weak ptr factory for posting callbacks. 290 // Generic weak ptr factory for posting callbacks.
280 base::WeakPtrFactory<TabHelper> weak_ptr_factory_; 291 base::WeakPtrFactory<TabHelper> weak_ptr_factory_;
281 292
282 DISALLOW_COPY_AND_ASSIGN(TabHelper); 293 DISALLOW_COPY_AND_ASSIGN(TabHelper);
283 }; 294 };
284 295
285 } // namespace extensions 296 } // namespace extensions
286 297
287 #endif // CHROME_BROWSER_EXTENSIONS_TAB_HELPER_H_ 298 #endif // CHROME_BROWSER_EXTENSIONS_TAB_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698