Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Unified Diff: components/keyed_service/content/browser_context_keyed_service_factory.cc

Issue 196783002: Export a private webstore API to call into the new inline sign-in flow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove a spurious diff Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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())

Powered by Google App Engine
This is Rietveld 408576698