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_rules_
registry.h" | 5 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_
registry.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 for (RulesMap::iterator i = new_webrequest_rules.begin(); | 177 for (RulesMap::iterator i = new_webrequest_rules.begin(); |
178 i != new_webrequest_rules.end(); ++i) { | 178 i != new_webrequest_rules.end(); ++i) { |
179 i->second->conditions().GetURLMatcherConditionSets(&all_new_condition_sets); | 179 i->second->conditions().GetURLMatcherConditionSets(&all_new_condition_sets); |
180 if (i->second->conditions().HasConditionsWithoutUrls()) | 180 if (i->second->conditions().HasConditionsWithoutUrls()) |
181 rules_with_untriggered_conditions_.insert(i->second.get()); | 181 rules_with_untriggered_conditions_.insert(i->second.get()); |
182 } | 182 } |
183 url_matcher_.AddConditionSets(all_new_condition_sets); | 183 url_matcher_.AddConditionSets(all_new_condition_sets); |
184 | 184 |
185 ClearCacheOnNavigation(); | 185 ClearCacheOnNavigation(); |
186 | 186 |
187 return ""; | 187 return std::string(); |
188 } | 188 } |
189 | 189 |
190 std::string WebRequestRulesRegistry::RemoveRulesImpl( | 190 std::string WebRequestRulesRegistry::RemoveRulesImpl( |
191 const std::string& extension_id, | 191 const std::string& extension_id, |
192 const std::vector<std::string>& rule_identifiers) { | 192 const std::vector<std::string>& rule_identifiers) { |
193 // URLMatcherConditionSet IDs that can be removed from URLMatcher. | 193 // URLMatcherConditionSet IDs that can be removed from URLMatcher. |
194 std::vector<URLMatcherConditionSet::ID> remove_from_url_matcher; | 194 std::vector<URLMatcherConditionSet::ID> remove_from_url_matcher; |
195 | 195 |
196 for (std::vector<std::string>::const_iterator i = rule_identifiers.begin(); | 196 for (std::vector<std::string>::const_iterator i = rule_identifiers.begin(); |
197 i != rule_identifiers.end(); ++i) { | 197 i != rule_identifiers.end(); ++i) { |
(...skipping 18 matching lines...) Expand all Loading... |
216 | 216 |
217 // Removes the owning references to (and thus deletes) the rule. | 217 // Removes the owning references to (and thus deletes) the rule. |
218 webrequest_rules_.erase(webrequest_rules_entry); | 218 webrequest_rules_.erase(webrequest_rules_entry); |
219 } | 219 } |
220 | 220 |
221 // Clear URLMatcher based on condition_set_ids that are not needed any more. | 221 // Clear URLMatcher based on condition_set_ids that are not needed any more. |
222 url_matcher_.RemoveConditionSets(remove_from_url_matcher); | 222 url_matcher_.RemoveConditionSets(remove_from_url_matcher); |
223 | 223 |
224 ClearCacheOnNavigation(); | 224 ClearCacheOnNavigation(); |
225 | 225 |
226 return ""; | 226 return std::string(); |
227 } | 227 } |
228 | 228 |
229 std::string WebRequestRulesRegistry::RemoveAllRulesImpl( | 229 std::string WebRequestRulesRegistry::RemoveAllRulesImpl( |
230 const std::string& extension_id) { | 230 const std::string& extension_id) { |
231 // Search all identifiers of rules that belong to extension |extension_id|. | 231 // Search all identifiers of rules that belong to extension |extension_id|. |
232 std::vector<std::string> rule_identifiers; | 232 std::vector<std::string> rule_identifiers; |
233 for (RulesMap::iterator i = webrequest_rules_.begin(); | 233 for (RulesMap::iterator i = webrequest_rules_.begin(); |
234 i != webrequest_rules_.end(); ++i) { | 234 i != webrequest_rules_.end(); ++i) { |
235 const WebRequestRule::GlobalRuleId& global_rule_id = i->first; | 235 const WebRequestRule::GlobalRuleId& global_rule_id = i->first; |
236 if (global_rule_id.first == extension_id) | 236 if (global_rule_id.first == extension_id) |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 RuleTriggers::const_iterator rule_trigger = rule_triggers_.find(*url_match); | 304 RuleTriggers::const_iterator rule_trigger = rule_triggers_.find(*url_match); |
305 CHECK(rule_trigger != rule_triggers_.end()); | 305 CHECK(rule_trigger != rule_triggers_.end()); |
306 if (!ContainsKey(*result, rule_trigger->second) && | 306 if (!ContainsKey(*result, rule_trigger->second) && |
307 rule_trigger->second->conditions().IsFulfilled(*url_match, | 307 rule_trigger->second->conditions().IsFulfilled(*url_match, |
308 request_data)) | 308 request_data)) |
309 result->insert(rule_trigger->second); | 309 result->insert(rule_trigger->second); |
310 } | 310 } |
311 } | 311 } |
312 | 312 |
313 } // namespace extensions | 313 } // namespace extensions |
OLD | NEW |