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

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

Issue 11547033: Implement declarativeContent API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/tab_helper.h ('k') | chrome/chrome_browser_extensions.gypi » ('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 #include "chrome/browser/extensions/tab_helper.h" 5 #include "chrome/browser/extensions/tab_helper.h"
6 6
7 #include "chrome/browser/extensions/activity_log.h" 7 #include "chrome/browser/extensions/activity_log.h"
8 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h"
9 #include "chrome/browser/extensions/api/declarative_content/content_rules_regist ry.h"
8 #include "chrome/browser/extensions/app_notify_channel_ui.h" 10 #include "chrome/browser/extensions/app_notify_channel_ui.h"
9 #include "chrome/browser/extensions/crx_installer.h" 11 #include "chrome/browser/extensions/crx_installer.h"
10 #include "chrome/browser/extensions/extension_action.h" 12 #include "chrome/browser/extensions/extension_action.h"
11 #include "chrome/browser/extensions/extension_action_manager.h" 13 #include "chrome/browser/extensions/extension_action_manager.h"
12 #include "chrome/browser/extensions/extension_service.h" 14 #include "chrome/browser/extensions/extension_service.h"
15 #include "chrome/browser/extensions/extension_system.h"
13 #include "chrome/browser/extensions/extension_tab_util.h" 16 #include "chrome/browser/extensions/extension_tab_util.h"
14 #include "chrome/browser/extensions/image_loader.h" 17 #include "chrome/browser/extensions/image_loader.h"
15 #include "chrome/browser/extensions/page_action_controller.h" 18 #include "chrome/browser/extensions/page_action_controller.h"
16 #include "chrome/browser/extensions/script_badge_controller.h" 19 #include "chrome/browser/extensions/script_badge_controller.h"
17 #include "chrome/browser/extensions/script_bubble_controller.h" 20 #include "chrome/browser/extensions/script_bubble_controller.h"
18 #include "chrome/browser/extensions/script_executor.h" 21 #include "chrome/browser/extensions/script_executor.h"
19 #include "chrome/browser/extensions/webstore_standalone_installer.h" 22 #include "chrome/browser/extensions/webstore_standalone_installer.h"
20 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/sessions/session_id.h" 24 #include "chrome/browser/sessions/session_id.h"
22 #include "chrome/browser/sessions/session_tab_helper.h" 25 #include "chrome/browser/sessions/session_tab_helper.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 TabHelper::TabHelper(content::WebContents* web_contents) 80 TabHelper::TabHelper(content::WebContents* web_contents)
78 : content::WebContentsObserver(web_contents), 81 : content::WebContentsObserver(web_contents),
79 extension_app_(NULL), 82 extension_app_(NULL),
80 ALLOW_THIS_IN_INITIALIZER_LIST( 83 ALLOW_THIS_IN_INITIALIZER_LIST(
81 extension_function_dispatcher_( 84 extension_function_dispatcher_(
82 Profile::FromBrowserContext(web_contents->GetBrowserContext()), 85 Profile::FromBrowserContext(web_contents->GetBrowserContext()),
83 this)), 86 this)),
84 pending_web_app_action_(NONE), 87 pending_web_app_action_(NONE),
85 script_executor_(new ScriptExecutor(web_contents, 88 script_executor_(new ScriptExecutor(web_contents,
86 &script_execution_observers_)), 89 &script_execution_observers_)),
90 rules_registry_service_(
91 ExtensionSystem::Get(
92 Profile::FromBrowserContext(web_contents->GetBrowserContext()))->
93 rules_registry_service()),
87 ALLOW_THIS_IN_INITIALIZER_LIST(image_loader_ptr_factory_(this)) { 94 ALLOW_THIS_IN_INITIALIZER_LIST(image_loader_ptr_factory_(this)) {
88 // The ActiveTabPermissionManager requires a session ID; ensure this 95 // The ActiveTabPermissionManager requires a session ID; ensure this
89 // WebContents has one. 96 // WebContents has one.
90 SessionTabHelper::CreateForWebContents(web_contents); 97 SessionTabHelper::CreateForWebContents(web_contents);
91 active_tab_permission_granter_.reset(new ActiveTabPermissionGranter( 98 active_tab_permission_granter_.reset(new ActiveTabPermissionGranter(
92 web_contents, 99 web_contents,
93 SessionID::IdForTab(web_contents), 100 SessionID::IdForTab(web_contents),
94 Profile::FromBrowserContext(web_contents->GetBrowserContext()))); 101 Profile::FromBrowserContext(web_contents->GetBrowserContext())));
95 if (FeatureSwitch::script_badges()->IsEnabled()) { 102 if (FeatureSwitch::script_badges()->IsEnabled()) {
96 location_bar_controller_.reset( 103 location_bar_controller_.reset(
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 188
182 void TabHelper::RenderViewCreated(RenderViewHost* render_view_host) { 189 void TabHelper::RenderViewCreated(RenderViewHost* render_view_host) {
183 render_view_host->Send( 190 render_view_host->Send(
184 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), 191 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(),
185 SessionID::IdForTab(web_contents()))); 192 SessionID::IdForTab(web_contents())));
186 } 193 }
187 194
188 void TabHelper::DidNavigateMainFrame( 195 void TabHelper::DidNavigateMainFrame(
189 const content::LoadCommittedDetails& details, 196 const content::LoadCommittedDetails& details,
190 const content::FrameNavigateParams& params) { 197 const content::FrameNavigateParams& params) {
198 #if defined(ENABLE_EXTENSIONS)
199 if (rules_registry_service_) {
200 rules_registry_service_->content_rules_registry()->DidNavigateMainFrame(
201 web_contents(), details, params);
202 }
203 #endif // defined(ENABLE_EXTENSIONS)
204
191 if (details.is_in_page) 205 if (details.is_in_page)
192 return; 206 return;
193 207
194 Profile* profile = 208 Profile* profile =
195 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 209 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
196 ExtensionService* service = profile->GetExtensionService(); 210 ExtensionService* service = profile->GetExtensionService();
197 if (!service) 211 if (!service)
198 return; 212 return;
199 213
200 ExtensionActionManager* extension_action_manager = 214 ExtensionActionManager* extension_action_manager =
(...skipping 21 matching lines...) Expand all
222 OnInstallApplication) 236 OnInstallApplication)
223 IPC_MESSAGE_HANDLER(ExtensionHostMsg_InlineWebstoreInstall, 237 IPC_MESSAGE_HANDLER(ExtensionHostMsg_InlineWebstoreInstall,
224 OnInlineWebstoreInstall) 238 OnInlineWebstoreInstall)
225 IPC_MESSAGE_HANDLER(ExtensionHostMsg_GetAppNotifyChannel, 239 IPC_MESSAGE_HANDLER(ExtensionHostMsg_GetAppNotifyChannel,
226 OnGetAppNotifyChannel) 240 OnGetAppNotifyChannel)
227 IPC_MESSAGE_HANDLER(ExtensionHostMsg_GetAppInstallState, 241 IPC_MESSAGE_HANDLER(ExtensionHostMsg_GetAppInstallState,
228 OnGetAppInstallState); 242 OnGetAppInstallState);
229 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) 243 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
230 IPC_MESSAGE_HANDLER(ExtensionHostMsg_ContentScriptsExecuting, 244 IPC_MESSAGE_HANDLER(ExtensionHostMsg_ContentScriptsExecuting,
231 OnContentScriptsExecuting) 245 OnContentScriptsExecuting)
246 IPC_MESSAGE_HANDLER(ExtensionHostMsg_OnWatchedPageChange,
247 OnWatchedPageChange)
232 IPC_MESSAGE_UNHANDLED(handled = false) 248 IPC_MESSAGE_UNHANDLED(handled = false)
233 IPC_END_MESSAGE_MAP() 249 IPC_END_MESSAGE_MAP()
234 return handled; 250 return handled;
235 } 251 }
236 252
237 void TabHelper::DidCloneToNewWebContents(WebContents* old_web_contents, 253 void TabHelper::DidCloneToNewWebContents(WebContents* old_web_contents,
238 WebContents* new_web_contents) { 254 WebContents* new_web_contents) {
239 // When the WebContents that this is attached to is cloned, give the new clone 255 // When the WebContents that this is attached to is cloned, give the new clone
240 // a TabHelper and copy state over. 256 // a TabHelper and copy state over.
241 CreateForWebContents(new_web_contents); 257 CreateForWebContents(new_web_contents);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 const ScriptExecutionObserver::ExecutingScriptsMap& executing_scripts_map, 426 const ScriptExecutionObserver::ExecutingScriptsMap& executing_scripts_map,
411 int32 on_page_id, 427 int32 on_page_id,
412 const GURL& on_url) { 428 const GURL& on_url) {
413 FOR_EACH_OBSERVER(ScriptExecutionObserver, script_execution_observers_, 429 FOR_EACH_OBSERVER(ScriptExecutionObserver, script_execution_observers_,
414 OnScriptsExecuted(web_contents(), 430 OnScriptsExecuted(web_contents(),
415 executing_scripts_map, 431 executing_scripts_map,
416 on_page_id, 432 on_page_id,
417 on_url)); 433 on_url));
418 } 434 }
419 435
436 void TabHelper::OnWatchedPageChange(
437 const std::vector<std::string>& css_selectors) {
438 #if defined(ENABLE_EXTENSIONS)
439 if (rules_registry_service_) {
440 rules_registry_service_->content_rules_registry()->Apply(
441 web_contents(), css_selectors);
442 }
443 #endif // defined(ENABLE_EXTENSIONS)
444 }
445
420 const Extension* TabHelper::GetExtension(const std::string& extension_app_id) { 446 const Extension* TabHelper::GetExtension(const std::string& extension_app_id) {
421 if (extension_app_id.empty()) 447 if (extension_app_id.empty())
422 return NULL; 448 return NULL;
423 449
424 Profile* profile = 450 Profile* profile =
425 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 451 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
426 ExtensionService* extension_service = profile->GetExtensionService(); 452 ExtensionService* extension_service = profile->GetExtensionService();
427 if (!extension_service || !extension_service->is_ready()) 453 if (!extension_service || !extension_service->is_ready())
428 return NULL; 454 return NULL;
429 455
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 script_bubble_controller_->OnExtensionUnloaded( 544 script_bubble_controller_->OnExtensionUnloaded(
519 content::Details<extensions::UnloadedExtensionInfo>( 545 content::Details<extensions::UnloadedExtensionInfo>(
520 details)->extension->id()); 546 details)->extension->id());
521 break; 547 break;
522 } 548 }
523 } 549 }
524 } 550 }
525 } 551 }
526 552
527 } // namespace extensions 553 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/tab_helper.h ('k') | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698