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

Unified Diff: extensions/browser/api/declarative/rules_registry_service.cc

Issue 2705513002: Extensions: Only create Web request rules registry if Declarative Web Request is enabled. (Closed)
Patch Set: Correct comment. Created 3 years, 10 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
« no previous file with comments | « no previous file | extensions/common/features/complex_feature.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/api/declarative/rules_registry_service.cc
diff --git a/extensions/browser/api/declarative/rules_registry_service.cc b/extensions/browser/api/declarative/rules_registry_service.cc
index 8fac46194b625b7973eea6a42b4bb194d41b5845..3d8e5babdda0a1d9efacfb1c0bacc4dbdedd7803 100644
--- a/extensions/browser/api/declarative/rules_registry_service.cc
+++ b/extensions/browser/api/declarative/rules_registry_service.cc
@@ -20,6 +20,8 @@
#include "extensions/browser/api/web_request/web_request_api.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/extension.h"
+#include "extensions/common/features/feature_channel.h"
+#include "extensions/common/features/feature_provider.h"
namespace extensions {
@@ -74,24 +76,31 @@ void RulesRegistryService::EnsureDefaultRulesRegistriesRegistered(
if (ContainsKey(rule_registries_, key))
return;
- // Only cache rules for regular pages.
- RulesCacheDelegate* web_request_cache_delegate = NULL;
- if (rules_registry_id == kDefaultRulesRegistryID) {
- // Create a RulesCacheDelegate.
- web_request_cache_delegate =
- new RulesCacheDelegate(true /*log_storage_init_delay*/);
- cache_delegates_.push_back(base::WrapUnique(web_request_cache_delegate));
+ // Create a web request rules registry if declarative web request is enabled
+ // on the current channel.
+ const Feature* declarative_web_request =
+ FeatureProvider::GetAPIFeature("declarativeWebRequest");
+ if (declarative_web_request->IsAvailableToChannel(GetCurrentChannel())
+ .is_available()) {
+ // Only cache rules for regular pages.
+ RulesCacheDelegate* web_request_cache_delegate = nullptr;
+ if (rules_registry_id == kDefaultRulesRegistryID) {
+ // Create a RulesCacheDelegate.
+ web_request_cache_delegate =
+ new RulesCacheDelegate(true /*log_storage_init_delay*/);
+ cache_delegates_.push_back(base::WrapUnique(web_request_cache_delegate));
+ }
+ scoped_refptr<WebRequestRulesRegistry> web_request_rules_registry(
+ new WebRequestRulesRegistry(
+ browser_context_, web_request_cache_delegate, rules_registry_id));
+
+ RegisterRulesRegistry(web_request_rules_registry);
+ content::BrowserThread::PostTask(
+ content::BrowserThread::IO, FROM_HERE,
+ base::Bind(&RegisterToExtensionWebRequestEventRouterOnIO,
+ browser_context_, rules_registry_id,
+ web_request_rules_registry));
}
- scoped_refptr<WebRequestRulesRegistry> web_request_rules_registry(
- new WebRequestRulesRegistry(browser_context_, web_request_cache_delegate,
- rules_registry_id));
-
- RegisterRulesRegistry(web_request_rules_registry);
- content::BrowserThread::PostTask(
- content::BrowserThread::IO, FROM_HERE,
- base::Bind(&RegisterToExtensionWebRequestEventRouterOnIO,
- browser_context_, rules_registry_id,
- web_request_rules_registry));
// Only create a ContentRulesRegistry for regular pages.
if (rules_registry_id == kDefaultRulesRegistryID) {
« no previous file with comments | « no previous file | extensions/common/features/complex_feature.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698