Chromium Code Reviews| Index: extensions/browser/api/declarative/rules_registry.cc |
| diff --git a/extensions/browser/api/declarative/rules_registry.cc b/extensions/browser/api/declarative/rules_registry.cc |
| index dfd9c35260ace0ea706aa383d78d355c8177e57b..bcc069b9fcb87d7ad4ce311877805d68c1a959b3 100644 |
| --- a/extensions/browser/api/declarative/rules_registry.cc |
| +++ b/extensions/browser/api/declarative/rules_registry.cc |
| @@ -19,6 +19,7 @@ |
| #include "content/public/browser/notification_source.h" |
| #include "extensions/browser/api/declarative/rules_cache_delegate.h" |
| #include "extensions/browser/extension_prefs.h" |
| +#include "extensions/browser/extension_registry.h" |
| #include "extensions/browser/extension_system.h" |
| #include "extensions/browser/state_store.h" |
| #include "extensions/common/extension.h" |
| @@ -226,9 +227,21 @@ void RulesRegistry::OnExtensionLoaded(const std::string& extension_id) { |
| DCHECK_CURRENTLY_ON(owner_thread()); |
| std::vector<linked_ptr<Rule> > rules; |
| GetAllRules(extension_id, &rules); |
| - std::string error = AddRulesImpl(extension_id, rules); |
| - if (!error.empty()) |
| - LOG(ERROR) << error; |
| + if (rules.empty()) { |
| + // If no rules have been registered yet, check if there are any rules |
|
not at google - send to devlin
2015/06/02 22:44:50
Why only if there are no rules registered yet? It
danduong
2015/06/04 23:06:37
Done.
|
| + // defined in the extension manifest to add. |
| + const Extension* extension = |
| + ExtensionRegistry::Get(browser_context()) |
| + ->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING); |
| + const base::ListValue* value = NULL; |
| + if (extension->manifest()->GetList(event_name_, &value)) { |
| + AddRules(extension_id, RulesFromValue(value)); |
| + } |
| + } else { |
| + std::string error = AddRulesImpl(extension_id, rules); |
| + if (!error.empty()) |
| + LOG(ERROR) << error; |
| + } |
| } |
| size_t RulesRegistry::GetNumberOfUsedRuleIdentifiersForTesting() const { |