| Index: chrome/browser/extensions/api/declarative/test_rules_registry.cc
|
| diff --git a/chrome/browser/extensions/api/declarative/test_rules_registry.cc b/chrome/browser/extensions/api/declarative/test_rules_registry.cc
|
| index f379c0b45ee14ebb93665371b4ee64a48abcb67a..00ad973799e63cd3cf6fd93d2a91be805f75b6d3 100644
|
| --- a/chrome/browser/extensions/api/declarative/test_rules_registry.cc
|
| +++ b/chrome/browser/extensions/api/declarative/test_rules_registry.cc
|
| @@ -6,21 +6,12 @@
|
|
|
| #include "base/logging.h"
|
| #include "base/values.h"
|
| -#include "chrome/browser/extensions/api/declarative/declarative_api_constants.h"
|
| -
|
| -namespace keys = extensions::declarative_api_constants;
|
|
|
| namespace {
|
|
|
| const char kSuccess[] = "";
|
| const char kRuleNotFound[] = "Rule not found.";
|
|
|
| -std::string GetRuleId(DictionaryValue* rule) {
|
| - std::string rule_id;
|
| - CHECK(rule->GetString(keys::kId, &rule_id));
|
| - return rule_id;
|
| -}
|
| -
|
| } // namespace
|
|
|
| namespace extensions {
|
| @@ -31,14 +22,14 @@ TestRulesRegistry::~TestRulesRegistry() {}
|
|
|
| std::string TestRulesRegistry::AddRules(
|
| const std::string& extension_id,
|
| - const std::vector<DictionaryValue*>& rules) {
|
| + const std::vector<linked_ptr<Rule> >& rules) {
|
| // TODO(battre) this ignores the extension_id but should not.
|
| - for (std::vector<DictionaryValue*>::const_iterator i =
|
| + for (std::vector<linked_ptr<Rule> >::const_iterator i =
|
| rules.begin(); i != rules.end(); ++i) {
|
| - std::string rule_id = GetRuleId(*i);
|
| + std::string rule_id = *((*i)->id);
|
| // TODO: relax this (check first and abort with returning false).
|
| CHECK(rules_.find(rule_id) == rules_.end());
|
| - rules_[rule_id] = make_linked_ptr((*i)->DeepCopy());
|
| + rules_[rule_id] = *i;
|
| }
|
| return kSuccess;
|
| }
|
| @@ -66,25 +57,25 @@ std::string TestRulesRegistry::RemoveAllRules(const std::string& extension_id) {
|
| std::string TestRulesRegistry::GetRules(
|
| const std::string& extension_id,
|
| const std::vector<std::string>& rule_identifiers,
|
| - std::vector<DictionaryValue*>* out) {
|
| + std::vector<linked_ptr<RulesRegistry::Rule> >* out) {
|
| // TODO(battre) this ignores the extension_id but should not.
|
| for (std::vector<std::string>::const_iterator i = rule_identifiers.begin();
|
| i != rule_identifiers.end(); ++i) {
|
| RulesDictionary::iterator entry = rules_.find(*i);
|
| if (entry == rules_.end())
|
| return kRuleNotFound;
|
| - out->push_back(entry->second->DeepCopy());
|
| + out->push_back(entry->second);
|
| }
|
| return kSuccess;
|
| }
|
|
|
| std::string TestRulesRegistry::GetAllRules(
|
| const std::string& extension_id,
|
| - std::vector<DictionaryValue*>* out) {
|
| + std::vector<linked_ptr<RulesRegistry::Rule> >* out) {
|
| // TODO(battre): this ignores the extension_id.
|
| for (RulesDictionary::const_iterator i = rules_.begin();
|
| i != rules_.end(); ++i)
|
| - out->push_back(i->second->DeepCopy());
|
| + out->push_back(i->second);
|
| return kSuccess;
|
| }
|
|
|
| @@ -95,4 +86,9 @@ void TestRulesRegistry::OnExtensionUnloaded(const std::string& extension_id) {
|
| LOG(ERROR) << error;
|
| }
|
|
|
| +content::BrowserThread::ID TestRulesRegistry::GetOwnerThread() {
|
| + return content::BrowserThread::UI;
|
| +}
|
| +
|
| +
|
| } // namespace extensions
|
|
|