Chromium Code Reviews| Index: chrome/browser/chromeos/policy/consumer_enrollment_handler_factory.cc |
| diff --git a/chrome/browser/chromeos/policy/consumer_enrollment_handler_factory.cc b/chrome/browser/chromeos/policy/consumer_enrollment_handler_factory.cc |
| index e78ef4147a8e62214084582a8cef69fa84084007..32e30afe3f51a0a21b75ecbb14bd4630bddd9ee9 100644 |
| --- a/chrome/browser/chromeos/policy/consumer_enrollment_handler_factory.cc |
| +++ b/chrome/browser/chromeos/policy/consumer_enrollment_handler_factory.cc |
| @@ -42,38 +42,28 @@ ConsumerEnrollmentHandlerFactory::ConsumerEnrollmentHandlerFactory() |
| ConsumerEnrollmentHandlerFactory::~ConsumerEnrollmentHandlerFactory() { |
| } |
| -bool ConsumerEnrollmentHandlerFactory::ShouldCreateHandler( |
| - Profile* profile, |
| - ConsumerManagementService* service) const { |
| - if (!service) |
| - return false; |
| - |
| - // On a fresh device, the first time the owner signs in, IsOwnerProfile() |
| - // will return false. But it is okay since there's no enrollment in progress |
| - // so we don't need to create a handler. |
| - if (!chromeos::ProfileHelper::IsOwnerProfile(profile)) |
| - return false; |
| - |
| - return service->GetStatus() == ConsumerManagementService::STATUS_ENROLLING || |
| - service->HasPendingEnrollmentNotification(); |
| -} |
| - |
| KeyedService* ConsumerEnrollmentHandlerFactory::BuildServiceInstanceFor( |
| content::BrowserContext* context) const { |
| + // On a fresh device, the first time the owner signs in, IsOwnerProfile() |
| + // will return false. But it is okay since there's no enrollment in progress. |
| Profile* profile = Profile::FromBrowserContext(context); |
| + if (!chromeos::ProfileHelper::IsOwnerProfile(profile)) |
| + return nullptr; |
| + |
| BrowserPolicyConnectorChromeOS* connector = |
| g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| ConsumerManagementService* service = |
| connector->GetConsumerManagementService(); |
| + if (!service) |
| + return nullptr; |
| - if (ShouldCreateHandler(profile, service)) { |
| - return new ConsumerEnrollmentHandler( |
| - profile, |
| - service, |
| - connector->GetDeviceManagementServiceForConsumer()); |
| - } else { |
| + if (service->GetStatus() != ConsumerManagementService::STATUS_ENROLLING) |
|
Mattias Nissler (ping if slow)
2014/11/18 10:02:26
nit: could merge this conditional with the one in
davidyu
2014/11/19 02:54:21
Done.
|
| return nullptr; |
| - } |
| + |
| + return new ConsumerEnrollmentHandler( |
| + profile, |
| + service, |
| + connector->GetDeviceManagementServiceForConsumer()); |
| } |
| bool ConsumerEnrollmentHandlerFactory::ServiceIsCreatedWithBrowserContext() |