OLD | NEW |
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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 void TabHelper::RenderViewCreated(RenderViewHost* render_view_host) { | 243 void TabHelper::RenderViewCreated(RenderViewHost* render_view_host) { |
244 SetTabId(render_view_host); | 244 SetTabId(render_view_host); |
245 } | 245 } |
246 | 246 |
247 void TabHelper::DidNavigateMainFrame( | 247 void TabHelper::DidNavigateMainFrame( |
248 const content::LoadCommittedDetails& details, | 248 const content::LoadCommittedDetails& details, |
249 const content::FrameNavigateParams& params) { | 249 const content::FrameNavigateParams& params) { |
250 #if defined(ENABLE_EXTENSIONS) | 250 #if defined(ENABLE_EXTENSIONS) |
251 if (ExtensionSystem::Get(profile_)->extension_service() && | 251 if (ExtensionSystem::Get(profile_)->extension_service() && |
252 RulesRegistryService::Get(profile_)) { | 252 RulesRegistryService::Get(profile_)) { |
253 RulesRegistryService::Get(profile_)->content_rules_registry()-> | 253 ContentRulesRegistryMap& content_rules_registry_map = |
254 DidNavigateMainFrame(web_contents(), details, params); | 254 RulesRegistryService::Get(profile_)->content_rules_registry_map(); |
| 255 for (ContentRulesRegistryMap::iterator it = |
| 256 content_rules_registry_map.begin(); |
| 257 it != content_rules_registry_map.end(); ++it) { |
| 258 it->second->DidNavigateMainFrame(web_contents(), |
| 259 details, |
| 260 params); |
| 261 } |
255 } | 262 } |
256 #endif // defined(ENABLE_EXTENSIONS) | 263 #endif // defined(ENABLE_EXTENSIONS) |
257 | 264 |
258 content::BrowserContext* context = web_contents()->GetBrowserContext(); | 265 content::BrowserContext* context = web_contents()->GetBrowserContext(); |
259 ExtensionRegistry* registry = ExtensionRegistry::Get(context); | 266 ExtensionRegistry* registry = ExtensionRegistry::Get(context); |
260 const ExtensionSet& enabled_extensions = registry->enabled_extensions(); | 267 const ExtensionSet& enabled_extensions = registry->enabled_extensions(); |
261 | 268 |
262 if (CommandLine::ForCurrentProcess()->HasSwitch( | 269 if (CommandLine::ForCurrentProcess()->HasSwitch( |
263 switches::kEnableStreamlinedHostedApps)) { | 270 switches::kEnableStreamlinedHostedApps)) { |
264 #if !defined(OS_ANDROID) | 271 #if !defined(OS_ANDROID) |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 int32 on_page_id, | 461 int32 on_page_id, |
455 const GURL& on_url) { | 462 const GURL& on_url) { |
456 FOR_EACH_OBSERVER(ScriptExecutionObserver, script_execution_observers_, | 463 FOR_EACH_OBSERVER(ScriptExecutionObserver, script_execution_observers_, |
457 OnScriptsExecuted(web_contents(), | 464 OnScriptsExecuted(web_contents(), |
458 executing_scripts_map, | 465 executing_scripts_map, |
459 on_page_id, | 466 on_page_id, |
460 on_url)); | 467 on_url)); |
461 } | 468 } |
462 | 469 |
463 void TabHelper::OnWatchedPageChange( | 470 void TabHelper::OnWatchedPageChange( |
| 471 const std::string& event_name, |
464 const std::vector<std::string>& css_selectors) { | 472 const std::vector<std::string>& css_selectors) { |
465 #if defined(ENABLE_EXTENSIONS) | 473 #if defined(ENABLE_EXTENSIONS) |
466 if (ExtensionSystem::Get(profile_)->extension_service() && | 474 if (ExtensionSystem::Get(profile_)->extension_service() && |
467 RulesRegistryService::Get(profile_)) { | 475 RulesRegistryService::Get(profile_)) { |
468 RulesRegistryService::Get(profile_)->content_rules_registry()->Apply( | 476 ContentRulesRegistry* content_rules_registry = |
469 web_contents(), css_selectors); | 477 RulesRegistryService::Get(profile_)-> |
| 478 GetContentRulesRegistry(event_name); |
| 479 if (!content_rules_registry) |
| 480 return; |
| 481 |
| 482 content_rules_registry->Apply(web_contents(), css_selectors); |
470 } | 483 } |
471 #endif // defined(ENABLE_EXTENSIONS) | 484 #endif // defined(ENABLE_EXTENSIONS) |
472 } | 485 } |
473 | 486 |
474 void TabHelper::OnDetailedConsoleMessageAdded( | 487 void TabHelper::OnDetailedConsoleMessageAdded( |
475 const base::string16& message, | 488 const base::string16& message, |
476 const base::string16& source, | 489 const base::string16& source, |
477 const StackTrace& stack_trace, | 490 const StackTrace& stack_trace, |
478 int32 severity_level) { | 491 int32 severity_level) { |
479 #if defined(ENABLE_EXTENSIONS) | 492 #if defined(ENABLE_EXTENSIONS) |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 } | 607 } |
595 } | 608 } |
596 | 609 |
597 void TabHelper::SetTabId(RenderViewHost* render_view_host) { | 610 void TabHelper::SetTabId(RenderViewHost* render_view_host) { |
598 render_view_host->Send( | 611 render_view_host->Send( |
599 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), | 612 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), |
600 SessionID::IdForTab(web_contents()))); | 613 SessionID::IdForTab(web_contents()))); |
601 } | 614 } |
602 | 615 |
603 } // namespace extensions | 616 } // namespace extensions |
OLD | NEW |