| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/policy/cloud/user_cloud_policy_invalidator_factory.h" | 5 #include "chrome/browser/policy/cloud/user_cloud_policy_invalidator_factory.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/invalidation/invalidation_service_factory.h" | 8 #include "chrome/browser/invalidation/invalidation_service_factory.h" |
| 9 #include "chrome/browser/policy/cloud/user_cloud_policy_invalidator.h" | 9 #include "chrome/browser/policy/cloud/user_cloud_policy_invalidator.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #else | 36 #else |
| 37 DependsOn(UserCloudPolicyManagerFactory::GetInstance()); | 37 DependsOn(UserCloudPolicyManagerFactory::GetInstance()); |
| 38 #endif | 38 #endif |
| 39 } | 39 } |
| 40 | 40 |
| 41 UserCloudPolicyInvalidatorFactory::~UserCloudPolicyInvalidatorFactory() {} | 41 UserCloudPolicyInvalidatorFactory::~UserCloudPolicyInvalidatorFactory() {} |
| 42 | 42 |
| 43 BrowserContextKeyedService* | 43 BrowserContextKeyedService* |
| 44 UserCloudPolicyInvalidatorFactory::BuildServiceInstanceFor( | 44 UserCloudPolicyInvalidatorFactory::BuildServiceInstanceFor( |
| 45 content::BrowserContext* context) const { | 45 content::BrowserContext* context) const { |
| 46 if (CommandLine::ForCurrentProcess()->HasSwitch( | 46 #if defined(OS_ANDROID) |
| 47 switches::kDisableCloudPolicyPush)) { | 47 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 48 switches::kEnableCloudPolicyPushAndroid)) { |
| 48 return NULL; | 49 return NULL; |
| 49 } | 50 } |
| 51 #else |
| 52 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 53 switches::kDisableCloudPolicyPush)) { |
| 54 return NULL; |
| 55 } |
| 56 #endif |
| 50 | 57 |
| 51 Profile* profile = static_cast<Profile*>(context); | 58 Profile* profile = static_cast<Profile*>(context); |
| 52 #if defined(OS_CHROMEOS) | 59 #if defined(OS_CHROMEOS) |
| 53 CloudPolicyManager* policy_manager = | 60 CloudPolicyManager* policy_manager = |
| 54 UserCloudPolicyManagerFactoryChromeOS::GetForProfile(profile); | 61 UserCloudPolicyManagerFactoryChromeOS::GetForProfile(profile); |
| 55 #else | 62 #else |
| 56 CloudPolicyManager* policy_manager = | 63 CloudPolicyManager* policy_manager = |
| 57 UserCloudPolicyManagerFactory::GetForProfile(profile); | 64 UserCloudPolicyManagerFactory::GetForProfile(profile); |
| 58 #endif | 65 #endif |
| 59 if (!policy_manager) | 66 if (!policy_manager) |
| 60 return NULL; | 67 return NULL; |
| 61 | 68 |
| 62 return new UserCloudPolicyInvalidator(profile, policy_manager); | 69 return new UserCloudPolicyInvalidator(profile, policy_manager); |
| 63 } | 70 } |
| 64 | 71 |
| 65 bool UserCloudPolicyInvalidatorFactory:: | 72 bool UserCloudPolicyInvalidatorFactory:: |
| 66 ServiceIsCreatedWithBrowserContext() const { | 73 ServiceIsCreatedWithBrowserContext() const { |
| 67 // Must be automatically created to enable user policy invalidations. | 74 // Must be automatically created to enable user policy invalidations. |
| 68 return true; | 75 return true; |
| 69 } | 76 } |
| 70 | 77 |
| 71 bool UserCloudPolicyInvalidatorFactory::ServiceIsNULLWhileTesting() const { | 78 bool UserCloudPolicyInvalidatorFactory::ServiceIsNULLWhileTesting() const { |
| 72 // Not used in tests. | 79 // Not used in tests. |
| 73 return true; | 80 return true; |
| 74 } | 81 } |
| 75 | 82 |
| 76 } // namespace policy | 83 } // namespace policy |
| OLD | NEW |