| 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 235 |
| 236 void TabHelper::RenderViewCreated(RenderViewHost* render_view_host) { | 236 void TabHelper::RenderViewCreated(RenderViewHost* render_view_host) { |
| 237 SetTabId(render_view_host); | 237 SetTabId(render_view_host); |
| 238 } | 238 } |
| 239 | 239 |
| 240 void TabHelper::DidNavigateMainFrame( | 240 void TabHelper::DidNavigateMainFrame( |
| 241 const content::LoadCommittedDetails& details, | 241 const content::LoadCommittedDetails& details, |
| 242 const content::FrameNavigateParams& params) { | 242 const content::FrameNavigateParams& params) { |
| 243 if (ExtensionSystem::Get(profile_)->extension_service() && | 243 if (ExtensionSystem::Get(profile_)->extension_service() && |
| 244 RulesRegistryService::Get(profile_)) { | 244 RulesRegistryService::Get(profile_)) { |
| 245 RulesRegistryService::Get(profile_)->content_rules_registry()-> | 245 ContentRulesRegistryMap& content_rules_registry_map = |
| 246 DidNavigateMainFrame(web_contents(), details, params); | 246 RulesRegistryService::Get(profile_)->content_rules_registry_map(); |
| 247 for (ContentRulesRegistryMap::iterator it = |
| 248 content_rules_registry_map.begin(); |
| 249 it != content_rules_registry_map.end(); ++it) { |
| 250 it->second->DidNavigateMainFrame(web_contents(), |
| 251 details, |
| 252 params); |
| 253 } |
| 247 } | 254 } |
| 248 | 255 |
| 249 content::BrowserContext* context = web_contents()->GetBrowserContext(); | 256 content::BrowserContext* context = web_contents()->GetBrowserContext(); |
| 250 ExtensionRegistry* registry = ExtensionRegistry::Get(context); | 257 ExtensionRegistry* registry = ExtensionRegistry::Get(context); |
| 251 const ExtensionSet& enabled_extensions = registry->enabled_extensions(); | 258 const ExtensionSet& enabled_extensions = registry->enabled_extensions(); |
| 252 | 259 |
| 253 if (CommandLine::ForCurrentProcess()->HasSwitch( | 260 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 254 switches::kEnableStreamlinedHostedApps)) { | 261 switches::kEnableStreamlinedHostedApps)) { |
| 255 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); | 262 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); |
| 256 if (browser && browser->is_app()) { | 263 if (browser && browser->is_app()) { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 int32 on_page_id, | 444 int32 on_page_id, |
| 438 const GURL& on_url) { | 445 const GURL& on_url) { |
| 439 FOR_EACH_OBSERVER(ScriptExecutionObserver, script_execution_observers_, | 446 FOR_EACH_OBSERVER(ScriptExecutionObserver, script_execution_observers_, |
| 440 OnScriptsExecuted(web_contents(), | 447 OnScriptsExecuted(web_contents(), |
| 441 executing_scripts_map, | 448 executing_scripts_map, |
| 442 on_page_id, | 449 on_page_id, |
| 443 on_url)); | 450 on_url)); |
| 444 } | 451 } |
| 445 | 452 |
| 446 void TabHelper::OnWatchedPageChange( | 453 void TabHelper::OnWatchedPageChange( |
| 454 const std::string& event_name, |
| 447 const std::vector<std::string>& css_selectors) { | 455 const std::vector<std::string>& css_selectors) { |
| 448 if (ExtensionSystem::Get(profile_)->extension_service() && | 456 if (ExtensionSystem::Get(profile_)->extension_service() && |
| 449 RulesRegistryService::Get(profile_)) { | 457 RulesRegistryService::Get(profile_)) { |
| 450 RulesRegistryService::Get(profile_)->content_rules_registry()->Apply( | 458 ContentRulesRegistry* content_rules_registry = |
| 451 web_contents(), css_selectors); | 459 RulesRegistryService::Get(profile_)-> |
| 460 GetContentRulesRegistry(event_name); |
| 461 if (!content_rules_registry) |
| 462 return; |
| 463 |
| 464 content_rules_registry->Apply(web_contents(), css_selectors); |
| 452 } | 465 } |
| 453 } | 466 } |
| 454 | 467 |
| 455 void TabHelper::OnDetailedConsoleMessageAdded( | 468 void TabHelper::OnDetailedConsoleMessageAdded( |
| 456 const base::string16& message, | 469 const base::string16& message, |
| 457 const base::string16& source, | 470 const base::string16& source, |
| 458 const StackTrace& stack_trace, | 471 const StackTrace& stack_trace, |
| 459 int32 severity_level) { | 472 int32 severity_level) { |
| 460 if (IsSourceFromAnExtension(source)) { | 473 if (IsSourceFromAnExtension(source)) { |
| 461 content::RenderViewHost* rvh = web_contents()->GetRenderViewHost(); | 474 content::RenderViewHost* rvh = web_contents()->GetRenderViewHost(); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 } | 580 } |
| 568 } | 581 } |
| 569 | 582 |
| 570 void TabHelper::SetTabId(RenderViewHost* render_view_host) { | 583 void TabHelper::SetTabId(RenderViewHost* render_view_host) { |
| 571 render_view_host->Send( | 584 render_view_host->Send( |
| 572 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), | 585 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), |
| 573 SessionID::IdForTab(web_contents()))); | 586 SessionID::IdForTab(web_contents()))); |
| 574 } | 587 } |
| 575 | 588 |
| 576 } // namespace extensions | 589 } // namespace extensions |
| OLD | NEW |