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

Unified Diff: chrome/browser/extensions/tab_helper.cc

Issue 344433003: Prepare declarativeContent API for new script injection feature. Added Javascript types and functio… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Greatly simplified: Got rid of WatchedPagesRecipient and new event types Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/tab_helper.cc
diff --git a/chrome/browser/extensions/tab_helper.cc b/chrome/browser/extensions/tab_helper.cc
index 4889d417a98dc43615753b7cb798694361462635..22d84fc97cc1ee2bdc2f1428446b716f5aa71997 100644
--- a/chrome/browser/extensions/tab_helper.cc
+++ b/chrome/browser/extensions/tab_helper.cc
@@ -240,10 +240,18 @@ void TabHelper::RenderViewCreated(RenderViewHost* render_view_host) {
void TabHelper::DidNavigateMainFrame(
const content::LoadCommittedDetails& details,
const content::FrameNavigateParams& params) {
+ typedef std::map<std::string, ContentRulesRegistry*> ContentRulesRegistryMap;
if (ExtensionSystem::Get(profile_)->extension_service() &&
RulesRegistryService::Get(profile_)) {
- RulesRegistryService::Get(profile_)->content_rules_registry()->
- DidNavigateMainFrame(web_contents(), details, params);
+ ContentRulesRegistryMap& content_rules_registry_map =
+ RulesRegistryService::Get(profile_)->content_rules_registry_map();
+ for (ContentRulesRegistryMap::iterator it =
+ content_rules_registry_map.begin();
+ it != content_rules_registry_map.end(); ++it) {
+ it->second->DidNavigateMainFrame(web_contents(),
+ details,
+ params);
+ }
}
content::BrowserContext* context = web_contents()->GetBrowserContext();
@@ -444,11 +452,17 @@ void TabHelper::OnContentScriptsExecuting(
}
void TabHelper::OnWatchedPageChange(
+ const std::string& event_name,
const std::vector<std::string>& css_selectors) {
if (ExtensionSystem::Get(profile_)->extension_service() &&
RulesRegistryService::Get(profile_)) {
- RulesRegistryService::Get(profile_)->content_rules_registry()->Apply(
- web_contents(), css_selectors);
+ ContentRulesRegistry* content_rules_registry =
+ RulesRegistryService::Get(profile_)->
+ GetContentRulesRegistry(event_name);
+ if (!content_rules_registry)
+ return;
+
+ content_rules_registry->Apply(web_contents(), css_selectors);
}
}

Powered by Google App Engine
This is Rietveld 408576698