| Index: chrome/browser/profiles/profile_keyed_service_factory.cc
|
| diff --git a/chrome/browser/profiles/profile_keyed_service_factory.cc b/chrome/browser/profiles/profile_keyed_service_factory.cc
|
| index 755409e28257057567530e22b8f071cb5bfc67eb..851571432603e4fc1bbc4b9c470226ac3b43f258 100644
|
| --- a/chrome/browser/profiles/profile_keyed_service_factory.cc
|
| +++ b/chrome/browser/profiles/profile_keyed_service_factory.cc
|
| @@ -23,7 +23,8 @@ ProfileKeyedServiceFactory::~ProfileKeyedServiceFactory() {
|
| }
|
|
|
| ProfileKeyedService* ProfileKeyedServiceFactory::GetServiceForProfile(
|
| - Profile* profile) {
|
| + Profile* profile,
|
| + bool create) {
|
| // Possibly handle Incognito mode.
|
| if (profile->IsOffTheRecord()) {
|
| if (ServiceRedirectedInIncognito()) {
|
| @@ -41,14 +42,18 @@ ProfileKeyedService* ProfileKeyedServiceFactory::GetServiceForProfile(
|
| mapping_.find(profile);
|
| if (it != mapping_.end()) {
|
| service = it->second;
|
| - if (service || !factory_)
|
| + if (service || !factory_ || !create)
|
| return service;
|
|
|
| // service is NULL but we have a mock factory function
|
| mapping_.erase(it);
|
| service = factory_(profile);
|
| - } else {
|
| + } else if (create) {
|
| + // not found but creation allowed
|
| service = BuildServiceInstanceFor(profile);
|
| + } else {
|
| + // not found, creation forbidden
|
| + return NULL;
|
| }
|
|
|
| Associate(profile, service);
|
|
|