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

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

Issue 1166393002: Reland "Encapsulate CSS selector declarative content condition tracking" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: address comments Created 5 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
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 <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector>
11 10
12 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
15 #include "base/observer_list.h" 14 #include "base/observer_list.h"
16 #include "chrome/browser/extensions/active_tab_permission_granter.h" 15 #include "chrome/browser/extensions/active_tab_permission_granter.h"
17 #include "chrome/browser/extensions/extension_reenabler.h" 16 #include "chrome/browser/extensions/extension_reenabler.h"
18 #include "chrome/common/extensions/webstore_install_result.h" 17 #include "chrome/common/extensions/webstore_install_result.h"
19 #include "chrome/common/web_application_info.h" 18 #include "chrome/common/web_application_info.h"
20 #include "content/public/browser/notification_observer.h" 19 #include "content/public/browser/notification_observer.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 bool CanCreateBookmarkApp() const; 59 bool CanCreateBookmarkApp() const;
61 60
62 void UpdateShortcutOnLoadComplete() { 61 void UpdateShortcutOnLoadComplete() {
63 update_shortcut_on_load_complete_ = true; 62 update_shortcut_on_load_complete_ = true;
64 } 63 }
65 64
66 // ScriptExecutionObserver::Delegate 65 // ScriptExecutionObserver::Delegate
67 virtual void AddScriptExecutionObserver(ScriptExecutionObserver* observer); 66 virtual void AddScriptExecutionObserver(ScriptExecutionObserver* observer);
68 virtual void RemoveScriptExecutionObserver(ScriptExecutionObserver* observer); 67 virtual void RemoveScriptExecutionObserver(ScriptExecutionObserver* observer);
69 68
70 // App extensions ------------------------------------------------------------
71
72 // Sets the extension denoting this as an app. If |extension| is non-null this 69 // Sets the extension denoting this as an app. If |extension| is non-null this
73 // tab becomes an app-tab. WebContents does not listen for unload events for 70 // tab becomes an app-tab. WebContents does not listen for unload events for
74 // the extension. It's up to consumers of WebContents to do that. 71 // the extension. It's up to consumers of WebContents to do that.
75 // 72 //
76 // NOTE: this should only be manipulated before the tab is added to a browser. 73 // NOTE: this should only be manipulated before the tab is added to a browser.
77 // TODO(sky): resolve if this is the right way to identify an app tab. If it 74 // TODO(sky): resolve if this is the right way to identify an app tab. If it
78 // is, than this should be passed in the constructor. 75 // is, than this should be passed in the constructor.
79 void SetExtensionApp(const Extension* extension); 76 void SetExtensionApp(const Extension* extension);
80 77
81 // Convenience for setting the app extension by id. This does nothing if 78 // Convenience for setting the app extension by id. This does nothing if
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // Sets a non-extension app icon associated with WebContents and fires an 115 // Sets a non-extension app icon associated with WebContents and fires an
119 // INVALIDATE_TYPE_TITLE navigation state change to trigger repaint of title. 116 // INVALIDATE_TYPE_TITLE navigation state change to trigger repaint of title.
120 void SetAppIcon(const SkBitmap& app_icon); 117 void SetAppIcon(const SkBitmap& app_icon);
121 118
122 // Sets the factory used to create inline webstore item installers. 119 // Sets the factory used to create inline webstore item installers.
123 // Used for testing. Takes ownership of the factory instance. 120 // Used for testing. Takes ownership of the factory instance.
124 void SetWebstoreInlineInstallerFactoryForTests( 121 void SetWebstoreInlineInstallerFactoryForTests(
125 WebstoreInlineInstallerFactory* factory); 122 WebstoreInlineInstallerFactory* factory);
126 123
127 private: 124 private:
125 // Utility function to invoke member functions on all relevant
126 // ContentRulesRegistries.
127 template <class Func>
128 void InvokeForContentRulesRegistries(const Func& func);
129
128 // Different types of action when web app info is available. 130 // Different types of action when web app info is available.
129 // OnDidGetApplicationInfo uses this to dispatch calls. 131 // OnDidGetApplicationInfo uses this to dispatch calls.
130 enum WebAppAction { 132 enum WebAppAction {
131 NONE, // No action at all. 133 NONE, // No action at all.
132 CREATE_SHORTCUT, // Bring up create application shortcut dialog. 134 CREATE_SHORTCUT, // Bring up create application shortcut dialog.
133 CREATE_HOSTED_APP, // Create and install a hosted app. 135 CREATE_HOSTED_APP, // Create and install a hosted app.
134 UPDATE_SHORTCUT // Update icon for app shortcut. 136 UPDATE_SHORTCUT // Update icon for app shortcut.
135 }; 137 };
136 138
137 explicit TabHelper(content::WebContents* web_contents); 139 explicit TabHelper(content::WebContents* web_contents);
(...skipping 26 matching lines...) Expand all
164 const std::string& webstore_item_id, 166 const std::string& webstore_item_id,
165 const GURL& requestor_url, 167 const GURL& requestor_url,
166 int listeners_mask); 168 int listeners_mask);
167 void OnGetAppInstallState(const GURL& requestor_url, 169 void OnGetAppInstallState(const GURL& requestor_url,
168 int return_route_id, 170 int return_route_id,
169 int callback_id); 171 int callback_id);
170 void OnRequest(const ExtensionHostMsg_Request_Params& params); 172 void OnRequest(const ExtensionHostMsg_Request_Params& params);
171 void OnContentScriptsExecuting( 173 void OnContentScriptsExecuting(
172 const ScriptExecutionObserver::ExecutingScriptsMap& extension_ids, 174 const ScriptExecutionObserver::ExecutingScriptsMap& extension_ids,
173 const GURL& on_url); 175 const GURL& on_url);
174 void OnWatchedPageChange(const std::vector<std::string>& css_selectors);
175 void OnDetailedConsoleMessageAdded(const base::string16& message, 176 void OnDetailedConsoleMessageAdded(const base::string16& message,
176 const base::string16& source, 177 const base::string16& source,
177 const StackTrace& stack_trace, 178 const StackTrace& stack_trace,
178 int32 severity_level); 179 int32 severity_level);
179 180
180 // App extensions related methods: 181 // App extensions related methods:
181 182
182 // Resets app_icon_ and if |extension| is non-null uses ImageLoader to load 183 // Resets app_icon_ and if |extension| is non-null uses ImageLoader to load
183 // the extension's image asynchronously. 184 // the extension's image asynchronously.
184 void UpdateExtensionAppIcon(const Extension* extension); 185 void UpdateExtensionAppIcon(const Extension* extension);
(...skipping 20 matching lines...) Expand all
205 const content::NotificationDetails& details) override; 206 const content::NotificationDetails& details) override;
206 207
207 // Requests application info for the specified page. This is an asynchronous 208 // Requests application info for the specified page. This is an asynchronous
208 // request. The delegate is notified by way of OnDidGetApplicationInfo when 209 // request. The delegate is notified by way of OnDidGetApplicationInfo when
209 // the data is available. 210 // the data is available.
210 void GetApplicationInfo(WebAppAction action); 211 void GetApplicationInfo(WebAppAction action);
211 212
212 // Sends our tab ID to |render_frame_host|. 213 // Sends our tab ID to |render_frame_host|.
213 void SetTabId(content::RenderFrameHost* render_frame_host); 214 void SetTabId(content::RenderFrameHost* render_frame_host);
214 215
215 // Data for app extensions --------------------------------------------------- 216 Profile* profile_;
216 217
217 // Our content script observers. Declare at top so that it will outlive all 218 // Our content script observers. Declare at top so that it will outlive all
218 // other members, since they might add themselves as observers. 219 // other members, since they might add themselves as observers.
219 base::ObserverList<ScriptExecutionObserver> script_execution_observers_; 220 base::ObserverList<ScriptExecutionObserver> script_execution_observers_;
220 221
221 // If non-null this tab is an app tab and this is the extension the tab was 222 // If non-null this tab is an app tab and this is the extension the tab was
222 // created for. 223 // created for.
223 const Extension* extension_app_; 224 const Extension* extension_app_;
224 225
225 // Icon for extension_app_ (if non-null) or a manually-set icon for 226 // Icon for extension_app_ (if non-null) or a manually-set icon for
(...skipping 22 matching lines...) Expand all
248 scoped_ptr<ScriptExecutor> script_executor_; 249 scoped_ptr<ScriptExecutor> script_executor_;
249 250
250 scoped_ptr<LocationBarController> location_bar_controller_; 251 scoped_ptr<LocationBarController> location_bar_controller_;
251 252
252 scoped_ptr<ActiveScriptController> active_script_controller_; 253 scoped_ptr<ActiveScriptController> active_script_controller_;
253 254
254 scoped_ptr<ActiveTabPermissionGranter> active_tab_permission_granter_; 255 scoped_ptr<ActiveTabPermissionGranter> active_tab_permission_granter_;
255 256
256 scoped_ptr<BookmarkAppHelper> bookmark_app_helper_; 257 scoped_ptr<BookmarkAppHelper> bookmark_app_helper_;
257 258
258 Profile* profile_;
259
260 // Creates WebstoreInlineInstaller instances for inline install triggers. 259 // Creates WebstoreInlineInstaller instances for inline install triggers.
261 scoped_ptr<WebstoreInlineInstallerFactory> webstore_inline_installer_factory_; 260 scoped_ptr<WebstoreInlineInstallerFactory> webstore_inline_installer_factory_;
262 261
263 // The reenable prompt for disabled extensions, if any. 262 // The reenable prompt for disabled extensions, if any.
264 scoped_ptr<ExtensionReenabler> extension_reenabler_; 263 scoped_ptr<ExtensionReenabler> extension_reenabler_;
265 264
266 // Vend weak pointers that can be invalidated to stop in-progress loads. 265 // Vend weak pointers that can be invalidated to stop in-progress loads.
267 base::WeakPtrFactory<TabHelper> image_loader_ptr_factory_; 266 base::WeakPtrFactory<TabHelper> image_loader_ptr_factory_;
268 267
269 // Generic weak ptr factory for posting callbacks. 268 // Generic weak ptr factory for posting callbacks.
270 base::WeakPtrFactory<TabHelper> weak_ptr_factory_; 269 base::WeakPtrFactory<TabHelper> weak_ptr_factory_;
271 270
272 DISALLOW_COPY_AND_ASSIGN(TabHelper); 271 DISALLOW_COPY_AND_ASSIGN(TabHelper);
273 }; 272 };
274 273
275 } // namespace extensions 274 } // namespace extensions
276 275
277 #endif // CHROME_BROWSER_EXTENSIONS_TAB_HELPER_H_ 276 #endif // CHROME_BROWSER_EXTENSIONS_TAB_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698