| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_manager_factory.h" | 5 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | |
| 8 #include "base/logging.h" | 7 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "chrome/browser/policy/cloud/cloud_external_data_manager.h" | 9 #include "chrome/browser/policy/cloud/cloud_external_data_manager.h" |
| 11 #include "chrome/browser/policy/cloud/user_cloud_policy_manager.h" | 10 #include "chrome/browser/policy/cloud/user_cloud_policy_manager.h" |
| 12 #include "chrome/browser/policy/cloud/user_cloud_policy_store.h" | 11 #include "chrome/browser/policy/cloud/user_cloud_policy_store.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 14 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" | 13 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
| 15 #include "components/policy/core/common/policy_switches.h" | |
| 16 | 14 |
| 17 namespace policy { | 15 namespace policy { |
| 18 | 16 |
| 19 // static | 17 // static |
| 20 UserCloudPolicyManagerFactory* UserCloudPolicyManagerFactory::GetInstance() { | 18 UserCloudPolicyManagerFactory* UserCloudPolicyManagerFactory::GetInstance() { |
| 21 return Singleton<UserCloudPolicyManagerFactory>::get(); | 19 return Singleton<UserCloudPolicyManagerFactory>::get(); |
| 22 } | 20 } |
| 23 | 21 |
| 24 // static | 22 // static |
| 25 UserCloudPolicyManager* UserCloudPolicyManagerFactory::GetForProfile( | 23 UserCloudPolicyManager* UserCloudPolicyManagerFactory::GetForProfile( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 46 // Get the manager for the original profile, since the PolicyService is | 44 // Get the manager for the original profile, since the PolicyService is |
| 47 // also shared between the incognito Profile and the original Profile. | 45 // also shared between the incognito Profile and the original Profile. |
| 48 ManagerMap::const_iterator it = managers_.find(profile->GetOriginalProfile()); | 46 ManagerMap::const_iterator it = managers_.find(profile->GetOriginalProfile()); |
| 49 return it != managers_.end() ? it->second : NULL; | 47 return it != managers_.end() ? it->second : NULL; |
| 50 } | 48 } |
| 51 | 49 |
| 52 scoped_ptr<UserCloudPolicyManager> | 50 scoped_ptr<UserCloudPolicyManager> |
| 53 UserCloudPolicyManagerFactory::CreateManagerForProfile( | 51 UserCloudPolicyManagerFactory::CreateManagerForProfile( |
| 54 Profile* profile, | 52 Profile* profile, |
| 55 bool force_immediate_load) { | 53 bool force_immediate_load) { |
| 56 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 57 switches::kDisableCloudPolicyOnSignin)) { | |
| 58 return scoped_ptr<UserCloudPolicyManager>(); | |
| 59 } | |
| 60 scoped_ptr<UserCloudPolicyStore> store(UserCloudPolicyStore::Create(profile)); | 54 scoped_ptr<UserCloudPolicyStore> store(UserCloudPolicyStore::Create(profile)); |
| 61 if (force_immediate_load) | 55 if (force_immediate_load) |
| 62 store->LoadImmediately(); | 56 store->LoadImmediately(); |
| 63 scoped_ptr<UserCloudPolicyManager> manager( | 57 scoped_ptr<UserCloudPolicyManager> manager( |
| 64 new UserCloudPolicyManager(profile, | 58 new UserCloudPolicyManager(profile, |
| 65 store.Pass(), | 59 store.Pass(), |
| 66 scoped_ptr<CloudExternalDataManager>(), | 60 scoped_ptr<CloudExternalDataManager>(), |
| 67 base::MessageLoopProxy::current())); | 61 base::MessageLoopProxy::current())); |
| 68 manager->Init(); | 62 manager->Init(); |
| 69 return manager.Pass(); | 63 return manager.Pass(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 100 ManagerMap::iterator entry = managers_.find(profile); | 94 ManagerMap::iterator entry = managers_.find(profile); |
| 101 if (entry != managers_.end()) { | 95 if (entry != managers_.end()) { |
| 102 DCHECK_EQ(instance, entry->second); | 96 DCHECK_EQ(instance, entry->second); |
| 103 managers_.erase(entry); | 97 managers_.erase(entry); |
| 104 } else { | 98 } else { |
| 105 NOTREACHED(); | 99 NOTREACHED(); |
| 106 } | 100 } |
| 107 } | 101 } |
| 108 | 102 |
| 109 } // namespace policy | 103 } // namespace policy |
| OLD | NEW |