1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/policy/cloud/user_cloud_policy_invalidator_factory.h"
7 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
8 #include "chrome/browser/policy/cloud/user_cloud_policy_invalidator.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "components/keyed_service/content/browser_context_dependency_manager.h"
11 #if defined(OS_CHROMEOS)
12 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h"
13 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.h"
15 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h"
16 #include "components/policy/core/common/cloud/user_cloud_policy_manager.h"
22 UserCloudPolicyInvalidatorFactory
*
23 UserCloudPolicyInvalidatorFactory::GetInstance() {
24 return base::Singleton
<UserCloudPolicyInvalidatorFactory
>::get();
27 UserCloudPolicyInvalidatorFactory::UserCloudPolicyInvalidatorFactory()
28 : BrowserContextKeyedServiceFactory(
29 "UserCloudPolicyInvalidator",
30 BrowserContextDependencyManager::GetInstance()) {
31 DependsOn(invalidation::ProfileInvalidationProviderFactory::GetInstance());
32 #if defined(OS_CHROMEOS)
33 DependsOn(UserCloudPolicyManagerFactoryChromeOS::GetInstance());
35 DependsOn(UserCloudPolicyManagerFactory::GetInstance());
39 UserCloudPolicyInvalidatorFactory::~UserCloudPolicyInvalidatorFactory() {}
41 KeyedService
* UserCloudPolicyInvalidatorFactory::BuildServiceInstanceFor(
42 content::BrowserContext
* context
) const {
43 Profile
* profile
= static_cast<Profile
*>(context
);
44 #if defined(OS_CHROMEOS)
45 CloudPolicyManager
* policy_manager
=
46 UserCloudPolicyManagerFactoryChromeOS::GetForProfile(profile
);
48 CloudPolicyManager
* policy_manager
=
49 UserCloudPolicyManagerFactory::GetForBrowserContext(context
);
54 return new UserCloudPolicyInvalidator(profile
, policy_manager
);
57 bool UserCloudPolicyInvalidatorFactory::
58 ServiceIsCreatedWithBrowserContext() const {
59 // Must be automatically created to enable user policy invalidations.
63 bool UserCloudPolicyInvalidatorFactory::ServiceIsNULLWhileTesting() const {