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/profiles/profile_io_data.h" | 5 #include "chrome/browser/profiles/profile_io_data.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 281 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
282 | 282 |
283 BrowserThread::PostTask( | 283 BrowserThread::PostTask( |
284 BrowserThread::UI, | 284 BrowserThread::UI, |
285 FROM_HERE, | 285 FROM_HERE, |
286 base::Bind(&GetTPMInfoForUserOnUIThread, username, username_hash)); | 286 base::Bind(&GetTPMInfoForUserOnUIThread, username, username_hash)); |
287 } | 287 } |
288 | 288 |
289 void StartNSSInitOnIOThread(const std::string& username, | 289 void StartNSSInitOnIOThread(const std::string& username, |
290 const std::string& username_hash, | 290 const std::string& username_hash, |
291 const base::FilePath& path, | 291 const base::FilePath& path) { |
292 bool is_primary_user) { | |
293 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 292 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
294 DVLOG(1) << "Starting NSS init for " << username | 293 DVLOG(1) << "Starting NSS init for " << username |
295 << " hash:" << username_hash | 294 << " hash:" << username_hash; |
296 << " is_primary_user:" << is_primary_user; | |
297 | |
298 if (!crypto::InitializeNSSForChromeOSUser( | 295 if (!crypto::InitializeNSSForChromeOSUser( |
299 username, username_hash, is_primary_user, path)) { | 296 username, username_hash, path, false /* not provisional*/)) { |
300 // If the user already exists in nss_util's map, it is already initialized | 297 // If the user already exists in nss_util's map, it is already initialized |
301 // or in the process of being initialized. In either case, there's no need | 298 // or in the process of being initialized. In either case, there's no need |
302 // to do anything. | 299 // to do anything. |
303 return; | 300 return; |
304 } | 301 } |
305 | 302 |
306 if (crypto::IsTPMTokenEnabledForNSS()) { | 303 if (crypto::IsTPMTokenEnabledForNSS()) { |
307 if (crypto::IsTPMTokenReady(base::Bind( | 304 if (crypto::IsTPMTokenReady(base::Bind( |
308 &StartTPMSlotInitializationOnIOThread, username, username_hash))) { | 305 &StartTPMSlotInitializationOnIOThread, username, username_hash))) { |
309 StartTPMSlotInitializationOnIOThread(username, username_hash); | 306 StartTPMSlotInitializationOnIOThread(username, username_hash); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 SupervisedUserService* supervised_user_service = | 350 SupervisedUserService* supervised_user_service = |
354 SupervisedUserServiceFactory::GetForProfile(profile); | 351 SupervisedUserServiceFactory::GetForProfile(profile); |
355 params->supervised_user_url_filter = | 352 params->supervised_user_url_filter = |
356 supervised_user_service->GetURLFilterForIOThread(); | 353 supervised_user_service->GetURLFilterForIOThread(); |
357 #endif | 354 #endif |
358 #if defined(OS_CHROMEOS) | 355 #if defined(OS_CHROMEOS) |
359 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); | 356 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); |
360 if (user_manager) { | 357 if (user_manager) { |
361 chromeos::User* user = | 358 chromeos::User* user = |
362 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); | 359 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); |
363 if (user) { | 360 // No need to initialize NSS for users with empty username hash: |
| 361 // Getters for a user's NSS slots always return NULL slot if the user's |
| 362 // username hash is empty, even when the NSS is not initialized for the |
| 363 // user. |
| 364 if (user && !user->username_hash().empty()) { |
364 params->username_hash = user->username_hash(); | 365 params->username_hash = user->username_hash(); |
365 bool is_primary_user = (user_manager->GetPrimaryUser() == user); | |
366 BrowserThread::PostTask(BrowserThread::IO, | 366 BrowserThread::PostTask(BrowserThread::IO, |
367 FROM_HERE, | 367 FROM_HERE, |
368 base::Bind(&StartNSSInitOnIOThread, | 368 base::Bind(&StartNSSInitOnIOThread, |
369 user->email(), | 369 user->email(), |
370 user->username_hash(), | 370 user->username_hash(), |
371 profile->GetPath(), | 371 profile->GetPath())); |
372 is_primary_user)); | |
373 } | 372 } |
374 } | 373 } |
375 if (params->username_hash.empty()) | 374 if (params->username_hash.empty()) |
376 LOG(WARNING) << "no username_hash"; | 375 LOG(WARNING) << "No username_hash; skipped NSS initialization."; |
377 #endif | 376 #endif |
378 | 377 |
379 params->profile = profile; | 378 params->profile = profile; |
380 params->prerender_tracker = g_browser_process->prerender_tracker(); | 379 params->prerender_tracker = g_browser_process->prerender_tracker(); |
381 profile_params_.reset(params.release()); | 380 profile_params_.reset(params.release()); |
382 | 381 |
383 ChromeNetworkDelegate::InitializePrefsOnUIThread( | 382 ChromeNetworkDelegate::InitializePrefsOnUIThread( |
384 &enable_referrers_, | 383 &enable_referrers_, |
385 &enable_do_not_track_, | 384 &enable_do_not_track_, |
386 &force_safesearch_, | 385 &force_safesearch_, |
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 void ProfileIOData::SetCookieSettingsForTesting( | 1245 void ProfileIOData::SetCookieSettingsForTesting( |
1247 CookieSettings* cookie_settings) { | 1246 CookieSettings* cookie_settings) { |
1248 DCHECK(!cookie_settings_.get()); | 1247 DCHECK(!cookie_settings_.get()); |
1249 cookie_settings_ = cookie_settings; | 1248 cookie_settings_ = cookie_settings; |
1250 } | 1249 } |
1251 | 1250 |
1252 void ProfileIOData::set_signin_names_for_testing( | 1251 void ProfileIOData::set_signin_names_for_testing( |
1253 SigninNamesOnIOThread* signin_names) { | 1252 SigninNamesOnIOThread* signin_names) { |
1254 signin_names_.reset(signin_names); | 1253 signin_names_.reset(signin_names); |
1255 } | 1254 } |
OLD | NEW |