Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.cc

Issue 1693383003: ChromeOS cryptohome should be able to use gaia id as user identifier. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed unit tests. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 user_manager::UserManager* const user_manager = 151 const user_manager::UserManager* const user_manager =
153 user_manager::UserManager::Get(); 152 user_manager::UserManager::Get();
154 153
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 profile_dir.Append(kPolicy).Append(kComponentsDir); 187 profile_dir.Append(kPolicy).Append(kComponentsDir);
189 const base::FilePath external_data_dir = 188 const base::FilePath external_data_dir =
190 profile_dir.Append(kPolicy).Append(kPolicyExternalDataDir); 189 profile_dir.Append(kPolicy).Append(kPolicyExternalDataDir);
191 base::FilePath policy_key_dir; 190 base::FilePath policy_key_dir;
192 CHECK(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &policy_key_dir)); 191 CHECK(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &policy_key_dir));
193 192
194 scoped_ptr<UserCloudPolicyStoreChromeOS> store( 193 scoped_ptr<UserCloudPolicyStoreChromeOS> store(
195 new UserCloudPolicyStoreChromeOS( 194 new UserCloudPolicyStoreChromeOS(
196 chromeos::DBusThreadManager::Get()->GetCryptohomeClient(), 195 chromeos::DBusThreadManager::Get()->GetCryptohomeClient(),
197 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(), 196 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(),
198 background_task_runner, 197 background_task_runner, account_id, policy_key_dir, token_cache_file,
199 username, policy_key_dir, token_cache_file, policy_cache_file)); 198 policy_cache_file));
200 199
201 scoped_refptr<base::SequencedTaskRunner> backend_task_runner = 200 scoped_refptr<base::SequencedTaskRunner> backend_task_runner =
202 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( 201 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner(
203 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); 202 content::BrowserThread::GetBlockingPool()->GetSequenceToken());
204 scoped_refptr<base::SequencedTaskRunner> io_task_runner = 203 scoped_refptr<base::SequencedTaskRunner> io_task_runner =
205 content::BrowserThread::GetMessageLoopProxyForThread( 204 content::BrowserThread::GetMessageLoopProxyForThread(
206 content::BrowserThread::IO); 205 content::BrowserThread::IO);
207 scoped_ptr<CloudExternalDataManager> external_data_manager( 206 scoped_ptr<CloudExternalDataManager> external_data_manager(
208 new UserCloudExternalDataManager(base::Bind(&GetChromePolicyDetails), 207 new UserCloudExternalDataManager(base::Bind(&GetChromePolicyDetails),
209 backend_task_runner, 208 backend_task_runner,
210 io_task_runner, 209 io_task_runner,
211 external_data_dir, 210 external_data_dir,
212 store.get())); 211 store.get()));
213 if (force_immediate_load) 212 if (force_immediate_load)
214 store->LoadImmediately(); 213 store->LoadImmediately();
215 214
216 scoped_refptr<base::SequencedTaskRunner> file_task_runner = 215 scoped_refptr<base::SequencedTaskRunner> file_task_runner =
217 content::BrowserThread::GetMessageLoopProxyForThread( 216 content::BrowserThread::GetMessageLoopProxyForThread(
218 content::BrowserThread::FILE); 217 content::BrowserThread::FILE);
219 218
220 scoped_ptr<UserCloudPolicyManagerChromeOS> manager( 219 scoped_ptr<UserCloudPolicyManagerChromeOS> manager(
221 new UserCloudPolicyManagerChromeOS( 220 new UserCloudPolicyManagerChromeOS(
222 std::move(store), std::move(external_data_manager), 221 std::move(store), std::move(external_data_manager),
223 component_policy_cache_dir, wait_for_policy_fetch, 222 component_policy_cache_dir, wait_for_policy_fetch,
224 initial_policy_fetch_timeout, base::ThreadTaskRunnerHandle::Get(), 223 initial_policy_fetch_timeout, base::ThreadTaskRunnerHandle::Get(),
225 file_task_runner, io_task_runner)); 224 file_task_runner, io_task_runner));
226 225
227 bool wildcard_match = false; 226 bool wildcard_match = false;
228 if (connector->IsEnterpriseManaged() && 227 if (connector->IsEnterpriseManaged() &&
229 chromeos::CrosSettings::IsWhitelisted(username, &wildcard_match) && 228 chromeos::CrosSettings::IsWhitelisted(account_id.GetUserEmail(),
230 wildcard_match && !connector->IsNonEnterpriseUser(username)) { 229 &wildcard_match) &&
231 manager->EnableWildcardLoginCheck(username); 230 wildcard_match &&
231 !connector->IsNonEnterpriseUser(account_id.GetUserEmail())) {
232 manager->EnableWildcardLoginCheck(account_id.GetUserEmail());
232 } 233 }
233 234
234 manager->Init( 235 manager->Init(
235 SchemaRegistryServiceFactory::GetForContext(profile)->registry()); 236 SchemaRegistryServiceFactory::GetForContext(profile)->registry());
236 manager->Connect(g_browser_process->local_state(), device_management_service, 237 manager->Connect(g_browser_process->local_state(), device_management_service,
237 g_browser_process->system_request_context()); 238 g_browser_process->system_request_context());
238 239
239 DCHECK(managers_.find(profile) == managers_.end()); 240 DCHECK(managers_.find(profile) == managers_.end());
240 managers_[profile] = manager.get(); 241 managers_[profile] = manager.get();
241 return manager; 242 return manager;
(...skipping 21 matching lines...) Expand all
263 264
264 bool UserCloudPolicyManagerFactoryChromeOS::HasTestingFactory( 265 bool UserCloudPolicyManagerFactoryChromeOS::HasTestingFactory(
265 content::BrowserContext* context) { 266 content::BrowserContext* context) {
266 return false; 267 return false;
267 } 268 }
268 269
269 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow( 270 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow(
270 content::BrowserContext* context) {} 271 content::BrowserContext* context) {}
271 272
272 } // namespace policy 273 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698