| Index: chrome/browser/extensions/api/declarative/rules_registry_service.cc
|
| diff --git a/chrome/browser/extensions/api/declarative/rules_registry_service.cc b/chrome/browser/extensions/api/declarative/rules_registry_service.cc
|
| index 7f3d12fee0f2efde60eb87a83bd28c19c1504a05..fb215ec71dfc1146d65f594368b7226c7da64882 100644
|
| --- a/chrome/browser/extensions/api/declarative/rules_registry_service.cc
|
| +++ b/chrome/browser/extensions/api/declarative/rules_registry_service.cc
|
| @@ -4,12 +4,18 @@
|
|
|
| #include "chrome/browser/extensions/api/declarative/rules_registry_service.h"
|
|
|
| +#include <map>
|
| +#include <string>
|
| +#include <utility>
|
| +
|
| #include "base/bind.h"
|
| #include "base/lazy_instance.h"
|
| #include "base/logging.h"
|
| +#include "base/macros.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "chrome/browser/chrome_notification_types.h"
|
| #include "chrome/browser/extensions/api/declarative/rules_cache_delegate.h"
|
| +#include "chrome/browser/extensions/api/declarative_content/content_constants.h"
|
| #include "chrome/browser/extensions/api/declarative_content/content_rules_registry.h"
|
| #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_constants.h"
|
| #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.h"
|
| @@ -43,8 +49,7 @@ bool IsWebView(const RulesRegistryService::WebViewKey& webview_key) {
|
| } // namespace
|
|
|
| RulesRegistryService::RulesRegistryService(content::BrowserContext* context)
|
| - : content_rules_registry_(NULL),
|
| - extension_registry_observer_(this),
|
| + : extension_registry_observer_(this),
|
| profile_(Profile::FromBrowserContext(context)) {
|
| if (profile_) {
|
| extension_registry_observer_.Add(ExtensionRegistry::Get(profile_));
|
| @@ -89,13 +94,25 @@ void RulesRegistryService::EnsureDefaultRulesRegistriesRegistered(
|
|
|
| // Only create a ContentRulesRegistry for regular pages and not webviews.
|
| if (!IsWebView(webview_key)) {
|
| - RulesCacheDelegate* content_rules_cache_delegate =
|
| - new RulesCacheDelegate(false /*log_storage_init_delay*/);
|
| - cache_delegates_.push_back(content_rules_cache_delegate);
|
| - scoped_refptr<ContentRulesRegistry> content_rules_registry(
|
| - new ContentRulesRegistry(profile_, content_rules_cache_delegate));
|
| - RegisterRulesRegistry(content_rules_registry);
|
| - content_rules_registry_ = content_rules_registry.get();
|
| + namespace dcc = declarative_content_constants;
|
| + const std::string content_registry_ids[] = {
|
| + dcc::kOnPageChanged,
|
| + };
|
| +
|
| + for (const std::string* it = content_registry_ids;
|
| + it < content_registry_ids + arraysize(content_registry_ids); ++it) {
|
| + RulesCacheDelegate* content_rules_cache_delegate =
|
| + new RulesCacheDelegate(false /*log_storage_init_delay*/);
|
| + cache_delegates_.push_back(content_rules_cache_delegate);
|
| + scoped_refptr<ContentRulesRegistry> content_rules_registry(
|
| + new ContentRulesRegistry(profile_,
|
| + *it, // event_name.
|
| + content_rules_cache_delegate));
|
| + RegisterRulesRegistry(content_rules_registry);
|
| + content_rules_registry_map_.insert(
|
| + std::make_pair(*it, // event_name.
|
| + content_rules_registry.get()));
|
| + }
|
| }
|
| }
|
|
|
| @@ -149,6 +166,17 @@ scoped_refptr<RulesRegistry> RulesRegistryService::GetRulesRegistry(
|
| return i->second;
|
| }
|
|
|
| +ContentRulesRegistry* RulesRegistryService::GetContentRulesRegistry(
|
| + const std::string& event_name) {
|
| + std::map<std::string, ContentRulesRegistry*>::iterator it =
|
| + content_rules_registry_map_.find(event_name);
|
| + if (it == content_rules_registry_map_.end())
|
| + return NULL;
|
| +
|
| + return content_rules_registry_map_[event_name];
|
| +}
|
| +
|
| +
|
| void RulesRegistryService::RemoveWebViewRulesRegistries(int process_id) {
|
| DCHECK_NE(0, process_id);
|
|
|
|
|