| 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 "extensions/browser/api/declarative/rules_registry_service.h" | 5 #include "extensions/browser/api/declarative/rules_registry_service.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "components/version_info/version_info.h" |
| 13 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 14 #include "content/public/browser/render_process_host.h" | 15 #include "content/public/browser/render_process_host.h" |
| 15 #include "extensions/browser/api/declarative/rules_cache_delegate.h" | 16 #include "extensions/browser/api/declarative/rules_cache_delegate.h" |
| 16 #include "extensions/browser/api/declarative_content/content_rules_registry.h" | 17 #include "extensions/browser/api/declarative_content/content_rules_registry.h" |
| 17 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h" | 18 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h" |
| 18 #include "extensions/browser/api/declarative_webrequest/webrequest_rules_registr
y.h" | 19 #include "extensions/browser/api/declarative_webrequest/webrequest_rules_registr
y.h" |
| 19 #include "extensions/browser/api/extensions_api_client.h" | 20 #include "extensions/browser/api/extensions_api_client.h" |
| 20 #include "extensions/browser/api/web_request/web_request_api.h" | 21 #include "extensions/browser/api/web_request/web_request_api.h" |
| 21 #include "extensions/browser/extension_registry.h" | 22 #include "extensions/browser/extension_registry.h" |
| 22 #include "extensions/common/extension.h" | 23 #include "extensions/common/extension.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 int rules_registry_id) { | 70 int rules_registry_id) { |
| 70 if (!browser_context_) | 71 if (!browser_context_) |
| 71 return; | 72 return; |
| 72 RulesRegistryKey key(declarative_webrequest_constants::kOnRequest, | 73 RulesRegistryKey key(declarative_webrequest_constants::kOnRequest, |
| 73 rules_registry_id); | 74 rules_registry_id); |
| 74 // If we can find the key in the |rule_registries_| then we have already | 75 // If we can find the key in the |rule_registries_| then we have already |
| 75 // installed the default registries. | 76 // installed the default registries. |
| 76 if (ContainsKey(rule_registries_, key)) | 77 if (ContainsKey(rule_registries_, key)) |
| 77 return; | 78 return; |
| 78 | 79 |
| 80 ScopedCurrentChannel channel(version_info::Channel::STABLE); |
| 81 |
| 79 // Create a web request rules registry if declarative web request is enabled | 82 // Create a web request rules registry if declarative web request is enabled |
| 80 // on the current channel. | 83 // on the current channel. |
| 81 const Feature* declarative_web_request = | 84 const Feature* declarative_web_request = |
| 82 FeatureProvider::GetAPIFeature("declarativeWebRequest"); | 85 FeatureProvider::GetAPIFeature("declarativeWebRequest"); |
| 83 if (declarative_web_request->IsAvailableToChannel(GetCurrentChannel()) | 86 if (declarative_web_request->IsAvailableToChannel(GetCurrentChannel()) |
| 84 .is_available()) { | 87 .is_available()) { |
| 85 // Only cache rules for regular pages. | 88 // Only cache rules for regular pages. |
| 86 RulesCacheDelegate* web_request_cache_delegate = nullptr; | 89 RulesCacheDelegate* web_request_cache_delegate = nullptr; |
| 87 if (rules_registry_id == kDefaultRulesRegistryID) { | 90 if (rules_registry_id == kDefaultRulesRegistryID) { |
| 88 // Create a RulesCacheDelegate. | 91 // Create a RulesCacheDelegate. |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 } | 232 } |
| 230 | 233 |
| 231 void RulesRegistryService::OnExtensionUninstalled( | 234 void RulesRegistryService::OnExtensionUninstalled( |
| 232 content::BrowserContext* browser_context, | 235 content::BrowserContext* browser_context, |
| 233 const Extension* extension, | 236 const Extension* extension, |
| 234 extensions::UninstallReason reason) { | 237 extensions::UninstallReason reason) { |
| 235 NotifyRegistriesHelper(&RulesRegistry::OnExtensionUninstalled, extension); | 238 NotifyRegistriesHelper(&RulesRegistry::OnExtensionUninstalled, extension); |
| 236 } | 239 } |
| 237 | 240 |
| 238 } // namespace extensions | 241 } // namespace extensions |
| OLD | NEW |