| 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 274 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 275 | 275 |
| 276 BrowserThread::PostTask( | 276 BrowserThread::PostTask( |
| 277 BrowserThread::UI, | 277 BrowserThread::UI, |
| 278 FROM_HERE, | 278 FROM_HERE, |
| 279 base::Bind(&GetTPMInfoForUserOnUIThread, username, username_hash)); | 279 base::Bind(&GetTPMInfoForUserOnUIThread, username, username_hash)); |
| 280 } | 280 } |
| 281 | 281 |
| 282 void StartNSSInitOnIOThread(const std::string& username, | 282 void StartNSSInitOnIOThread(const std::string& username, |
| 283 const std::string& username_hash, | 283 const std::string& username_hash, |
| 284 const base::FilePath& path, | 284 const base::FilePath& path) { |
| 285 bool is_primary_user) { | |
| 286 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 285 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 287 DVLOG(1) << "Starting NSS init for " << username | 286 DVLOG(1) << "Starting NSS init for " << username |
| 288 << " hash:" << username_hash | 287 << " hash:" << username_hash; |
| 289 << " is_primary_user:" << is_primary_user; | |
| 290 | 288 |
| 291 if (!crypto::InitializeNSSForChromeOSUser( | 289 if (!crypto::InitializeNSSForChromeOSUser(username, username_hash, path)) { |
| 292 username, username_hash, is_primary_user, path)) { | |
| 293 // If the user already exists in nss_util's map, it is already initialized | 290 // If the user already exists in nss_util's map, it is already initialized |
| 294 // or in the process of being initialized. In either case, there's no need | 291 // or in the process of being initialized. In either case, there's no need |
| 295 // to do anything. | 292 // to do anything. |
| 296 return; | 293 return; |
| 297 } | 294 } |
| 298 | 295 |
| 299 if (crypto::IsTPMTokenEnabledForNSS()) { | 296 if (crypto::IsTPMTokenEnabledForNSS()) { |
| 300 if (crypto::IsTPMTokenReady(base::Bind( | 297 if (crypto::IsTPMTokenReady(base::Bind( |
| 301 &StartTPMSlotInitializationOnIOThread, username, username_hash))) { | 298 &StartTPMSlotInitializationOnIOThread, username, username_hash))) { |
| 302 StartTPMSlotInitializationOnIOThread(username, username_hash); | 299 StartTPMSlotInitializationOnIOThread(username, username_hash); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 #if defined(ENABLE_MANAGED_USERS) | 342 #if defined(ENABLE_MANAGED_USERS) |
| 346 ManagedUserService* managed_user_service = | 343 ManagedUserService* managed_user_service = |
| 347 ManagedUserServiceFactory::GetForProfile(profile); | 344 ManagedUserServiceFactory::GetForProfile(profile); |
| 348 params->managed_mode_url_filter = | 345 params->managed_mode_url_filter = |
| 349 managed_user_service->GetURLFilterForIOThread(); | 346 managed_user_service->GetURLFilterForIOThread(); |
| 350 #endif | 347 #endif |
| 351 #if defined(OS_CHROMEOS) | 348 #if defined(OS_CHROMEOS) |
| 352 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); | 349 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); |
| 353 if (user_manager) { | 350 if (user_manager) { |
| 354 chromeos::User* user = user_manager->GetUserByProfile(profile); | 351 chromeos::User* user = user_manager->GetUserByProfile(profile); |
| 355 if (user) { | 352 // No need to initialize NSS for users with empty username hash: |
| 353 // Getters for a user's NSS slots always return NULL slot if the user's |
| 354 // username hash is empty, even when the NSS is not initialized for the |
| 355 // user. |
| 356 if (user && !user->username_hash().empty()) { |
| 356 params->username_hash = user->username_hash(); | 357 params->username_hash = user->username_hash(); |
| 357 bool is_primary_user = (user_manager->GetPrimaryUser() == user); | |
| 358 BrowserThread::PostTask(BrowserThread::IO, | 358 BrowserThread::PostTask(BrowserThread::IO, |
| 359 FROM_HERE, | 359 FROM_HERE, |
| 360 base::Bind(&StartNSSInitOnIOThread, | 360 base::Bind(&StartNSSInitOnIOThread, |
| 361 user->email(), | 361 user->email(), |
| 362 user->username_hash(), | 362 user->username_hash(), |
| 363 profile->GetPath(), | 363 profile->GetPath())); |
| 364 is_primary_user)); | |
| 365 } | 364 } |
| 366 } | 365 } |
| 367 if (params->username_hash.empty()) | 366 if (params->username_hash.empty()) |
| 368 LOG(WARNING) << "no username_hash"; | 367 LOG(WARNING) << "No username_hash; skipped NSS initialization."; |
| 369 #endif | 368 #endif |
| 370 | 369 |
| 371 params->profile = profile; | 370 params->profile = profile; |
| 372 params->prerender_tracker = g_browser_process->prerender_tracker(); | 371 params->prerender_tracker = g_browser_process->prerender_tracker(); |
| 373 profile_params_.reset(params.release()); | 372 profile_params_.reset(params.release()); |
| 374 | 373 |
| 375 ChromeNetworkDelegate::InitializePrefsOnUIThread( | 374 ChromeNetworkDelegate::InitializePrefsOnUIThread( |
| 376 &enable_referrers_, | 375 &enable_referrers_, |
| 377 &enable_do_not_track_, | 376 &enable_do_not_track_, |
| 378 &force_safesearch_, | 377 &force_safesearch_, |
| (...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 void ProfileIOData::SetCookieSettingsForTesting( | 1187 void ProfileIOData::SetCookieSettingsForTesting( |
| 1189 CookieSettings* cookie_settings) { | 1188 CookieSettings* cookie_settings) { |
| 1190 DCHECK(!cookie_settings_.get()); | 1189 DCHECK(!cookie_settings_.get()); |
| 1191 cookie_settings_ = cookie_settings; | 1190 cookie_settings_ = cookie_settings; |
| 1192 } | 1191 } |
| 1193 | 1192 |
| 1194 void ProfileIOData::set_signin_names_for_testing( | 1193 void ProfileIOData::set_signin_names_for_testing( |
| 1195 SigninNamesOnIOThread* signin_names) { | 1194 SigninNamesOnIOThread* signin_names) { |
| 1196 signin_names_.reset(signin_names); | 1195 signin_names_.reset(signin_names); |
| 1197 } | 1196 } |
| OLD | NEW |