| Index: components/keyed_service/content/browser_context_keyed_service_factory.cc
|
| diff --git a/components/keyed_service/content/browser_context_keyed_service_factory.cc b/components/keyed_service/content/browser_context_keyed_service_factory.cc
|
| index f2180a6ec349edc27f7ffeb32046bffe5517b847..532e990f8806e40e212f46eb311de35c40958b9b 100644
|
| --- a/components/keyed_service/content/browser_context_keyed_service_factory.cc
|
| +++ b/components/keyed_service/content/browser_context_keyed_service_factory.cc
|
| @@ -15,6 +15,11 @@
|
| void BrowserContextKeyedServiceFactory::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
|
| @@ -77,10 +82,12 @@ KeyedService* BrowserContextKeyedServiceFactory::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.
|
| KeyedService* service = NULL;
|
| 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())
|
|
|