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_content/content_rules_regist
ry.h" | 5 #include "chrome/browser/extensions/api/declarative_content/content_rules_regist
ry.h" |
6 | 6 |
7 #include "chrome/browser/extensions/api/declarative_content/content_action.h" | 7 #include "chrome/browser/extensions/api/declarative_content/content_action.h" |
8 #include "chrome/browser/extensions/api/declarative_content/content_condition.h" | 8 #include "chrome/browser/extensions/api/declarative_content/content_condition.h" |
9 #include "chrome/browser/extensions/extension_system.h" | 9 #include "chrome/browser/extensions/extension_system.h" |
10 #include "chrome/browser/extensions/extension_tab_util.h" | 10 #include "chrome/browser/extensions/extension_tab_util.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 // Register url patterns in url_matcher_. | 169 // Register url patterns in url_matcher_. |
170 URLMatcherConditionSet::Vector all_new_condition_sets; | 170 URLMatcherConditionSet::Vector all_new_condition_sets; |
171 for (RulesMap::iterator i = new_content_rules.begin(); | 171 for (RulesMap::iterator i = new_content_rules.begin(); |
172 i != new_content_rules.end(); ++i) { | 172 i != new_content_rules.end(); ++i) { |
173 i->second->conditions().GetURLMatcherConditionSets(&all_new_condition_sets); | 173 i->second->conditions().GetURLMatcherConditionSets(&all_new_condition_sets); |
174 } | 174 } |
175 url_matcher_.AddConditionSets(all_new_condition_sets); | 175 url_matcher_.AddConditionSets(all_new_condition_sets); |
176 | 176 |
177 UpdateConditionCache(); | 177 UpdateConditionCache(); |
178 | 178 |
179 return ""; | 179 return std::string(); |
180 } | 180 } |
181 | 181 |
182 std::string ContentRulesRegistry::RemoveRulesImpl( | 182 std::string ContentRulesRegistry::RemoveRulesImpl( |
183 const std::string& extension_id, | 183 const std::string& extension_id, |
184 const std::vector<std::string>& rule_identifiers) { | 184 const std::vector<std::string>& rule_identifiers) { |
185 // URLMatcherConditionSet IDs that can be removed from URLMatcher. | 185 // URLMatcherConditionSet IDs that can be removed from URLMatcher. |
186 std::vector<URLMatcherConditionSet::ID> remove_from_url_matcher; | 186 std::vector<URLMatcherConditionSet::ID> remove_from_url_matcher; |
187 | 187 |
188 for (std::vector<std::string>::const_iterator i = rule_identifiers.begin(); | 188 for (std::vector<std::string>::const_iterator i = rule_identifiers.begin(); |
189 i != rule_identifiers.end(); ++i) { | 189 i != rule_identifiers.end(); ++i) { |
(...skipping 24 matching lines...) Expand all Loading... |
214 | 214 |
215 // Remove reference to actual rule. | 215 // Remove reference to actual rule. |
216 content_rules_.erase(content_rules_entry); | 216 content_rules_.erase(content_rules_entry); |
217 } | 217 } |
218 | 218 |
219 // Clear URLMatcher based on condition_set_ids that are not needed any more. | 219 // Clear URLMatcher based on condition_set_ids that are not needed any more. |
220 url_matcher_.RemoveConditionSets(remove_from_url_matcher); | 220 url_matcher_.RemoveConditionSets(remove_from_url_matcher); |
221 | 221 |
222 UpdateConditionCache(); | 222 UpdateConditionCache(); |
223 | 223 |
224 return ""; | 224 return std::string(); |
225 } | 225 } |
226 | 226 |
227 std::string ContentRulesRegistry::RemoveAllRulesImpl( | 227 std::string ContentRulesRegistry::RemoveAllRulesImpl( |
228 const std::string& extension_id) { | 228 const std::string& extension_id) { |
229 // Search all identifiers of rules that belong to extension |extension_id|. | 229 // Search all identifiers of rules that belong to extension |extension_id|. |
230 std::vector<std::string> rule_identifiers; | 230 std::vector<std::string> rule_identifiers; |
231 for (RulesMap::iterator i = content_rules_.begin(); | 231 for (RulesMap::iterator i = content_rules_.begin(); |
232 i != content_rules_.end(); ++i) { | 232 i != content_rules_.end(); ++i) { |
233 const ContentRule::GlobalRuleId& global_rule_id = i->first; | 233 const ContentRule::GlobalRuleId& global_rule_id = i->first; |
234 if (global_rule_id.first == extension_id) | 234 if (global_rule_id.first == extension_id) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 | 286 |
287 base::Time ContentRulesRegistry::GetExtensionInstallationTime( | 287 base::Time ContentRulesRegistry::GetExtensionInstallationTime( |
288 const std::string& extension_id) const { | 288 const std::string& extension_id) const { |
289 if (!extension_info_map_.get()) // May be NULL during testing. | 289 if (!extension_info_map_.get()) // May be NULL during testing. |
290 return base::Time(); | 290 return base::Time(); |
291 | 291 |
292 return extension_info_map_->GetInstallTime(extension_id); | 292 return extension_info_map_->GetInstallTime(extension_id); |
293 } | 293 } |
294 | 294 |
295 } // namespace extensions | 295 } // namespace extensions |
OLD | NEW |