| 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" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "chrome/browser/policy/cloud/user_cloud_policy_manager.h" | 9 #include "chrome/browser/policy/cloud/user_cloud_policy_manager.h" |
| 10 #include "chrome/browser/policy/cloud/user_cloud_policy_store.h" | 10 #include "chrome/browser/policy/cloud/user_cloud_policy_store.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 } | 26 } |
| 27 | 27 |
| 28 // static | 28 // static |
| 29 scoped_ptr<UserCloudPolicyManager> | 29 scoped_ptr<UserCloudPolicyManager> |
| 30 UserCloudPolicyManagerFactory::CreateForProfile(Profile* profile, | 30 UserCloudPolicyManagerFactory::CreateForProfile(Profile* profile, |
| 31 bool force_immediate_load) { | 31 bool force_immediate_load) { |
| 32 return GetInstance()->CreateManagerForProfile(profile, force_immediate_load); | 32 return GetInstance()->CreateManagerForProfile(profile, force_immediate_load); |
| 33 } | 33 } |
| 34 | 34 |
| 35 UserCloudPolicyManagerFactory::UserCloudPolicyManagerFactory() | 35 UserCloudPolicyManagerFactory::UserCloudPolicyManagerFactory() |
| 36 : ProfileKeyedBaseFactory("UserCloudPolicyManager", | 36 : BrowserContextKeyedBaseFactory("UserCloudPolicyManager", |
| 37 ProfileDependencyManager::GetInstance()) {} | 37 BrowserContextDependencyManager::GetInstance()) {} |
| 38 | 38 |
| 39 UserCloudPolicyManagerFactory::~UserCloudPolicyManagerFactory() {} | 39 UserCloudPolicyManagerFactory::~UserCloudPolicyManagerFactory() {} |
| 40 | 40 |
| 41 UserCloudPolicyManager* UserCloudPolicyManagerFactory::GetManagerForProfile( | 41 UserCloudPolicyManager* UserCloudPolicyManagerFactory::GetManagerForProfile( |
| 42 Profile* profile) { | 42 Profile* profile) { |
| 43 // Get the manager for the original profile, since the PolicyService is | 43 // Get the manager for the original profile, since the PolicyService is |
| 44 // also shared between the incognito Profile and the original Profile. | 44 // also shared between the incognito Profile and the original Profile. |
| 45 ManagerMap::const_iterator it = managers_.find(profile->GetOriginalProfile()); | 45 ManagerMap::const_iterator it = managers_.find(profile->GetOriginalProfile()); |
| 46 return it != managers_.end() ? it->second : NULL; | 46 return it != managers_.end() ? it->second : NULL; |
| 47 } | 47 } |
| 48 | 48 |
| 49 scoped_ptr<UserCloudPolicyManager> | 49 scoped_ptr<UserCloudPolicyManager> |
| 50 UserCloudPolicyManagerFactory::CreateManagerForProfile( | 50 UserCloudPolicyManagerFactory::CreateManagerForProfile( |
| 51 Profile* profile, | 51 Profile* profile, |
| 52 bool force_immediate_load) { | 52 bool force_immediate_load) { |
| 53 if (CommandLine::ForCurrentProcess()->HasSwitch( | 53 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 54 switches::kDisableCloudPolicyOnSignin)) { | 54 switches::kDisableCloudPolicyOnSignin)) { |
| 55 return scoped_ptr<UserCloudPolicyManager>(); | 55 return scoped_ptr<UserCloudPolicyManager>(); |
| 56 } | 56 } |
| 57 scoped_ptr<UserCloudPolicyStore> store(UserCloudPolicyStore::Create(profile)); | 57 scoped_ptr<UserCloudPolicyStore> store(UserCloudPolicyStore::Create(profile)); |
| 58 if (force_immediate_load) | 58 if (force_immediate_load) |
| 59 store->LoadImmediately(); | 59 store->LoadImmediately(); |
| 60 scoped_ptr<UserCloudPolicyManager> manager( | 60 scoped_ptr<UserCloudPolicyManager> manager( |
| 61 new UserCloudPolicyManager(profile, store.Pass())); | 61 new UserCloudPolicyManager(profile, store.Pass())); |
| 62 manager->Init(); | 62 manager->Init(); |
| 63 return manager.Pass(); | 63 return manager.Pass(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 void UserCloudPolicyManagerFactory::ProfileShutdown( | 66 void UserCloudPolicyManagerFactory::BrowserContextShutdown( |
| 67 content::BrowserContext* context) { | 67 content::BrowserContext* context) { |
| 68 Profile* profile = static_cast<Profile*>(context); | 68 Profile* profile = static_cast<Profile*>(context); |
| 69 if (profile->IsOffTheRecord()) | 69 if (profile->IsOffTheRecord()) |
| 70 return; | 70 return; |
| 71 UserCloudPolicyManager* manager = GetManagerForProfile(profile); | 71 UserCloudPolicyManager* manager = GetManagerForProfile(profile); |
| 72 if (manager) { | 72 if (manager) { |
| 73 manager->CloudPolicyManager::Shutdown(); | 73 manager->CloudPolicyManager::Shutdown(); |
| 74 manager->ProfileKeyedService::Shutdown(); | 74 manager->BrowserContextKeyedService::Shutdown(); |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 | 77 |
| 78 void UserCloudPolicyManagerFactory::SetEmptyTestingFactory( | 78 void UserCloudPolicyManagerFactory::SetEmptyTestingFactory( |
| 79 content::BrowserContext* profile) { | 79 content::BrowserContext* profile) { |
| 80 } | 80 } |
| 81 | 81 |
| 82 void UserCloudPolicyManagerFactory::CreateServiceNow( | 82 void UserCloudPolicyManagerFactory::CreateServiceNow( |
| 83 content::BrowserContext* profile) { | 83 content::BrowserContext* profile) { |
| 84 } | 84 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 96 ManagerMap::iterator entry = managers_.find(profile); | 96 ManagerMap::iterator entry = managers_.find(profile); |
| 97 if (entry != managers_.end()) { | 97 if (entry != managers_.end()) { |
| 98 DCHECK_EQ(instance, entry->second); | 98 DCHECK_EQ(instance, entry->second); |
| 99 managers_.erase(entry); | 99 managers_.erase(entry); |
| 100 } else { | 100 } else { |
| 101 NOTREACHED(); | 101 NOTREACHED(); |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 | 104 |
| 105 } // namespace policy | 105 } // namespace policy |
| OLD | NEW |