| Index: chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.cc
|
| diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.cc b/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.cc
|
| index 0a0cc71587e76898e6857d8d11c7364522044998..94f3dbe52809334d034531e1b60c2930fa509160 100644
|
| --- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.cc
|
| +++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.cc
|
| @@ -10,17 +10,12 @@
|
|
|
| #include "base/stl_util.h"
|
| #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_condition.h"
|
| +#include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_checker.h"
|
| #include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h"
|
| #include "chrome/browser/extensions/api/web_request/web_request_permissions.h"
|
| #include "chrome/browser/extensions/extension_system.h"
|
| #include "net/url_request/url_request.h"
|
|
|
| -namespace {
|
| -const char kActionCannotBeExecuted[] = "An action can never be executed "
|
| - "because there are is no time in the request life-cycle during which the "
|
| - "conditions can be checked and the action can possibly be executed.";
|
| -} // namespace
|
| -
|
| namespace extensions {
|
|
|
| WebRequestRulesRegistry::WebRequestRulesRegistry(Profile* profile,
|
| @@ -145,6 +140,9 @@ std::string WebRequestRulesRegistry::AddRulesImpl(
|
|
|
| std::string error;
|
| RulesMap new_webrequest_rules;
|
| + const Extension* extension =
|
| + extension_info_map_->extensions().GetByID(extension_id);
|
| + WebRequestRulesChecker checker(extension);
|
|
|
| for (std::vector<linked_ptr<RulesRegistry::Rule> >::const_iterator rule =
|
| rules.begin(); rule != rules.end(); ++rule) {
|
| @@ -154,7 +152,7 @@ std::string WebRequestRulesRegistry::AddRulesImpl(
|
| scoped_ptr<WebRequestRule> webrequest_rule(
|
| WebRequestRule::Create(url_matcher_.condition_factory(), extension_id,
|
| extension_installation_time, *rule,
|
| - &CheckConsistency, &error));
|
| + checker.GetChecker(), &error));
|
| if (!error.empty()) {
|
| // We don't return here, because we want to clear temporary
|
| // condition sets in the url_matcher_.
|
| @@ -200,9 +198,6 @@ std::string WebRequestRulesRegistry::AddRulesImpl(
|
| ClearCacheOnNavigation();
|
|
|
| if (profile_id_ && !webrequest_rules_.empty()) {
|
| - const Extension* extension =
|
| - extension_info_map_->extensions().GetByID(extension_id);
|
| -
|
| BrowserThread::PostTask(
|
| BrowserThread::UI, FROM_HERE,
|
| base::Bind(&extension_web_request_api_helpers::NotifyWebRequestAPIUsed,
|
| @@ -290,36 +285,6 @@ void WebRequestRulesRegistry::ClearCacheOnNavigation() {
|
| extension_web_request_api_helpers::ClearCacheOnNavigation();
|
| }
|
|
|
| -// static
|
| -bool WebRequestRulesRegistry::CheckConsistency(
|
| - const WebRequestConditionSet* conditions,
|
| - const WebRequestActionSet* actions,
|
| - std::string* error) {
|
| - // Actions and conditions can be checked and executed in specific phases
|
| - // of each web request. We consider a rule inconsistent if there is an action
|
| - // that cannot be triggered by any condition.
|
| - for (WebRequestActionSet::Actions::const_iterator action_iter =
|
| - actions->actions().begin();
|
| - action_iter != actions->actions().end();
|
| - ++action_iter) {
|
| - bool found_matching_condition = false;
|
| - for (WebRequestConditionSet::Conditions::const_iterator condition_iter =
|
| - conditions->conditions().begin();
|
| - condition_iter != conditions->conditions().end() &&
|
| - !found_matching_condition;
|
| - ++condition_iter) {
|
| - // Test the intersection of bit masks, this is intentionally & and not &&.
|
| - if ((*action_iter)->GetStages() & (*condition_iter)->stages())
|
| - found_matching_condition = true;
|
| - }
|
| - if (!found_matching_condition) {
|
| - *error = kActionCannotBeExecuted;
|
| - return false;
|
| - }
|
| - }
|
| - return true;
|
| -}
|
| -
|
| void WebRequestRulesRegistry::AddTriggeredRules(
|
| const URLMatches& url_matches,
|
| const WebRequestCondition::MatchData& request_data,
|
|
|