Index: chrome/browser/extensions/api/declarative/rules_registry_service.cc |
diff --git a/chrome/browser/extensions/api/declarative/rules_registry_service.cc b/chrome/browser/extensions/api/declarative/rules_registry_service.cc |
index 614712c2edfa1ee2c83822766f00ae024bf492dc..464e009f5aa61803e37b18fcf982b67677c275ee 100644 |
--- a/chrome/browser/extensions/api/declarative/rules_registry_service.cc |
+++ b/chrome/browser/extensions/api/declarative/rules_registry_service.cc |
@@ -5,6 +5,7 @@ |
#include "chrome/browser/extensions/api/declarative/rules_registry_service.h" |
#include "base/bind.h" |
+#include "base/lazy_instance.h" |
#include "base/logging.h" |
#include "base/memory/scoped_ptr.h" |
#include "chrome/browser/extensions/api/declarative/initializing_rules_registry.h" |
@@ -36,6 +37,20 @@ RulesRegistryService::RulesRegistryService(Profile* profile) |
if (profile) { |
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
content::Source<Profile>(profile->GetOriginalProfile())); |
+ if (profile->HasOffTheRecordProfile() && |
+ profile->GetOffTheRecordProfile() == profile) { |
+ |
+ // Only initialize the RulesRegistryService for a OTR profile |
+ // if the regular ExtensionSystem has been initialized properly, as we |
+ // depend on it. Some ChromeOS browser tests don't initialize the |
+ // regular ExtensionSystem in login-tests. Currently these browser |
+ // tests are EnterpriseLoginBlocksForEnterpriseUser and |
Yoyo Zhou
2013/05/09 01:08:54
You don't have to name these tests here; this comm
|
+ // NormalLoginDoesntBlock. |
+ if (ExtensionSystem::Get(profile)->extension_service()) |
+ RegisterDefaultRulesRegistries(); |
+ } else { |
+ RegisterDefaultRulesRegistries(); |
+ } |
} |
} |
@@ -70,6 +85,20 @@ void RulesRegistryService::Shutdown() { |
profile_, scoped_refptr<WebRequestRulesRegistry>(NULL))); |
} |
+static base::LazyInstance<ProfileKeyedAPIFactory<RulesRegistryService> > |
+g_factory = LAZY_INSTANCE_INITIALIZER; |
+ |
+// static |
+ProfileKeyedAPIFactory<RulesRegistryService>* |
+RulesRegistryService::GetFactoryInstance() { |
+ return &g_factory.Get(); |
+} |
+ |
+// static |
+RulesRegistryService* RulesRegistryService::Get(Profile* profile) { |
+ return ProfileKeyedAPIFactory<RulesRegistryService>::GetForProfile(profile); |
+} |
+ |
void RulesRegistryService::RegisterRulesRegistry( |
scoped_refptr<RulesRegistry> rule_registry) { |
const std::string event_name(rule_registry->event_name()); |