OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 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. | |
4 | |
5 #include "chrome/browser/policy/cloud/user_cloud_policy_invalidator_factory.h" | |
6 | |
7 #include "base/command_line.h" | |
8 #if defined(OS_CHROMEOS) | |
Joao da Silva
2013/07/25 18:03:53
Put OS_CHROMEOS #includes after the unconditional
Steve Condie
2013/07/26 01:39:25
Done.
| |
9 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | |
10 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h" | |
11 #endif | |
12 #include "chrome/browser/invalidation/invalidation_service_factory.h" | |
13 #include "chrome/browser/policy/cloud/user_cloud_policy_invalidator.h" | |
14 #if !defined(OS_CHROMEOS) | |
Joao da Silva
2013/07/25 18:03:53
Same for these
Steve Condie
2013/07/26 01:39:25
Done.
| |
15 #include "chrome/browser/policy/cloud/user_cloud_policy_manager.h" | |
16 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" | |
17 #endif | |
18 #include "chrome/browser/profiles/profile.h" | |
19 #include "chrome/common/chrome_switches.h" | |
20 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" | |
21 | |
22 namespace policy { | |
23 | |
24 namespace { | |
25 #if defined(OS_CHROMEOS) | |
26 typedef UserCloudPolicyManagerFactoryChromeOS CloudPolicyManagerFactory; | |
27 #else | |
28 typedef UserCloudPolicyManagerFactory CloudPolicyManagerFactory; | |
29 #endif | |
30 } // namespace | |
Joao da Silva
2013/07/25 18:03:53
no need for the namespace for typedefs.
Also, it'
Steve Condie
2013/07/26 01:39:25
Done.
| |
31 | |
32 // static | |
33 UserCloudPolicyInvalidatorFactory* | |
34 UserCloudPolicyInvalidatorFactory::GetInstance() { | |
35 return Singleton<UserCloudPolicyInvalidatorFactory>::get(); | |
36 } | |
37 | |
38 UserCloudPolicyInvalidatorFactory::UserCloudPolicyInvalidatorFactory() | |
39 : BrowserContextKeyedServiceFactory( | |
40 "UserCloudPolicyInvalidator", | |
41 BrowserContextDependencyManager::GetInstance()) { | |
42 DependsOn(invalidation::InvalidationServiceFactory::GetInstance()); | |
43 DependsOn(CloudPolicyManagerFactory::GetInstance()); | |
44 } | |
45 | |
46 UserCloudPolicyInvalidatorFactory::~UserCloudPolicyInvalidatorFactory() {} | |
47 | |
48 BrowserContextKeyedService* | |
49 UserCloudPolicyInvalidatorFactory::BuildServiceInstanceFor( | |
50 content::BrowserContext* context) const { | |
51 #if !defined(ANDROID_OS) // Allow invalidations on Android regardless of switch. | |
52 if (!CommandLine::ForCurrentProcess()->HasSwitch( | |
53 switches::kEnableCloudPolicyPush)) { | |
54 return NULL; | |
55 } | |
56 #endif | |
Joao da Silva
2013/07/25 18:03:53
After discussing this with Mattias we decided it's
Steve Condie
2013/07/26 01:39:25
Done.
| |
57 | |
58 Profile* profile = static_cast<Profile*>(context); | |
59 invalidation::InvalidationService* invalidation_service = | |
60 invalidation::InvalidationServiceFactory::GetForProfile(profile); | |
rlarocque
2013/07/25 19:23:40
I'm just catching up on the discussions of service
Steve Condie
2013/07/26 01:39:25
This will be solved by not attempting to get the I
| |
61 CloudPolicyManager* policy_manager = | |
62 CloudPolicyManagerFactory::GetForProfile(profile); | |
63 if (!invalidation_service || !policy_manager) | |
64 return NULL; | |
65 | |
66 return new UserCloudPolicyInvalidator(invalidation_service, policy_manager); | |
67 } | |
68 | |
69 bool UserCloudPolicyInvalidatorFactory:: | |
70 ServiceIsCreatedWithBrowserContext() const { | |
71 // Must be automatically created to enable user policy invalidations. | |
72 return true; | |
73 } | |
74 | |
75 bool UserCloudPolicyInvalidatorFactory::ServiceIsNULLWhileTesting() const { | |
76 // Not used in tests. | |
77 return true; | |
78 } | |
79 | |
80 } // namespace policy | |
OLD | NEW |