| 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/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 | 10 |
| 11 namespace { | 11 namespace { |
| 12 std::string ToId(int identifier) { | 12 std::string ToId(int identifier) { |
| 13 return base::StringPrintf("_%d_", identifier); | 13 return base::StringPrintf("_%d_", identifier); |
| 14 } | 14 } |
| 15 } // namespace | 15 } // namespace |
| 16 | 16 |
| 17 namespace extensions { | 17 namespace extensions { |
| 18 | 18 |
| 19 InitializingRulesRegistry::InitializingRulesRegistry( | 19 InitializingRulesRegistry::InitializingRulesRegistry( |
| 20 scoped_refptr<RulesRegistry> delegate) | 20 scoped_refptr<RulesRegistry> delegate) |
| 21 : RulesRegistry(delegate->owner_thread(), delegate->event_name()), | 21 : RulesRegistry(delegate->owner_thread(), |
| 22 delegate->event_name(), |
| 23 delegate->webview_key()), |
| 22 delegate_(delegate), | 24 delegate_(delegate), |
| 23 last_generated_rule_identifier_id_(0) {} | 25 last_generated_rule_identifier_id_(0) {} |
| 24 | 26 |
| 25 std::string InitializingRulesRegistry::AddRules( | 27 std::string InitializingRulesRegistry::AddRules( |
| 26 const std::string& extension_id, | 28 const std::string& extension_id, |
| 27 const std::vector<linked_ptr<RulesRegistry::Rule> >& rules) { | 29 const std::vector<linked_ptr<RulesRegistry::Rule> >& rules) { |
| 28 std::string error = CheckAndFillInOptionalRules(extension_id, rules); | 30 std::string error = CheckAndFillInOptionalRules(extension_id, rules); |
| 29 if (!error.empty()) | 31 if (!error.empty()) |
| 30 return error; | 32 return error; |
| 31 FillInOptionalPriorities(rules); | 33 FillInOptionalPriorities(rules); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 for (i = identifiers.begin(); i != identifiers.end(); ++i) | 154 for (i = identifiers.begin(); i != identifiers.end(); ++i) |
| 153 used_rule_identifiers_[extension_id].erase(*i); | 155 used_rule_identifiers_[extension_id].erase(*i); |
| 154 } | 156 } |
| 155 | 157 |
| 156 void InitializingRulesRegistry::RemoveAllUsedRuleIdentifiers( | 158 void InitializingRulesRegistry::RemoveAllUsedRuleIdentifiers( |
| 157 const std::string& extension_id) { | 159 const std::string& extension_id) { |
| 158 used_rule_identifiers_.erase(extension_id); | 160 used_rule_identifiers_.erase(extension_id); |
| 159 } | 161 } |
| 160 | 162 |
| 161 } // namespace extensions | 163 } // namespace extensions |
| OLD | NEW |