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 23 matching lines...) Expand all Loading... |
34 #include "chrome/browser/download/download_service_factory.h" | 34 #include "chrome/browser/download/download_service_factory.h" |
35 #include "chrome/browser/extensions/extension_resource_protocols.h" | 35 #include "chrome/browser/extensions/extension_resource_protocols.h" |
36 #include "chrome/browser/io_thread.h" | 36 #include "chrome/browser/io_thread.h" |
37 #include "chrome/browser/media/media_device_id_salt.h" | 37 #include "chrome/browser/media/media_device_id_salt.h" |
38 #include "chrome/browser/net/about_protocol_handler.h" | 38 #include "chrome/browser/net/about_protocol_handler.h" |
39 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" | 39 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" |
40 #include "chrome/browser/net/chrome_http_user_agent_settings.h" | 40 #include "chrome/browser/net/chrome_http_user_agent_settings.h" |
41 #include "chrome/browser/net/chrome_net_log.h" | 41 #include "chrome/browser/net/chrome_net_log.h" |
42 #include "chrome/browser/net/chrome_network_delegate.h" | 42 #include "chrome/browser/net/chrome_network_delegate.h" |
43 #include "chrome/browser/net/cookie_store_util.h" | 43 #include "chrome/browser/net/cookie_store_util.h" |
| 44 #include "chrome/browser/net/nss_context.h" |
44 #include "chrome/browser/net/proxy_service_factory.h" | 45 #include "chrome/browser/net/proxy_service_factory.h" |
45 #include "chrome/browser/profiles/profile.h" | 46 #include "chrome/browser/profiles/profile.h" |
46 #include "chrome/browser/profiles/profile_manager.h" | 47 #include "chrome/browser/profiles/profile_manager.h" |
47 #include "chrome/browser/signin/signin_names_io_thread.h" | 48 #include "chrome/browser/signin/signin_names_io_thread.h" |
48 #include "chrome/common/chrome_paths.h" | 49 #include "chrome/common/chrome_paths.h" |
49 #include "chrome/common/chrome_switches.h" | 50 #include "chrome/common/chrome_switches.h" |
50 #include "chrome/common/pref_names.h" | 51 #include "chrome/common/pref_names.h" |
51 #include "chrome/common/url_constants.h" | 52 #include "chrome/common/url_constants.h" |
52 #include "components/startup_metric_utils/startup_metric_utils.h" | 53 #include "components/startup_metric_utils/startup_metric_utils.h" |
53 #include "components/sync_driver/pref_names.h" | 54 #include "components/sync_driver/pref_names.h" |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 StartTPMSlotInitializationOnIOThread(username, username_hash); | 311 StartTPMSlotInitializationOnIOThread(username, username_hash); |
311 } else { | 312 } else { |
312 DVLOG(1) << "Waiting for tpm ready ..."; | 313 DVLOG(1) << "Waiting for tpm ready ..."; |
313 } | 314 } |
314 } else { | 315 } else { |
315 crypto::InitializePrivateSoftwareSlotForChromeOSUser(username_hash); | 316 crypto::InitializePrivateSoftwareSlotForChromeOSUser(username_hash); |
316 } | 317 } |
317 } | 318 } |
318 #endif // defined(OS_CHROMEOS) | 319 #endif // defined(OS_CHROMEOS) |
319 | 320 |
| 321 #if defined(USE_NSS) |
| 322 void CreateKeygenHandlerWithSlot( |
| 323 const GURL& url, |
| 324 const base::Callback<void(scoped_ptr<net::KeygenHandler>)>& callback, |
| 325 scoped_ptr<net::KeygenHandler> keygen_handler, |
| 326 crypto::ScopedPK11Slot slot) { |
| 327 scoped_ptr<crypto::CryptoModuleBlockingPasswordDelegate> delegate( |
| 328 new ChromeNSSCryptoModuleDelegate(chrome::kCryptoModulePasswordKeygen, |
| 329 net::HostPortPair::FromURL(url))); |
| 330 keygen_handler->set_crypto_module_delegate(delegate.Pass()); |
| 331 keygen_handler->set_key_slot(slot.Pass()); |
| 332 |
| 333 callback.Run(keygen_handler.Pass()); |
| 334 } |
| 335 #endif // defined(USE_NSS) |
| 336 |
320 } // namespace | 337 } // namespace |
321 | 338 |
322 void ProfileIOData::InitializeOnUIThread(Profile* profile) { | 339 void ProfileIOData::InitializeOnUIThread(Profile* profile) { |
323 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 340 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
324 PrefService* pref_service = profile->GetPrefs(); | 341 PrefService* pref_service = profile->GetPrefs(); |
325 PrefService* local_state_pref_service = g_browser_process->local_state(); | 342 PrefService* local_state_pref_service = g_browser_process->local_state(); |
326 | 343 |
327 scoped_ptr<ProfileParams> params(new ProfileParams); | 344 scoped_ptr<ProfileParams> params(new ProfileParams); |
328 params->path = profile->GetPath(); | 345 params->path = profile->GetPath(); |
329 | 346 |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 void ProfileIOData::ResourceContext::CreateKeygenHandler( | 918 void ProfileIOData::ResourceContext::CreateKeygenHandler( |
902 uint32 key_size_in_bits, | 919 uint32 key_size_in_bits, |
903 const std::string& challenge_string, | 920 const std::string& challenge_string, |
904 const GURL& url, | 921 const GURL& url, |
905 const base::Callback<void(scoped_ptr<net::KeygenHandler>)>& callback) { | 922 const base::Callback<void(scoped_ptr<net::KeygenHandler>)>& callback) { |
906 DCHECK(!callback.is_null()); | 923 DCHECK(!callback.is_null()); |
907 #if defined(USE_NSS) | 924 #if defined(USE_NSS) |
908 scoped_ptr<net::KeygenHandler> keygen_handler( | 925 scoped_ptr<net::KeygenHandler> keygen_handler( |
909 new net::KeygenHandler(key_size_in_bits, challenge_string, url)); | 926 new net::KeygenHandler(key_size_in_bits, challenge_string, url)); |
910 | 927 |
911 scoped_ptr<ChromeNSSCryptoModuleDelegate> delegate( | 928 base::Callback<void(crypto::ScopedPK11Slot)> get_slot_callback = |
912 new ChromeNSSCryptoModuleDelegate(chrome::kCryptoModulePasswordKeygen, | 929 base::Bind(&CreateKeygenHandlerWithSlot, |
913 net::HostPortPair::FromURL(url))); | 930 url, |
914 ChromeNSSCryptoModuleDelegate* delegate_ptr = delegate.get(); | 931 callback, |
915 keygen_handler->set_crypto_module_delegate( | 932 base::Passed(&keygen_handler)); |
916 delegate.PassAs<crypto::NSSCryptoModuleDelegate>()); | |
917 | 933 |
918 base::Closure bound_callback = | 934 crypto::ScopedPK11Slot slot = |
919 base::Bind(callback, base::Passed(&keygen_handler)); | 935 GetPrivateNSSKeySlotForResourceContext(this, get_slot_callback); |
920 if (delegate_ptr->InitializeSlot(this, bound_callback)) { | 936 |
921 // Initialization complete, run the callback synchronously. | 937 if (slot) { |
922 bound_callback.Run(); | 938 // Obtained the slot synchronously, run the callback synchronously. |
| 939 get_slot_callback.Run(slot.Pass()); |
923 return; | 940 return; |
924 } | 941 } |
925 // Otherwise, the InitializeSlot will run the callback asynchronously. | 942 // Otherwise, GetPrivateNSSKeySlotForResourceContext will run the callback |
| 943 // asynchronously. |
926 #else | 944 #else |
927 callback.Run(make_scoped_ptr( | 945 callback.Run(make_scoped_ptr( |
928 new net::KeygenHandler(key_size_in_bits, challenge_string, url))); | 946 new net::KeygenHandler(key_size_in_bits, challenge_string, url))); |
929 #endif | 947 #endif |
930 } | 948 } |
931 | 949 |
932 bool ProfileIOData::ResourceContext::AllowMicAccess(const GURL& origin) { | 950 bool ProfileIOData::ResourceContext::AllowMicAccess(const GURL& origin) { |
933 return AllowContentAccess(origin, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 951 return AllowContentAccess(origin, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
934 } | 952 } |
935 | 953 |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1251 void ProfileIOData::SetCookieSettingsForTesting( | 1269 void ProfileIOData::SetCookieSettingsForTesting( |
1252 CookieSettings* cookie_settings) { | 1270 CookieSettings* cookie_settings) { |
1253 DCHECK(!cookie_settings_.get()); | 1271 DCHECK(!cookie_settings_.get()); |
1254 cookie_settings_ = cookie_settings; | 1272 cookie_settings_ = cookie_settings; |
1255 } | 1273 } |
1256 | 1274 |
1257 void ProfileIOData::set_signin_names_for_testing( | 1275 void ProfileIOData::set_signin_names_for_testing( |
1258 SigninNamesOnIOThread* signin_names) { | 1276 SigninNamesOnIOThread* signin_names) { |
1259 signin_names_.reset(signin_names); | 1277 signin_names_.reset(signin_names); |
1260 } | 1278 } |
OLD | NEW |