Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / policy / cloud / user_cloud_policy_invalidator_factory.cc
blobe4c7fef6f4a384c60db212fefac95482ec69f25d
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"
14 #else
15 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h"
16 #include "components/policy/core/common/cloud/user_cloud_policy_manager.h"
17 #endif
19 namespace policy {
21 // static
22 UserCloudPolicyInvalidatorFactory*
23 UserCloudPolicyInvalidatorFactory::GetInstance() {
24 return 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());
34 #else
35 DependsOn(UserCloudPolicyManagerFactory::GetInstance());
36 #endif
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);
47 #else
48 CloudPolicyManager* policy_manager =
49 UserCloudPolicyManagerFactory::GetForBrowserContext(context);
50 #endif
51 if (!policy_manager)
52 return NULL;
54 return new UserCloudPolicyInvalidator(profile, policy_manager);
57 bool UserCloudPolicyInvalidatorFactory::
58 ServiceIsCreatedWithBrowserContext() const {
59 // Must be automatically created to enable user policy invalidations.
60 return true;
63 bool UserCloudPolicyInvalidatorFactory::ServiceIsNULLWhileTesting() const {
64 // Not used in tests.
65 return true;
68 } // namespace policy