| 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 "chrome/browser/extensions/api/declarative_webrequest/webrequest_rule.h
" | 5 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rule.h
" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_action
.h" | 8 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_action
.h" |
| 9 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_condit
ion.h" | 9 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_condit
ion.h" |
| 10 #include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h" | 10 #include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 *error = kActionCannotBeExecuted; | 65 *error = kActionCannotBeExecuted; |
| 66 return false; | 66 return false; |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 return true; | 69 return true; |
| 70 } | 70 } |
| 71 | 71 |
| 72 // static | 72 // static |
| 73 scoped_ptr<WebRequestRule> WebRequestRule::Create( | 73 scoped_ptr<WebRequestRule> WebRequestRule::Create( |
| 74 URLMatcherConditionFactory* url_matcher_condition_factory, | 74 URLMatcherConditionFactory* url_matcher_condition_factory, |
| 75 URLMatcherConditionFactory* first_party_url_matcher_condition_factory, |
| 75 const std::string& extension_id, | 76 const std::string& extension_id, |
| 76 base::Time extension_installation_time, | 77 base::Time extension_installation_time, |
| 77 linked_ptr<RulesRegistry::Rule> rule, | 78 linked_ptr<RulesRegistry::Rule> rule, |
| 78 std::string* error) { | 79 std::string* error) { |
| 79 scoped_ptr<WebRequestRule> error_result; | 80 scoped_ptr<WebRequestRule> error_result; |
| 80 | 81 |
| 81 scoped_ptr<WebRequestConditionSet> conditions = | 82 scoped_ptr<WebRequestConditionSet> conditions = |
| 82 WebRequestConditionSet::Create( | 83 WebRequestConditionSet::Create(url_matcher_condition_factory, |
| 83 url_matcher_condition_factory, rule->conditions, error); | 84 first_party_url_matcher_condition_factory, |
| 85 rule->conditions, error); |
| 84 if (!error->empty()) | 86 if (!error->empty()) |
| 85 return error_result.Pass(); | 87 return error_result.Pass(); |
| 86 CHECK(conditions.get()); | 88 CHECK(conditions.get()); |
| 87 | 89 |
| 88 bool bad_message = false; | 90 bool bad_message = false; |
| 89 scoped_ptr<WebRequestActionSet> actions = | 91 scoped_ptr<WebRequestActionSet> actions = |
| 90 WebRequestActionSet::Create(rule->actions, error, &bad_message); | 92 WebRequestActionSet::Create(rule->actions, error, &bad_message); |
| 91 if (bad_message) { | 93 if (bad_message) { |
| 92 // TODO(battre) Export concept of bad_message to caller, the extension | 94 // TODO(battre) Export concept of bad_message to caller, the extension |
| 93 // should be killed in case it is true. | 95 // should be killed in case it is true. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 119 return actions_->CreateDeltas(extension_info_map, extension_id(), | 121 return actions_->CreateDeltas(extension_info_map, extension_id(), |
| 120 request_data, crosses_incognito, | 122 request_data, crosses_incognito, |
| 121 extension_installation_time_); | 123 extension_installation_time_); |
| 122 } | 124 } |
| 123 | 125 |
| 124 int WebRequestRule::GetMinimumPriority() const { | 126 int WebRequestRule::GetMinimumPriority() const { |
| 125 return actions_->GetMinimumPriority(); | 127 return actions_->GetMinimumPriority(); |
| 126 } | 128 } |
| 127 | 129 |
| 128 } // namespace extensions | 130 } // namespace extensions |
| OLD | NEW |