| Index: components/keyed_service/content/refcounted_browser_context_keyed_service_factory.cc
|
| diff --git a/components/keyed_service/content/refcounted_browser_context_keyed_service_factory.cc b/components/keyed_service/content/refcounted_browser_context_keyed_service_factory.cc
|
| index 4f75d99a72e6dbbb1504f04d7e0c9622f5a6b01e..6876ce5c5f0e31a9a8b7251150b86b89cf37db1d 100644
|
| --- a/components/keyed_service/content/refcounted_browser_context_keyed_service_factory.cc
|
| +++ b/components/keyed_service/content/refcounted_browser_context_keyed_service_factory.cc
|
| @@ -13,6 +13,11 @@
|
| void RefcountedBrowserContextKeyedServiceFactory::SetTestingFactory(
|
| content::BrowserContext* context,
|
| TestingFactoryFunction testing_factory) {
|
| + if (!context) {
|
| + testing_factories_[NULL] = testing_factory;
|
| + return;
|
| + }
|
| +
|
| // Destroying the context may cause us to lose data about whether |context|
|
| // has our preferences registered on it (since the context object itself
|
| // isn't dead). See if we need to readd it once we've gone through normal
|
| @@ -71,10 +76,12 @@ RefcountedBrowserContextKeyedServiceFactory::GetServiceForBrowserContext(
|
|
|
| // Create new object.
|
| // Check to see if we have a per-BrowserContext testing factory that we should
|
| - // use instead of default behavior.
|
| + // use instead of default behavior. Check for a global factory as well.
|
| scoped_refptr<RefcountedBrowserContextKeyedService> service;
|
| BrowserContextOverriddenTestingFunctions::const_iterator jt =
|
| testing_factories_.find(context);
|
| + if (jt == testing_factories_.end())
|
| + jt = testing_factories_.find(NULL);
|
| if (jt != testing_factories_.end()) {
|
| if (jt->second) {
|
| if (!context->IsOffTheRecord())
|
|
|