| 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_cloud_policy_manager_factory_chrom
eos.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" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 const user_manager::User* user = | 131 const user_manager::User* user = |
| 132 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); | 132 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); |
| 133 CHECK(user); | 133 CHECK(user); |
| 134 | 134 |
| 135 // User policy exists for enterprise accounts only: | 135 // User policy exists for enterprise accounts only: |
| 136 // - For regular enterprise users (those who have a GAIA account), a | 136 // - For regular enterprise users (those who have a GAIA account), a |
| 137 // |UserCloudPolicyManagerChromeOS| is created here. | 137 // |UserCloudPolicyManagerChromeOS| is created here. |
| 138 // - For device-local accounts, policy is provided by | 138 // - For device-local accounts, policy is provided by |
| 139 // |DeviceLocalAccountPolicyService|. | 139 // |DeviceLocalAccountPolicyService|. |
| 140 // All other user types do not have user policy. | 140 // All other user types do not have user policy. |
| 141 const std::string& username = user->email(); | 141 const AccountId account_id = user->GetAccountId(); |
| 142 if (!user->HasGaiaAccount() || | 142 if (!user->HasGaiaAccount() || user->IsSupervised() || |
| 143 user->IsSupervised() || | 143 BrowserPolicyConnector::IsNonEnterpriseUser(account_id.GetUserEmail())) { |
| 144 BrowserPolicyConnector::IsNonEnterpriseUser(username)) { | |
| 145 return scoped_ptr<UserCloudPolicyManagerChromeOS>(); | 144 return scoped_ptr<UserCloudPolicyManagerChromeOS>(); |
| 146 } | 145 } |
| 147 | 146 |
| 148 policy::BrowserPolicyConnectorChromeOS* connector = | 147 policy::BrowserPolicyConnectorChromeOS* connector = |
| 149 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 148 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 150 const bool is_browser_restart = | 149 const bool is_browser_restart = |
| 151 command_line->HasSwitch(chromeos::switches::kLoginUser); | 150 command_line->HasSwitch(chromeos::switches::kLoginUser); |
| 152 const bool wait_for_initial_policy = !is_browser_restart; | 151 const bool wait_for_initial_policy = !is_browser_restart; |
| 153 | 152 |
| 154 const base::TimeDelta initial_policy_fetch_timeout = | 153 const base::TimeDelta initial_policy_fetch_timeout = |
| (...skipping 14 matching lines...) Expand all Loading... |
| 169 profile_dir.Append(kPolicy).Append(kComponentsDir); | 168 profile_dir.Append(kPolicy).Append(kComponentsDir); |
| 170 const base::FilePath external_data_dir = | 169 const base::FilePath external_data_dir = |
| 171 profile_dir.Append(kPolicy).Append(kPolicyExternalDataDir); | 170 profile_dir.Append(kPolicy).Append(kPolicyExternalDataDir); |
| 172 base::FilePath policy_key_dir; | 171 base::FilePath policy_key_dir; |
| 173 CHECK(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &policy_key_dir)); | 172 CHECK(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &policy_key_dir)); |
| 174 | 173 |
| 175 scoped_ptr<UserCloudPolicyStoreChromeOS> store( | 174 scoped_ptr<UserCloudPolicyStoreChromeOS> store( |
| 176 new UserCloudPolicyStoreChromeOS( | 175 new UserCloudPolicyStoreChromeOS( |
| 177 chromeos::DBusThreadManager::Get()->GetCryptohomeClient(), | 176 chromeos::DBusThreadManager::Get()->GetCryptohomeClient(), |
| 178 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(), | 177 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(), |
| 179 background_task_runner, | 178 background_task_runner, account_id, policy_key_dir, token_cache_file, |
| 180 username, policy_key_dir, token_cache_file, policy_cache_file)); | 179 policy_cache_file)); |
| 181 | 180 |
| 182 scoped_refptr<base::SequencedTaskRunner> backend_task_runner = | 181 scoped_refptr<base::SequencedTaskRunner> backend_task_runner = |
| 183 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( | 182 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( |
| 184 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); | 183 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); |
| 185 scoped_refptr<base::SequencedTaskRunner> io_task_runner = | 184 scoped_refptr<base::SequencedTaskRunner> io_task_runner = |
| 186 content::BrowserThread::GetMessageLoopProxyForThread( | 185 content::BrowserThread::GetMessageLoopProxyForThread( |
| 187 content::BrowserThread::IO); | 186 content::BrowserThread::IO); |
| 188 scoped_ptr<CloudExternalDataManager> external_data_manager( | 187 scoped_ptr<CloudExternalDataManager> external_data_manager( |
| 189 new UserCloudExternalDataManager(base::Bind(&GetChromePolicyDetails), | 188 new UserCloudExternalDataManager(base::Bind(&GetChromePolicyDetails), |
| 190 backend_task_runner, | 189 backend_task_runner, |
| 191 io_task_runner, | 190 io_task_runner, |
| 192 external_data_dir, | 191 external_data_dir, |
| 193 store.get())); | 192 store.get())); |
| 194 if (force_immediate_load) | 193 if (force_immediate_load) |
| 195 store->LoadImmediately(); | 194 store->LoadImmediately(); |
| 196 | 195 |
| 197 scoped_refptr<base::SequencedTaskRunner> file_task_runner = | 196 scoped_refptr<base::SequencedTaskRunner> file_task_runner = |
| 198 content::BrowserThread::GetMessageLoopProxyForThread( | 197 content::BrowserThread::GetMessageLoopProxyForThread( |
| 199 content::BrowserThread::FILE); | 198 content::BrowserThread::FILE); |
| 200 | 199 |
| 201 scoped_ptr<UserCloudPolicyManagerChromeOS> manager( | 200 scoped_ptr<UserCloudPolicyManagerChromeOS> manager( |
| 202 new UserCloudPolicyManagerChromeOS( | 201 new UserCloudPolicyManagerChromeOS( |
| 203 std::move(store), std::move(external_data_manager), | 202 std::move(store), std::move(external_data_manager), |
| 204 component_policy_cache_dir, wait_for_initial_policy, | 203 component_policy_cache_dir, wait_for_initial_policy, |
| 205 initial_policy_fetch_timeout, base::ThreadTaskRunnerHandle::Get(), | 204 initial_policy_fetch_timeout, base::ThreadTaskRunnerHandle::Get(), |
| 206 file_task_runner, io_task_runner)); | 205 file_task_runner, io_task_runner)); |
| 207 | 206 |
| 208 bool wildcard_match = false; | 207 bool wildcard_match = false; |
| 209 if (connector->IsEnterpriseManaged() && | 208 if (connector->IsEnterpriseManaged() && |
| 210 chromeos::CrosSettings::IsWhitelisted(username, &wildcard_match) && | 209 chromeos::CrosSettings::IsWhitelisted(account_id.GetUserEmail(), |
| 211 wildcard_match && !connector->IsNonEnterpriseUser(username)) { | 210 &wildcard_match) && |
| 212 manager->EnableWildcardLoginCheck(username); | 211 wildcard_match && |
| 212 !connector->IsNonEnterpriseUser(account_id.GetUserEmail())) { |
| 213 manager->EnableWildcardLoginCheck(account_id.GetUserEmail()); |
| 213 } | 214 } |
| 214 | 215 |
| 215 manager->Init( | 216 manager->Init( |
| 216 SchemaRegistryServiceFactory::GetForContext(profile)->registry()); | 217 SchemaRegistryServiceFactory::GetForContext(profile)->registry()); |
| 217 manager->Connect(g_browser_process->local_state(), device_management_service, | 218 manager->Connect(g_browser_process->local_state(), device_management_service, |
| 218 g_browser_process->system_request_context()); | 219 g_browser_process->system_request_context()); |
| 219 | 220 |
| 220 DCHECK(managers_.find(profile) == managers_.end()); | 221 DCHECK(managers_.find(profile) == managers_.end()); |
| 221 managers_[profile] = manager.get(); | 222 managers_[profile] = manager.get(); |
| 222 return manager; | 223 return manager; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 244 | 245 |
| 245 bool UserCloudPolicyManagerFactoryChromeOS::HasTestingFactory( | 246 bool UserCloudPolicyManagerFactoryChromeOS::HasTestingFactory( |
| 246 content::BrowserContext* context) { | 247 content::BrowserContext* context) { |
| 247 return false; | 248 return false; |
| 248 } | 249 } |
| 249 | 250 |
| 250 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow( | 251 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow( |
| 251 content::BrowserContext* context) {} | 252 content::BrowserContext* context) {} |
| 252 | 253 |
| 253 } // namespace policy | 254 } // namespace policy |
| OLD | NEW |