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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/keyed_service/content/browser_context_keyed_service_factory .h" 5 #include "components/keyed_service/content/browser_context_keyed_service_factory .h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "components/keyed_service/content/browser_context_dependency_manager.h" 11 #include "components/keyed_service/content/browser_context_dependency_manager.h"
12 #include "components/keyed_service/core/keyed_service.h" 12 #include "components/keyed_service/core/keyed_service.h"
13 #include "content/public/browser/browser_context.h" 13 #include "content/public/browser/browser_context.h"
14 14
15 void BrowserContextKeyedServiceFactory::SetTestingFactory( 15 void BrowserContextKeyedServiceFactory::SetTestingFactory(
16 content::BrowserContext* context, 16 content::BrowserContext* context,
17 TestingFactoryFunction testing_factory) { 17 TestingFactoryFunction testing_factory) {
18 if (!context) {
19 testing_factories_[NULL] = testing_factory;
20 return;
21 }
22
18 // Destroying the context may cause us to lose data about whether |context| 23 // Destroying the context may cause us to lose data about whether |context|
19 // has our preferences registered on it (since the context object itself 24 // has our preferences registered on it (since the context object itself
20 // isn't dead). See if we need to readd it once we've gone through normal 25 // isn't dead). See if we need to readd it once we've gone through normal
21 // destruction. 26 // destruction.
22 bool add_context = ArePreferencesSetOn(context); 27 bool add_context = ArePreferencesSetOn(context);
23 28
24 #ifndef NDEBUG 29 #ifndef NDEBUG
25 // Ensure that |context| is not marked as stale (e.g., due to it aliasing an 30 // Ensure that |context| is not marked as stale (e.g., due to it aliasing an
26 // instance that was destroyed in an earlier test) in order to avoid accesses 31 // instance that was destroyed in an earlier test) in order to avoid accesses
27 // to |context| in |BrowserContextShutdown| from causing 32 // to |context| in |BrowserContextShutdown| from causing
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 BrowserContextKeyedServices::const_iterator it = mapping_.find(context); 75 BrowserContextKeyedServices::const_iterator it = mapping_.find(context);
71 if (it != mapping_.end()) 76 if (it != mapping_.end())
72 return it->second; 77 return it->second;
73 78
74 // Object not found. 79 // Object not found.
75 if (!create) 80 if (!create)
76 return NULL; // And we're forbidden from creating one. 81 return NULL; // And we're forbidden from creating one.
77 82
78 // Create new object. 83 // Create new object.
79 // Check to see if we have a per-BrowserContext testing factory that we should 84 // Check to see if we have a per-BrowserContext testing factory that we should
80 // use instead of default behavior. 85 // use instead of default behavior. Check for a global factory as well.
81 KeyedService* service = NULL; 86 KeyedService* service = NULL;
82 BrowserContextOverriddenTestingFunctions::const_iterator jt = 87 BrowserContextOverriddenTestingFunctions::const_iterator jt =
83 testing_factories_.find(context); 88 testing_factories_.find(context);
89 if (jt == testing_factories_.end())
90 jt = testing_factories_.find(NULL);
84 if (jt != testing_factories_.end()) { 91 if (jt != testing_factories_.end()) {
85 if (jt->second) { 92 if (jt->second) {
86 if (!context->IsOffTheRecord()) 93 if (!context->IsOffTheRecord())
87 RegisterUserPrefsOnBrowserContextForTest(context); 94 RegisterUserPrefsOnBrowserContextForTest(context);
88 service = jt->second(context); 95 service = jt->second(context);
89 } 96 }
90 } else { 97 } else {
91 service = BuildServiceInstanceFor(context); 98 service = BuildServiceInstanceFor(context);
92 } 99 }
93 100
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 140
134 void BrowserContextKeyedServiceFactory::SetEmptyTestingFactory( 141 void BrowserContextKeyedServiceFactory::SetEmptyTestingFactory(
135 content::BrowserContext* context) { 142 content::BrowserContext* context) {
136 SetTestingFactory(context, NULL); 143 SetTestingFactory(context, NULL);
137 } 144 }
138 145
139 void BrowserContextKeyedServiceFactory::CreateServiceNow( 146 void BrowserContextKeyedServiceFactory::CreateServiceNow(
140 content::BrowserContext* context) { 147 content::BrowserContext* context) {
141 GetServiceForBrowserContext(context, true); 148 GetServiceForBrowserContext(context, true);
142 } 149 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698