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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 #include "net/url_request/url_request_job_factory_impl.h" | 81 #include "net/url_request/url_request_job_factory_impl.h" |
82 | 82 |
83 #if defined(ENABLE_MANAGED_USERS) | 83 #if defined(ENABLE_MANAGED_USERS) |
84 #include "chrome/browser/managed_mode/managed_mode_url_filter.h" | 84 #include "chrome/browser/managed_mode/managed_mode_url_filter.h" |
85 #include "chrome/browser/managed_mode/managed_user_service.h" | 85 #include "chrome/browser/managed_mode/managed_user_service.h" |
86 #include "chrome/browser/managed_mode/managed_user_service_factory.h" | 86 #include "chrome/browser/managed_mode/managed_user_service_factory.h" |
87 #endif | 87 #endif |
88 | 88 |
89 #if defined(OS_CHROMEOS) | 89 #if defined(OS_CHROMEOS) |
90 #include "chrome/browser/chromeos/drive/drive_protocol_handler.h" | 90 #include "chrome/browser/chromeos/drive/drive_protocol_handler.h" |
91 #include "chrome/browser/chromeos/login/user.h" | |
92 #include "chrome/browser/chromeos/login/user_manager.h" | |
91 #include "chrome/browser/chromeos/policy/policy_cert_service.h" | 93 #include "chrome/browser/chromeos/policy/policy_cert_service.h" |
92 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" | 94 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" |
93 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" | 95 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" |
94 #include "chrome/browser/chromeos/settings/cros_settings.h" | 96 #include "chrome/browser/chromeos/settings/cros_settings.h" |
97 #include "chromeos/dbus/cryptohome_client.h" | |
98 #include "chromeos/dbus/dbus_thread_manager.h" | |
95 #include "chromeos/settings/cros_settings_names.h" | 99 #include "chromeos/settings/cros_settings_names.h" |
100 #include "crypto/nss_util.h" | |
101 #include "crypto/nss_util_internal.h" | |
96 #endif // defined(OS_CHROMEOS) | 102 #endif // defined(OS_CHROMEOS) |
97 | 103 |
98 using content::BrowserContext; | 104 using content::BrowserContext; |
99 using content::BrowserThread; | 105 using content::BrowserThread; |
100 using content::ResourceContext; | 106 using content::ResourceContext; |
101 | 107 |
102 namespace { | 108 namespace { |
103 | 109 |
104 // ---------------------------------------------------------------------------- | 110 // ---------------------------------------------------------------------------- |
105 // CookieMonster::Delegate implementation | 111 // CookieMonster::Delegate implementation |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 request, network_delegate, path, | 222 request, network_delegate, path, |
217 content::BrowserThread::GetBlockingPool()-> | 223 content::BrowserThread::GetBlockingPool()-> |
218 GetTaskRunnerWithShutdownBehavior( | 224 GetTaskRunnerWithShutdownBehavior( |
219 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | 225 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); |
220 | 226 |
221 return NULL; | 227 return NULL; |
222 } | 228 } |
223 }; | 229 }; |
224 #endif // defined(DEBUG_DEVTOOLS) | 230 #endif // defined(DEBUG_DEVTOOLS) |
225 | 231 |
232 #if defined(OS_CHROMEOS) | |
233 void DidGetTPMInfoForUserOnUIThread(const std::string& username_hash, | |
Ryan Sleevi
2013/11/27 00:24:11
This is somewhat hard to follow, because it's in r
mattm
2013/11/27 04:12:23
Ok, I added some comments and ascii art.
| |
234 chromeos::DBusMethodCallStatus call_status, | |
235 const std::string& label, | |
236 const std::string& user_pin, | |
Ryan Sleevi
2013/11/27 00:24:11
user_pin was removed, right?
mattm
2013/11/27 04:12:23
It was removed from nss_util and such, but cryptoh
| |
237 int slot_id) { | |
238 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
239 if (call_status == chromeos::DBUS_METHOD_CALL_FAILURE) { | |
240 NOTREACHED() << "dbus error getting TPM info for " << username_hash; | |
241 return; | |
242 } | |
243 VLOG(1) << __func__ << " "<< username_hash << " " << slot_id; | |
Ryan Sleevi
2013/11/27 00:24:11
Why VLOG __func__, when VLOG already includes the
mattm
2013/11/27 04:12:23
Just find it easier to read if you don't have to l
| |
244 BrowserThread::PostTask( | |
245 BrowserThread::IO, | |
246 FROM_HERE, | |
247 base::Bind( | |
248 &crypto::InitializeTPMForChromeOSUser, username_hash, slot_id)); | |
249 } | |
250 | |
251 void GetTPMInfoForUserOnUIThread(const std::string& username, | |
252 const std::string& username_hash) { | |
253 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
254 VLOG(1) << __func__ << " " << username << " " << username_hash; | |
255 chromeos::DBusThreadManager::Get() | |
256 ->GetCryptohomeClient() | |
257 ->Pkcs11GetTpmTokenInfoForUser( | |
258 username, | |
259 base::Bind(&DidGetTPMInfoForUserOnUIThread, username_hash)); | |
260 } | |
261 | |
262 void StartTPMSlotInitializionOnIOThread(const std::string& username, | |
263 const std::string& username_hash) { | |
264 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
265 VLOG(1) << __func__ << " " << username << " " << username_hash; | |
266 | |
267 BrowserThread::PostTask( | |
268 BrowserThread::UI, | |
269 FROM_HERE, | |
270 base::Bind(&GetTPMInfoForUserOnUIThread, username, username_hash)); | |
271 } | |
272 | |
273 void StartNSSInitOnIOThread(const std::string& username, | |
274 const std::string& username_hash, | |
275 const base::FilePath& path, | |
276 bool is_primary_user) { | |
277 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
278 VLOG(1) << "username:" << username << " hash:" << username_hash | |
279 << " is_primary_user:" << is_primary_user; | |
280 | |
281 if (!crypto::InitializeNSSForChromeOSUser( | |
282 username, username_hash, is_primary_user, path)) | |
Ryan Sleevi
2013/11/27 00:24:11
Is this clang-format'd? Seems like this should hav
mattm
2013/11/27 04:12:23
Done.
| |
283 return; | |
284 | |
285 if (crypto::IsTPMTokenEnabledForNSS()) { | |
286 if (crypto::IsTPMTokenReady()) { | |
287 StartTPMSlotInitializionOnIOThread(username, username_hash); | |
288 } else { | |
289 VLOG(1) << "waiting for tpm ready ..."; | |
290 crypto::OnTPMReady(base::Bind( | |
291 &StartTPMSlotInitializionOnIOThread, username, username_hash)); | |
292 } | |
293 } else { | |
294 crypto::InitializePrivateSoftwareSlotForChromeOSUser(username_hash); | |
295 } | |
296 } | |
297 #endif // defined(OS_CHROMEOS) | |
298 | |
226 } // namespace | 299 } // namespace |
227 | 300 |
228 void ProfileIOData::InitializeOnUIThread(Profile* profile) { | 301 void ProfileIOData::InitializeOnUIThread(Profile* profile) { |
229 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 302 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
230 PrefService* pref_service = profile->GetPrefs(); | 303 PrefService* pref_service = profile->GetPrefs(); |
231 PrefService* local_state_pref_service = g_browser_process->local_state(); | 304 PrefService* local_state_pref_service = g_browser_process->local_state(); |
232 | 305 |
233 scoped_ptr<ProfileParams> params(new ProfileParams); | 306 scoped_ptr<ProfileParams> params(new ProfileParams); |
234 params->path = profile->GetPath(); | 307 params->path = profile->GetPath(); |
235 | 308 |
(...skipping 30 matching lines...) Expand all Loading... | |
266 | 339 |
267 params->proxy_config_service | 340 params->proxy_config_service |
268 .reset(ProxyServiceFactory::CreateProxyConfigService( | 341 .reset(ProxyServiceFactory::CreateProxyConfigService( |
269 profile->GetProxyConfigTracker())); | 342 profile->GetProxyConfigTracker())); |
270 #if defined(ENABLE_MANAGED_USERS) | 343 #if defined(ENABLE_MANAGED_USERS) |
271 ManagedUserService* managed_user_service = | 344 ManagedUserService* managed_user_service = |
272 ManagedUserServiceFactory::GetForProfile(profile); | 345 ManagedUserServiceFactory::GetForProfile(profile); |
273 params->managed_mode_url_filter = | 346 params->managed_mode_url_filter = |
274 managed_user_service->GetURLFilterForIOThread(); | 347 managed_user_service->GetURLFilterForIOThread(); |
275 #endif | 348 #endif |
349 #if defined(OS_CHROMEOS) | |
350 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); | |
351 if (user_manager) { | |
352 chromeos::User* user = user_manager->GetUserByProfile(profile); | |
353 if (user) { | |
354 params->username_hash = user->username_hash(); | |
355 bool is_primary_user = (user_manager->GetPrimaryUser() == user); | |
356 BrowserThread::PostTask(BrowserThread::IO, | |
357 FROM_HERE, | |
358 base::Bind(&StartNSSInitOnIOThread, | |
359 user->email(), | |
360 user->username_hash(), | |
361 profile->GetPath(), | |
362 is_primary_user)); | |
363 } | |
364 } | |
365 if (params->username_hash.empty()) | |
366 LOG(WARNING) << "no username_hash"; | |
367 #endif | |
276 | 368 |
277 params->profile = profile; | 369 params->profile = profile; |
278 profile_params_.reset(params.release()); | 370 profile_params_.reset(params.release()); |
279 | 371 |
280 ChromeNetworkDelegate::InitializePrefsOnUIThread( | 372 ChromeNetworkDelegate::InitializePrefsOnUIThread( |
281 &enable_referrers_, | 373 &enable_referrers_, |
282 &enable_do_not_track_, | 374 &enable_do_not_track_, |
283 &force_safesearch_, | 375 &force_safesearch_, |
284 pref_service); | 376 pref_service); |
285 | 377 |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
803 #endif | 895 #endif |
804 | 896 |
805 #if defined(OS_CHROMEOS) | 897 #if defined(OS_CHROMEOS) |
806 if (cert_verifier_) { | 898 if (cert_verifier_) { |
807 cert_verifier_->InitializeOnIOThread(); | 899 cert_verifier_->InitializeOnIOThread(); |
808 main_request_context_->set_cert_verifier(cert_verifier_.get()); | 900 main_request_context_->set_cert_verifier(cert_verifier_.get()); |
809 } else { | 901 } else { |
810 main_request_context_->set_cert_verifier( | 902 main_request_context_->set_cert_verifier( |
811 io_thread_globals->cert_verifier.get()); | 903 io_thread_globals->cert_verifier.get()); |
812 } | 904 } |
905 username_hash_ = profile_params_->username_hash; | |
813 #else | 906 #else |
814 main_request_context_->set_cert_verifier( | 907 main_request_context_->set_cert_verifier( |
815 io_thread_globals->cert_verifier.get()); | 908 io_thread_globals->cert_verifier.get()); |
816 #endif | 909 #endif |
817 | 910 |
818 InitializeInternal(profile_params_.get(), protocol_handlers); | 911 InitializeInternal(profile_params_.get(), protocol_handlers); |
819 | 912 |
820 profile_params_.reset(); | 913 profile_params_.reset(); |
821 initialized_ = true; | 914 initialized_ = true; |
822 } | 915 } |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
960 void ProfileIOData::SetCookieSettingsForTesting( | 1053 void ProfileIOData::SetCookieSettingsForTesting( |
961 CookieSettings* cookie_settings) { | 1054 CookieSettings* cookie_settings) { |
962 DCHECK(!cookie_settings_.get()); | 1055 DCHECK(!cookie_settings_.get()); |
963 cookie_settings_ = cookie_settings; | 1056 cookie_settings_ = cookie_settings; |
964 } | 1057 } |
965 | 1058 |
966 void ProfileIOData::set_signin_names_for_testing( | 1059 void ProfileIOData::set_signin_names_for_testing( |
967 SigninNamesOnIOThread* signin_names) { | 1060 SigninNamesOnIOThread* signin_names) { |
968 signin_names_.reset(signin_names); | 1061 signin_names_.reset(signin_names); |
969 } | 1062 } |
OLD | NEW |