| 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/initializing_rules_registry.
h" | 5 #include "chrome/browser/extensions/api/declarative/initializing_rules_registry.
h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 | 10 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 const std::string& extension_id, | 79 const std::string& extension_id, |
| 80 const std::string& rule_id) const { | 80 const std::string& rule_id) const { |
| 81 RuleIdentifiersMap::const_iterator identifiers = | 81 RuleIdentifiersMap::const_iterator identifiers = |
| 82 used_rule_identifiers_.find(extension_id); | 82 used_rule_identifiers_.find(extension_id); |
| 83 if (identifiers == used_rule_identifiers_.end()) | 83 if (identifiers == used_rule_identifiers_.end()) |
| 84 return true; | 84 return true; |
| 85 return identifiers->second.find(rule_id) == identifiers->second.end(); | 85 return identifiers->second.find(rule_id) == identifiers->second.end(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 std::string InitializingRulesRegistry::GenerateUniqueId( | 88 std::string InitializingRulesRegistry::GenerateUniqueId( |
| 89 std::string extension_id) { | 89 const std::string& extension_id) { |
| 90 while (!IsUniqueId(extension_id, ToId(last_generated_rule_identifier_id_))) | 90 while (!IsUniqueId(extension_id, ToId(last_generated_rule_identifier_id_))) |
| 91 ++last_generated_rule_identifier_id_; | 91 ++last_generated_rule_identifier_id_; |
| 92 return ToId(last_generated_rule_identifier_id_); | 92 return ToId(last_generated_rule_identifier_id_); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void InitializingRulesRegistry::RemoveUsedRuleIdentifiers( | 95 void InitializingRulesRegistry::RemoveUsedRuleIdentifiers( |
| 96 const std::string& extension_id, | 96 const std::string& extension_id, |
| 97 const std::vector<std::string>& identifiers) { | 97 const std::vector<std::string>& identifiers) { |
| 98 std::vector<std::string>::const_iterator i; | 98 std::vector<std::string>::const_iterator i; |
| 99 for (i = identifiers.begin(); i != identifiers.end(); ++i) | 99 for (i = identifiers.begin(); i != identifiers.end(); ++i) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 void InitializingRulesRegistry::FillInOptionalPriorities( | 141 void InitializingRulesRegistry::FillInOptionalPriorities( |
| 142 const std::vector<linked_ptr<RulesRegistry::Rule> >& rules) { | 142 const std::vector<linked_ptr<RulesRegistry::Rule> >& rules) { |
| 143 std::vector<linked_ptr<RulesRegistry::Rule> >::const_iterator i; | 143 std::vector<linked_ptr<RulesRegistry::Rule> >::const_iterator i; |
| 144 for (i = rules.begin(); i != rules.end(); ++i) { | 144 for (i = rules.begin(); i != rules.end(); ++i) { |
| 145 if (!(*i)->priority.get()) | 145 if (!(*i)->priority.get()) |
| 146 (*i)->priority.reset(new int(DEFAULT_PRIORITY)); | 146 (*i)->priority.reset(new int(DEFAULT_PRIORITY)); |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 | 149 |
| 150 } // namespace extensions | 150 } // namespace extensions |
| OLD | NEW |