| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" | 5 #include "chrome/browser/chromeos/policy/user_policy_manager_factory_chromeos.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/ptr_util.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 15 #include "base/sequenced_task_runner.h" | 16 #include "base/sequenced_task_runner.h" |
| 16 #include "base/threading/sequenced_worker_pool.h" | 17 #include "base/threading/sequenced_worker_pool.h" |
| 17 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
| 18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 19 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 21 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 22 #include "chrome/browser/chromeos/policy/user_active_directory_policy_manager.h" |
| 21 #include "chrome/browser/chromeos/policy/user_cloud_external_data_manager.h" | 23 #include "chrome/browser/chromeos/policy/user_cloud_external_data_manager.h" |
| 22 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 24 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
| 23 #include "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h" | 25 #include "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h" |
| 24 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 26 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 25 #include "chrome/browser/chromeos/settings/cros_settings.h" | 27 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 28 #include "chrome/browser/chromeos/settings/install_attributes.h" |
| 26 #include "chrome/browser/policy/schema_registry_service.h" | 29 #include "chrome/browser/policy/schema_registry_service.h" |
| 27 #include "chrome/browser/policy/schema_registry_service_factory.h" | 30 #include "chrome/browser/policy/schema_registry_service_factory.h" |
| 28 #include "chrome/browser/profiles/profile.h" | 31 #include "chrome/browser/profiles/profile.h" |
| 29 #include "chromeos/chromeos_paths.h" | 32 #include "chromeos/chromeos_paths.h" |
| 30 #include "chromeos/chromeos_switches.h" | 33 #include "chromeos/chromeos_switches.h" |
| 31 #include "chromeos/dbus/dbus_thread_manager.h" | 34 #include "chromeos/dbus/dbus_thread_manager.h" |
| 32 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 35 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 33 #include "components/policy/core/browser/browser_policy_connector.h" | 36 #include "components/policy/core/browser/browser_policy_connector.h" |
| 34 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" | 37 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" |
| 35 #include "components/policy/core/common/cloud/device_management_service.h" | 38 #include "components/policy/core/common/cloud/device_management_service.h" |
| 39 #include "components/policy/core/common/configuration_policy_provider.h" |
| 36 #include "components/policy/policy_constants.h" | 40 #include "components/policy/policy_constants.h" |
| 37 #include "components/user_manager/user.h" | 41 #include "components/user_manager/user.h" |
| 38 #include "components/user_manager/user_manager.h" | 42 #include "components/user_manager/user_manager.h" |
| 39 #include "content/public/browser/browser_thread.h" | 43 #include "content/public/browser/browser_thread.h" |
| 40 #include "net/url_request/url_request_context_getter.h" | 44 #include "net/url_request/url_request_context_getter.h" |
| 41 | 45 |
| 42 namespace policy { | 46 namespace policy { |
| 43 | 47 |
| 44 namespace { | 48 namespace { |
| 45 | 49 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 57 const base::FilePath::CharType kPolicyExternalDataDir[] = | 61 const base::FilePath::CharType kPolicyExternalDataDir[] = |
| 58 FILE_PATH_LITERAL("External Data"); | 62 FILE_PATH_LITERAL("External Data"); |
| 59 | 63 |
| 60 // Timeout in seconds after which to abandon the initial policy fetch and start | 64 // Timeout in seconds after which to abandon the initial policy fetch and start |
| 61 // the session regardless. | 65 // the session regardless. |
| 62 const int kInitialPolicyFetchTimeoutSeconds = 10; | 66 const int kInitialPolicyFetchTimeoutSeconds = 10; |
| 63 | 67 |
| 64 } // namespace | 68 } // namespace |
| 65 | 69 |
| 66 // static | 70 // static |
| 67 UserCloudPolicyManagerFactoryChromeOS* | 71 UserPolicyManagerFactoryChromeOS* |
| 68 UserCloudPolicyManagerFactoryChromeOS::GetInstance() { | 72 UserPolicyManagerFactoryChromeOS::GetInstance() { |
| 69 return base::Singleton<UserCloudPolicyManagerFactoryChromeOS>::get(); | 73 return base::Singleton<UserPolicyManagerFactoryChromeOS>::get(); |
| 74 } |
| 75 |
| 76 // static |
| 77 ConfigurationPolicyProvider* UserPolicyManagerFactoryChromeOS::GetForProfile( |
| 78 Profile* profile) { |
| 79 ConfigurationPolicyProvider* cloud_provider = |
| 80 GetInstance()->GetCloudPolicyManagerForProfile(profile); |
| 81 if (cloud_provider) { |
| 82 return cloud_provider; |
| 83 } |
| 84 return GetInstance()->GetActiveDirectoryPolicyManagerForProfile(profile); |
| 70 } | 85 } |
| 71 | 86 |
| 72 // static | 87 // static |
| 73 UserCloudPolicyManagerChromeOS* | 88 UserCloudPolicyManagerChromeOS* |
| 74 UserCloudPolicyManagerFactoryChromeOS::GetForProfile( | 89 UserPolicyManagerFactoryChromeOS::GetCloudPolicyManagerForProfile( |
| 75 Profile* profile) { | 90 Profile* profile) { |
| 76 return GetInstance()->GetManagerForProfile(profile); | 91 return GetInstance()->GetCloudPolicyManager(profile); |
| 77 } | 92 } |
| 78 | 93 |
| 79 // static | 94 // static |
| 80 std::unique_ptr<UserCloudPolicyManagerChromeOS> | 95 UserActiveDirectoryPolicyManager* |
| 81 UserCloudPolicyManagerFactoryChromeOS::CreateForProfile( | 96 UserPolicyManagerFactoryChromeOS::GetActiveDirectoryPolicyManagerForProfile( |
| 97 Profile* profile) { |
| 98 return GetInstance()->GetActiveDirectoryPolicyManager(profile); |
| 99 } |
| 100 |
| 101 // static |
| 102 std::unique_ptr<ConfigurationPolicyProvider> |
| 103 UserPolicyManagerFactoryChromeOS::CreateForProfile( |
| 82 Profile* profile, | 104 Profile* profile, |
| 83 bool force_immediate_load, | 105 bool force_immediate_load, |
| 84 scoped_refptr<base::SequencedTaskRunner> background_task_runner) { | 106 scoped_refptr<base::SequencedTaskRunner> background_task_runner) { |
| 85 return GetInstance()->CreateManagerForProfile( | 107 return GetInstance()->CreateManagerForProfile(profile, force_immediate_load, |
| 86 profile, force_immediate_load, background_task_runner); | 108 background_task_runner); |
| 87 } | 109 } |
| 88 | 110 |
| 89 UserCloudPolicyManagerFactoryChromeOS::UserCloudPolicyManagerFactoryChromeOS() | 111 UserPolicyManagerFactoryChromeOS::UserPolicyManagerFactoryChromeOS() |
| 90 : BrowserContextKeyedBaseFactory( | 112 : BrowserContextKeyedBaseFactory( |
| 91 "UserCloudPolicyManagerChromeOS", | 113 "UserCloudPolicyManagerChromeOS", |
| 92 BrowserContextDependencyManager::GetInstance()) { | 114 BrowserContextDependencyManager::GetInstance()) { |
| 93 DependsOn(SchemaRegistryServiceFactory::GetInstance()); | 115 DependsOn(SchemaRegistryServiceFactory::GetInstance()); |
| 94 } | 116 } |
| 95 | 117 |
| 96 UserCloudPolicyManagerFactoryChromeOS:: | 118 UserPolicyManagerFactoryChromeOS::~UserPolicyManagerFactoryChromeOS() {} |
| 97 ~UserCloudPolicyManagerFactoryChromeOS() {} | |
| 98 | 119 |
| 99 UserCloudPolicyManagerChromeOS* | 120 UserCloudPolicyManagerChromeOS* |
| 100 UserCloudPolicyManagerFactoryChromeOS::GetManagerForProfile( | 121 UserPolicyManagerFactoryChromeOS::GetCloudPolicyManager(Profile* profile) { |
| 101 Profile* profile) { | |
| 102 // Get the manager for the original profile, since the PolicyService is | 122 // Get the manager for the original profile, since the PolicyService is |
| 103 // also shared between the incognito Profile and the original Profile. | 123 // also shared between the incognito Profile and the original Profile. |
| 104 ManagerMap::const_iterator it = managers_.find(profile->GetOriginalProfile()); | 124 const auto it = cloud_managers_.find(profile->GetOriginalProfile()); |
| 105 return it != managers_.end() ? it->second : NULL; | 125 return it != cloud_managers_.end() ? it->second : nullptr; |
| 106 } | 126 } |
| 107 | 127 |
| 108 std::unique_ptr<UserCloudPolicyManagerChromeOS> | 128 UserActiveDirectoryPolicyManager* |
| 109 UserCloudPolicyManagerFactoryChromeOS::CreateManagerForProfile( | 129 UserPolicyManagerFactoryChromeOS::GetActiveDirectoryPolicyManager( |
| 130 Profile* profile) { |
| 131 // Get the manager for the original profile, since the PolicyService is |
| 132 // also shared between the incognito Profile and the original Profile. |
| 133 const auto it = |
| 134 active_directory_managers_.find(profile->GetOriginalProfile()); |
| 135 return it != active_directory_managers_.end() ? it->second : nullptr; |
| 136 } |
| 137 |
| 138 std::unique_ptr<ConfigurationPolicyProvider> |
| 139 UserPolicyManagerFactoryChromeOS::CreateManagerForProfile( |
| 110 Profile* profile, | 140 Profile* profile, |
| 111 bool force_immediate_load, | 141 bool force_immediate_load, |
| 112 scoped_refptr<base::SequencedTaskRunner> background_task_runner) { | 142 scoped_refptr<base::SequencedTaskRunner> background_task_runner) { |
| 143 DCHECK(cloud_managers_.find(profile) == cloud_managers_.end()); |
| 144 DCHECK(active_directory_managers_.find(profile) == |
| 145 active_directory_managers_.end()); |
| 146 |
| 113 const base::CommandLine* command_line = | 147 const base::CommandLine* command_line = |
| 114 base::CommandLine::ForCurrentProcess(); | 148 base::CommandLine::ForCurrentProcess(); |
| 115 // Don't initialize cloud policy for the signin profile. | 149 // Don't initialize cloud policy for the signin profile. |
| 116 if (chromeos::ProfileHelper::IsSigninProfile(profile)) | 150 if (chromeos::ProfileHelper::IsSigninProfile(profile)) |
| 117 return std::unique_ptr<UserCloudPolicyManagerChromeOS>(); | 151 return {}; |
| 118 | 152 |
| 119 // |user| should never be NULL except for the signin profile. This object is | 153 // |user| should never be nullptr except for the signin profile. This object |
| 120 // created as part of the Profile creation, which happens right after | 154 // is created as part of the Profile creation, which happens right after |
| 121 // sign-in. The just-signed-in User is the active user during that time. | 155 // sign-in. The just-signed-in User is the active user during that time. |
| 122 const user_manager::User* user = | 156 const user_manager::User* user = |
| 123 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); | 157 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); |
| 124 CHECK(user); | 158 CHECK(user); |
| 125 | 159 |
| 126 // User policy exists for enterprise accounts only: | 160 // User policy exists for enterprise accounts only: |
| 127 // - For regular enterprise users (those who have a GAIA account), a | 161 // - For regular cloud-managed users (those who have a GAIA account), a |
| 128 // |UserCloudPolicyManagerChromeOS| is created here. | 162 // |UserCloudPolicyManagerChromeOS| is created here. |
| 163 // - For Active Directory managed users, a |UserActiveDirectoryPolicyManager| |
| 164 // is created. |
| 129 // - For device-local accounts, policy is provided by | 165 // - For device-local accounts, policy is provided by |
| 130 // |DeviceLocalAccountPolicyService|. | 166 // |DeviceLocalAccountPolicyService|. |
| 131 // All other user types do not have user policy. | 167 // All other user types do not have user policy. |
| 132 const AccountId account_id = user->GetAccountId(); | 168 const AccountId& account_id = user->GetAccountId(); |
| 133 if (!user->HasGaiaAccount() || user->IsSupervised() || | 169 if (user->IsSupervised() || |
| 134 BrowserPolicyConnector::IsNonEnterpriseUser(account_id.GetUserEmail())) { | 170 BrowserPolicyConnector::IsNonEnterpriseUser(account_id.GetUserEmail())) { |
| 135 return std::unique_ptr<UserCloudPolicyManagerChromeOS>(); | 171 return {}; |
| 136 } | 172 } |
| 137 | 173 |
| 138 policy::BrowserPolicyConnectorChromeOS* connector = | 174 policy::BrowserPolicyConnectorChromeOS* connector = |
| 139 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 175 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 176 bool is_active_directory = false; |
| 177 switch (account_id.GetAccountType()) { |
| 178 case AccountType::UNKNOWN: |
| 179 // TODO(tnagel): Return nullptr for unknown accounts once AccountId |
| 180 // migration is finished. |
| 181 if (!user->HasGaiaAccount()) { |
| 182 return {}; |
| 183 } |
| 184 is_active_directory = false; |
| 185 break; |
| 186 case AccountType::GOOGLE: |
| 187 if (!user->HasGaiaAccount()) { |
| 188 return {}; |
| 189 } |
| 190 is_active_directory = false; |
| 191 break; |
| 192 case AccountType::ACTIVE_DIRECTORY: |
| 193 // Ensure install attributes are locked into Active Directory mode before |
| 194 // allowing Active Directory policy which is not signed. |
| 195 if (!connector->GetInstallAttributes()->IsActiveDirectoryManaged()) { |
| 196 return {}; |
| 197 } |
| 198 is_active_directory = true; |
| 199 break; |
| 200 } |
| 201 |
| 140 const bool is_browser_restart = | 202 const bool is_browser_restart = |
| 141 command_line->HasSwitch(chromeos::switches::kLoginUser); | 203 command_line->HasSwitch(chromeos::switches::kLoginUser); |
| 142 const user_manager::UserManager* const user_manager = | 204 const user_manager::UserManager* const user_manager = |
| 143 user_manager::UserManager::Get(); | 205 user_manager::UserManager::Get(); |
| 144 | 206 |
| 145 // We want to block for policy in a few situations: if the user is new, or | 207 // We want to block for policy in a few situations: if the user is new, or if |
| 146 // if we are forcing an online signin. An online signin will be forced if | 208 // we are forcing an online signin. An online signin will be forced if there |
| 147 // there has been a credential error, or if the initial session creation | 209 // has been a credential error, or if the initial session creation was not |
| 148 // was not completed (the oauth_token_status is not set to valid by | 210 // completed (the oauth_token_status is not set to valid by OAuth2LoginManager |
| 149 // OAuth2LoginManager until profile creation/session restore is complete). | 211 // until profile creation/session restore is complete). |
| 212 // TODO(tnagel): Don't limit blocking to cloud managed users. |
| 150 const bool block_forever_for_policy = | 213 const bool block_forever_for_policy = |
| 151 !user_manager->IsLoggedInAsStub() && | 214 !is_active_directory && !user_manager->IsLoggedInAsStub() && |
| 152 (user_manager->IsCurrentUserNew() || | 215 (user_manager->IsCurrentUserNew() || |
| 153 user_manager->GetActiveUser()->force_online_signin() || | 216 user_manager->GetActiveUser()->force_online_signin() || |
| 154 user_manager->GetActiveUser()->oauth_token_status() != | 217 user_manager->GetActiveUser()->oauth_token_status() != |
| 155 user_manager::User::OAUTH2_TOKEN_STATUS_VALID); | 218 user_manager::User::OAUTH2_TOKEN_STATUS_VALID); |
| 156 | 219 |
| 157 const bool wait_for_policy_fetch = | 220 const bool wait_for_policy_fetch = |
| 158 block_forever_for_policy || !is_browser_restart; | 221 block_forever_for_policy || !is_browser_restart; |
| 159 | 222 |
| 160 base::TimeDelta initial_policy_fetch_timeout; | 223 base::TimeDelta initial_policy_fetch_timeout; |
| 161 if (block_forever_for_policy) { | 224 if (block_forever_for_policy) { |
| 162 initial_policy_fetch_timeout = base::TimeDelta::Max(); | 225 initial_policy_fetch_timeout = base::TimeDelta::Max(); |
| 163 } else if (wait_for_policy_fetch) { | 226 } else if (wait_for_policy_fetch) { |
| 164 initial_policy_fetch_timeout = | 227 initial_policy_fetch_timeout = |
| 165 base::TimeDelta::FromSeconds(kInitialPolicyFetchTimeoutSeconds); | 228 base::TimeDelta::FromSeconds(kInitialPolicyFetchTimeoutSeconds); |
| 166 } | 229 } |
| 167 | 230 |
| 168 DeviceManagementService* device_management_service = | 231 DeviceManagementService* device_management_service = |
| 169 connector->device_management_service(); | 232 connector->device_management_service(); |
| 170 if (wait_for_policy_fetch) | 233 if (wait_for_policy_fetch) |
| 171 device_management_service->ScheduleInitialization(0); | 234 device_management_service->ScheduleInitialization(0); |
| 172 | 235 |
| 173 base::FilePath profile_dir = profile->GetPath(); | 236 base::FilePath profile_dir = profile->GetPath(); |
| 174 const base::FilePath component_policy_cache_dir = | 237 const base::FilePath component_policy_cache_dir = |
| 175 profile_dir.Append(kPolicy).Append(kComponentsDir); | 238 profile_dir.Append(kPolicy).Append(kComponentsDir); |
| 176 const base::FilePath external_data_dir = | 239 const base::FilePath external_data_dir = |
| 177 profile_dir.Append(kPolicy).Append(kPolicyExternalDataDir); | 240 profile_dir.Append(kPolicy).Append(kPolicyExternalDataDir); |
| 178 base::FilePath policy_key_dir; | 241 base::FilePath policy_key_dir; |
| 179 CHECK(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &policy_key_dir)); | 242 CHECK(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &policy_key_dir)); |
| 180 | 243 |
| 181 std::unique_ptr<UserCloudPolicyStoreChromeOS> store( | 244 std::unique_ptr<UserCloudPolicyStoreChromeOS> store = |
| 182 new UserCloudPolicyStoreChromeOS( | 245 base::MakeUnique<UserCloudPolicyStoreChromeOS>( |
| 183 chromeos::DBusThreadManager::Get()->GetCryptohomeClient(), | 246 chromeos::DBusThreadManager::Get()->GetCryptohomeClient(), |
| 184 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(), | 247 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(), |
| 185 background_task_runner, account_id, policy_key_dir)); | 248 background_task_runner, account_id, policy_key_dir, |
| 249 is_active_directory); |
| 186 | 250 |
| 187 scoped_refptr<base::SequencedTaskRunner> backend_task_runner = | 251 scoped_refptr<base::SequencedTaskRunner> backend_task_runner = |
| 188 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( | 252 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( |
| 189 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); | 253 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); |
| 190 scoped_refptr<base::SequencedTaskRunner> io_task_runner = | 254 scoped_refptr<base::SequencedTaskRunner> io_task_runner = |
| 191 content::BrowserThread::GetTaskRunnerForThread( | 255 content::BrowserThread::GetTaskRunnerForThread( |
| 192 content::BrowserThread::IO); | 256 content::BrowserThread::IO); |
| 193 std::unique_ptr<CloudExternalDataManager> external_data_manager( | 257 std::unique_ptr<CloudExternalDataManager> external_data_manager( |
| 194 new UserCloudExternalDataManager(base::Bind(&GetChromePolicyDetails), | 258 new UserCloudExternalDataManager(base::Bind(&GetChromePolicyDetails), |
| 195 backend_task_runner, io_task_runner, | 259 backend_task_runner, io_task_runner, |
| 196 external_data_dir, store.get())); | 260 external_data_dir, store.get())); |
| 197 if (force_immediate_load) | 261 if (force_immediate_load) |
| 198 store->LoadImmediately(); | 262 store->LoadImmediately(); |
| 199 | 263 |
| 200 scoped_refptr<base::SequencedTaskRunner> file_task_runner = | 264 scoped_refptr<base::SequencedTaskRunner> file_task_runner = |
| 201 content::BrowserThread::GetTaskRunnerForThread( | 265 content::BrowserThread::GetTaskRunnerForThread( |
| 202 content::BrowserThread::FILE); | 266 content::BrowserThread::FILE); |
| 203 | 267 |
| 204 std::unique_ptr<UserCloudPolicyManagerChromeOS> manager( | 268 if (is_active_directory) { |
| 205 new UserCloudPolicyManagerChromeOS( | 269 std::unique_ptr<UserActiveDirectoryPolicyManager> manager = |
| 206 std::move(store), std::move(external_data_manager), | 270 base::MakeUnique<UserActiveDirectoryPolicyManager>(account_id, |
| 207 component_policy_cache_dir, wait_for_policy_fetch, | 271 std::move(store)); |
| 208 initial_policy_fetch_timeout, base::ThreadTaskRunnerHandle::Get(), | 272 manager->Init( |
| 209 file_task_runner, io_task_runner)); | 273 SchemaRegistryServiceFactory::GetForContext(profile)->registry()); |
| 210 | 274 |
| 211 bool wildcard_match = false; | 275 active_directory_managers_[profile] = manager.get(); |
| 212 if (connector->IsEnterpriseManaged() && | 276 return std::move(manager); |
| 213 chromeos::CrosSettings::IsWhitelisted(account_id.GetUserEmail(), | 277 } else { |
| 214 &wildcard_match) && | 278 std::unique_ptr<UserCloudPolicyManagerChromeOS> manager = |
| 215 wildcard_match && | 279 base::MakeUnique<UserCloudPolicyManagerChromeOS>( |
| 216 !connector->IsNonEnterpriseUser(account_id.GetUserEmail())) { | 280 std::move(store), std::move(external_data_manager), |
| 217 manager->EnableWildcardLoginCheck(account_id.GetUserEmail()); | 281 component_policy_cache_dir, wait_for_policy_fetch, |
| 282 initial_policy_fetch_timeout, base::ThreadTaskRunnerHandle::Get(), |
| 283 file_task_runner, io_task_runner); |
| 284 |
| 285 // TODO(tnagel): Enable whitelist for Active Directory. |
| 286 bool wildcard_match = false; |
| 287 if (connector->IsEnterpriseManaged() && |
| 288 chromeos::CrosSettings::IsWhitelisted(account_id.GetUserEmail(), |
| 289 &wildcard_match) && |
| 290 wildcard_match && |
| 291 !connector->IsNonEnterpriseUser(account_id.GetUserEmail())) { |
| 292 manager->EnableWildcardLoginCheck(account_id.GetUserEmail()); |
| 293 } |
| 294 |
| 295 manager->Init( |
| 296 SchemaRegistryServiceFactory::GetForContext(profile)->registry()); |
| 297 manager->Connect(g_browser_process->local_state(), |
| 298 device_management_service, |
| 299 g_browser_process->system_request_context()); |
| 300 |
| 301 cloud_managers_[profile] = manager.get(); |
| 302 return std::move(manager); |
| 218 } | 303 } |
| 219 | |
| 220 manager->Init( | |
| 221 SchemaRegistryServiceFactory::GetForContext(profile)->registry()); | |
| 222 manager->Connect(g_browser_process->local_state(), device_management_service, | |
| 223 g_browser_process->system_request_context()); | |
| 224 | |
| 225 DCHECK(managers_.find(profile) == managers_.end()); | |
| 226 managers_[profile] = manager.get(); | |
| 227 return manager; | |
| 228 } | 304 } |
| 229 | 305 |
| 230 void UserCloudPolicyManagerFactoryChromeOS::BrowserContextShutdown( | 306 void UserPolicyManagerFactoryChromeOS::BrowserContextShutdown( |
| 231 content::BrowserContext* context) { | 307 content::BrowserContext* context) { |
| 232 Profile* profile = static_cast<Profile*>(context); | 308 Profile* profile = static_cast<Profile*>(context); |
| 233 if (profile->IsOffTheRecord()) | 309 if (profile->IsOffTheRecord()) |
| 234 return; | 310 return; |
| 235 UserCloudPolicyManagerChromeOS* manager = GetManagerForProfile(profile); | 311 UserCloudPolicyManagerChromeOS* cloud_manager = |
| 236 if (manager) | 312 GetCloudPolicyManager(profile); |
| 237 manager->Shutdown(); | 313 if (cloud_manager) |
| 314 cloud_manager->Shutdown(); |
| 315 UserActiveDirectoryPolicyManager* active_directory_manager = |
| 316 GetActiveDirectoryPolicyManager(profile); |
| 317 if (active_directory_manager) |
| 318 active_directory_manager->Shutdown(); |
| 238 } | 319 } |
| 239 | 320 |
| 240 void UserCloudPolicyManagerFactoryChromeOS::BrowserContextDestroyed( | 321 void UserPolicyManagerFactoryChromeOS::BrowserContextDestroyed( |
| 241 content::BrowserContext* context) { | 322 content::BrowserContext* context) { |
| 242 Profile* profile = static_cast<Profile*>(context); | 323 Profile* profile = static_cast<Profile*>(context); |
| 243 managers_.erase(profile); | 324 cloud_managers_.erase(profile); |
| 325 active_directory_managers_.erase(profile); |
| 244 BrowserContextKeyedBaseFactory::BrowserContextDestroyed(context); | 326 BrowserContextKeyedBaseFactory::BrowserContextDestroyed(context); |
| 245 } | 327 } |
| 246 | 328 |
| 247 void UserCloudPolicyManagerFactoryChromeOS::SetEmptyTestingFactory( | 329 void UserPolicyManagerFactoryChromeOS::SetEmptyTestingFactory( |
| 248 content::BrowserContext* context) {} | 330 content::BrowserContext* context) {} |
| 249 | 331 |
| 250 bool UserCloudPolicyManagerFactoryChromeOS::HasTestingFactory( | 332 bool UserPolicyManagerFactoryChromeOS::HasTestingFactory( |
| 251 content::BrowserContext* context) { | 333 content::BrowserContext* context) { |
| 252 return false; | 334 return false; |
| 253 } | 335 } |
| 254 | 336 |
| 255 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow( | 337 void UserPolicyManagerFactoryChromeOS::CreateServiceNow( |
| 256 content::BrowserContext* context) {} | 338 content::BrowserContext* context) {} |
| 257 | 339 |
| 258 } // namespace policy | 340 } // namespace policy |
| OLD | NEW |