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 #include "chrome/browser/extensions/api/declarative/declarative_api_constants.h" | 10 #include "chrome/browser/extensions/api/declarative/declarative_api_constants.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 const std::string& extension_id, | 78 const std::string& extension_id, |
79 const std::string& rule_id) const { | 79 const std::string& rule_id) const { |
80 RuleIdentifiersMap::const_iterator identifiers = | 80 RuleIdentifiersMap::const_iterator identifiers = |
81 used_rule_identifiers_.find(extension_id); | 81 used_rule_identifiers_.find(extension_id); |
82 if (identifiers == used_rule_identifiers_.end()) | 82 if (identifiers == used_rule_identifiers_.end()) |
83 return true; | 83 return true; |
84 return identifiers->second.find(rule_id) == identifiers->second.end(); | 84 return identifiers->second.find(rule_id) == identifiers->second.end(); |
85 } | 85 } |
86 | 86 |
87 std::string InitializingRulesRegistry::GenerateUniqueId( | 87 std::string InitializingRulesRegistry::GenerateUniqueId( |
88 std::string extension_id) { | 88 const std::string& extension_id) { |
89 while (!IsUniqueId(extension_id, ToId(last_generated_rule_identifier_id_))) | 89 while (!IsUniqueId(extension_id, ToId(last_generated_rule_identifier_id_))) |
90 ++last_generated_rule_identifier_id_; | 90 ++last_generated_rule_identifier_id_; |
91 std::string new_id = ToId(last_generated_rule_identifier_id_); | 91 std::string new_id = ToId(last_generated_rule_identifier_id_); |
92 used_rule_identifiers_[extension_id].insert(new_id); | 92 used_rule_identifiers_[extension_id].insert(new_id); |
93 return new_id; | 93 return new_id; |
94 } | 94 } |
95 | 95 |
96 void InitializingRulesRegistry::RemoveUsedRuleIdentifiers( | 96 void InitializingRulesRegistry::RemoveUsedRuleIdentifiers( |
97 const std::string& extension_id, | 97 const std::string& extension_id, |
98 const std::vector<std::string>& identifiers) { | 98 const std::vector<std::string>& identifiers) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 const std::vector<DictionaryValue*>& rules) { | 142 const std::vector<DictionaryValue*>& rules) { |
143 std::vector<DictionaryValue*>::const_iterator i; | 143 std::vector<DictionaryValue*>::const_iterator i; |
144 for (i = rules.begin(); i != rules.end(); ++i) { | 144 for (i = rules.begin(); i != rules.end(); ++i) { |
145 DictionaryValue* rule = *i; | 145 DictionaryValue* rule = *i; |
146 if (!rule->HasKey(keys::kPriority)) | 146 if (!rule->HasKey(keys::kPriority)) |
147 rule->SetInteger(keys::kPriority, 100); | 147 rule->SetInteger(keys::kPriority, 100); |
148 } | 148 } |
149 } | 149 } |
150 | 150 |
151 } // namespace extensions | 151 } // namespace extensions |
OLD | NEW |