Chromium Code Reviews| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 #include "chrome/common/chrome_switches.h" | 55 #include "chrome/common/chrome_switches.h" |
| 56 #include "chrome/common/pref_names.h" | 56 #include "chrome/common/pref_names.h" |
| 57 #include "chrome/common/url_constants.h" | 57 #include "chrome/common/url_constants.h" |
| 58 #include "components/startup_metric_utils/startup_metric_utils.h" | 58 #include "components/startup_metric_utils/startup_metric_utils.h" |
| 59 #include "content/public/browser/browser_thread.h" | 59 #include "content/public/browser/browser_thread.h" |
| 60 #include "content/public/browser/host_zoom_map.h" | 60 #include "content/public/browser/host_zoom_map.h" |
| 61 #include "content/public/browser/notification_service.h" | 61 #include "content/public/browser/notification_service.h" |
| 62 #include "content/public/browser/resource_context.h" | 62 #include "content/public/browser/resource_context.h" |
| 63 #include "extensions/browser/info_map.h" | 63 #include "extensions/browser/info_map.h" |
| 64 #include "extensions/common/constants.h" | 64 #include "extensions/common/constants.h" |
| 65 #include "net/base/keygen_handler.h" | |
| 65 #include "net/cookies/canonical_cookie.h" | 66 #include "net/cookies/canonical_cookie.h" |
| 66 #include "net/cookies/cookie_monster.h" | 67 #include "net/cookies/cookie_monster.h" |
| 67 #include "net/http/http_transaction_factory.h" | 68 #include "net/http/http_transaction_factory.h" |
| 68 #include "net/http/http_util.h" | 69 #include "net/http/http_util.h" |
| 69 #include "net/http/transport_security_persister.h" | 70 #include "net/http/transport_security_persister.h" |
| 70 #include "net/proxy/proxy_config_service_fixed.h" | 71 #include "net/proxy/proxy_config_service_fixed.h" |
| 71 #include "net/proxy/proxy_script_fetcher_impl.h" | 72 #include "net/proxy/proxy_script_fetcher_impl.h" |
| 72 #include "net/proxy/proxy_service.h" | 73 #include "net/proxy/proxy_service.h" |
| 73 #include "net/ssl/client_cert_store.h" | 74 #include "net/ssl/client_cert_store.h" |
| 74 #include "net/ssl/server_bound_cert_service.h" | 75 #include "net/ssl/server_bound_cert_service.h" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 95 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" | 96 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" |
| 96 #include "chrome/browser/chromeos/settings/cros_settings.h" | 97 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 97 #include "chromeos/dbus/cryptohome_client.h" | 98 #include "chromeos/dbus/cryptohome_client.h" |
| 98 #include "chromeos/dbus/dbus_thread_manager.h" | 99 #include "chromeos/dbus/dbus_thread_manager.h" |
| 99 #include "chromeos/settings/cros_settings_names.h" | 100 #include "chromeos/settings/cros_settings_names.h" |
| 100 #include "crypto/nss_util.h" | 101 #include "crypto/nss_util.h" |
| 101 #include "crypto/nss_util_internal.h" | 102 #include "crypto/nss_util_internal.h" |
| 102 #endif // defined(OS_CHROMEOS) | 103 #endif // defined(OS_CHROMEOS) |
| 103 | 104 |
| 104 #if defined(USE_NSS) | 105 #if defined(USE_NSS) |
| 105 #include "chrome/browser/ui/crypto_module_password_dialog.h" | 106 #include "chrome/browser/ui/crypto_module_delegate_nss.h" |
| 106 #include "net/ssl/client_cert_store_nss.h" | 107 #include "net/ssl/client_cert_store_nss.h" |
| 107 #endif | 108 #endif |
| 108 | 109 |
| 109 #if defined(OS_WIN) | 110 #if defined(OS_WIN) |
| 110 #include "net/ssl/client_cert_store_win.h" | 111 #include "net/ssl/client_cert_store_win.h" |
| 111 #endif | 112 #endif |
| 112 | 113 |
| 113 #if defined(OS_MACOSX) | 114 #if defined(OS_MACOSX) |
| 114 #include "net/ssl/client_cert_store_mac.h" | 115 #include "net/ssl/client_cert_store_mac.h" |
| 115 #endif | 116 #endif |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 StartTPMSlotInitializationOnIOThread(username, username_hash); | 342 StartTPMSlotInitializationOnIOThread(username, username_hash); |
| 342 } else { | 343 } else { |
| 343 DVLOG(1) << "Waiting for tpm ready ..."; | 344 DVLOG(1) << "Waiting for tpm ready ..."; |
| 344 } | 345 } |
| 345 } else { | 346 } else { |
| 346 crypto::InitializePrivateSoftwareSlotForChromeOSUser(username_hash); | 347 crypto::InitializePrivateSoftwareSlotForChromeOSUser(username_hash); |
| 347 } | 348 } |
| 348 } | 349 } |
| 349 #endif // defined(OS_CHROMEOS) | 350 #endif // defined(OS_CHROMEOS) |
| 350 | 351 |
| 352 #if defined(USE_NSS) | |
| 353 void KeygenHandlerCallbackHelper( | |
| 354 const base::Callback<void(scoped_ptr<net::KeygenHandler>)>& callback, | |
| 355 scoped_ptr<net::KeygenHandler>* keygen_handler) { | |
| 356 callback.Run(keygen_handler->Pass()); | |
| 357 }; | |
|
sky
2013/12/11 14:20:42
nit: no ;
mattm
2013/12/11 23:12:09
Done.
| |
| 358 #endif // defined(USE_NSS) | |
| 359 | |
| 351 } // namespace | 360 } // namespace |
| 352 | 361 |
| 353 void ProfileIOData::InitializeOnUIThread(Profile* profile) { | 362 void ProfileIOData::InitializeOnUIThread(Profile* profile) { |
| 354 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 363 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 355 PrefService* pref_service = profile->GetPrefs(); | 364 PrefService* pref_service = profile->GetPrefs(); |
| 356 PrefService* local_state_pref_service = g_browser_process->local_state(); | 365 PrefService* local_state_pref_service = g_browser_process->local_state(); |
| 357 | 366 |
| 358 scoped_ptr<ProfileParams> params(new ProfileParams); | 367 scoped_ptr<ProfileParams> params(new ProfileParams); |
| 359 params->path = profile->GetPath(); | 368 params->path = profile->GetPath(); |
| 360 | 369 |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 825 net::URLRequestContext* ProfileIOData::ResourceContext::GetRequestContext() { | 834 net::URLRequestContext* ProfileIOData::ResourceContext::GetRequestContext() { |
| 826 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 835 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 827 DCHECK(io_data_->initialized_); | 836 DCHECK(io_data_->initialized_); |
| 828 return request_context_; | 837 return request_context_; |
| 829 } | 838 } |
| 830 | 839 |
| 831 scoped_ptr<net::ClientCertStore> | 840 scoped_ptr<net::ClientCertStore> |
| 832 ProfileIOData::ResourceContext::CreateClientCertStore() { | 841 ProfileIOData::ResourceContext::CreateClientCertStore() { |
| 833 #if defined(USE_NSS) | 842 #if defined(USE_NSS) |
| 834 return scoped_ptr<net::ClientCertStore>(new net::ClientCertStoreNSS( | 843 return scoped_ptr<net::ClientCertStore>(new net::ClientCertStoreNSS( |
| 835 base::Bind(&chrome::NewCryptoModuleBlockingDialogDelegate, | 844 base::Bind(&CreateCryptoModuleBlockingPasswordDelegate, |
| 836 chrome::kCryptoModulePasswordClientAuth))); | 845 chrome::kCryptoModulePasswordClientAuth))); |
| 837 #elif defined(OS_WIN) | 846 #elif defined(OS_WIN) |
| 838 return scoped_ptr<net::ClientCertStore>(new net::ClientCertStoreWin()); | 847 return scoped_ptr<net::ClientCertStore>(new net::ClientCertStoreWin()); |
| 839 #elif defined(OS_MACOSX) | 848 #elif defined(OS_MACOSX) |
| 840 return scoped_ptr<net::ClientCertStore>(new net::ClientCertStoreMac()); | 849 return scoped_ptr<net::ClientCertStore>(new net::ClientCertStoreMac()); |
| 841 #elif defined(USE_OPENSSL) | 850 #elif defined(USE_OPENSSL) |
| 842 // OpenSSL does not use the ClientCertStore infrastructure. On Android client | 851 // OpenSSL does not use the ClientCertStore infrastructure. On Android client |
| 843 // cert matching is done by the OS as part of the call to show the cert | 852 // cert matching is done by the OS as part of the call to show the cert |
| 844 // selection dialog. | 853 // selection dialog. |
| 845 return scoped_ptr<net::ClientCertStore>(); | 854 return scoped_ptr<net::ClientCertStore>(); |
| 846 #else | 855 #else |
| 847 #error Unknown platform. | 856 #error Unknown platform. |
| 848 #endif | 857 #endif |
| 849 } | 858 } |
| 850 | 859 |
| 860 scoped_ptr<net::KeygenHandler> | |
| 861 ProfileIOData::ResourceContext::CreateKeygenHandler( | |
| 862 uint32 key_size_in_bits, | |
| 863 const std::string& challenge_string, | |
| 864 const GURL& url, | |
| 865 const base::Callback<void(scoped_ptr<net::KeygenHandler>)>& callback) { | |
| 866 DCHECK(!callback.is_null()); | |
| 867 #if defined(USE_NSS) | |
| 868 // Store the KeygenHandler scoped_ptr on the heap, which will be Owned by | |
| 869 // the helper_callback below. This allows the KeygenHandler to be retrieved | |
| 870 // and returned directly in the synchronous success case. | |
| 871 scoped_ptr<net::KeygenHandler>* keygen_handler = | |
| 872 new scoped_ptr<net::KeygenHandler>( | |
| 873 new net::KeygenHandler(key_size_in_bits, challenge_string, url)); | |
| 874 | |
| 875 scoped_ptr<ChromeNSSCryptoModuleDelegate> delegate( | |
| 876 new ChromeNSSCryptoModuleDelegate(chrome::kCryptoModulePasswordKeygen, | |
| 877 url.host())); | |
| 878 ChromeNSSCryptoModuleDelegate* delegate_ptr = delegate.get(); | |
| 879 (*keygen_handler)->set_crypto_module_delegate( | |
| 880 delegate.PassAs<crypto::NSSCryptoModuleDelegate>()); | |
| 881 | |
| 882 // Keep |helper_callback| on the stack, since ownership of | |
| 883 // |keygen_handler| is transferred to |helper_callback|. This allows | |
| 884 // |keygen_handler| to still be accessed if InitializeSlot returns with | |
| 885 // synchronous success. | |
| 886 base::Closure helper_callback = base::Bind( | |
| 887 &KeygenHandlerCallbackHelper, callback, base::Owned(keygen_handler)); | |
| 888 if (delegate_ptr->InitializeSlot(this, helper_callback)) { | |
| 889 // Synchronous success, return the KeygenHandler directly. | |
| 890 return keygen_handler->Pass(); | |
| 891 } | |
| 892 // The KeygenHandler will be passed to |callback| by | |
| 893 // KeygenHandlerCallbackHelper. | |
| 894 return scoped_ptr<net::KeygenHandler>(); | |
| 895 #else | |
| 896 return scoped_ptr<net::KeygenHandler>( | |
| 897 new net::KeygenHandler(key_size_in_bits, challenge_string, url)); | |
| 898 #endif | |
| 899 } | |
| 900 | |
| 851 bool ProfileIOData::ResourceContext::AllowMicAccess(const GURL& origin) { | 901 bool ProfileIOData::ResourceContext::AllowMicAccess(const GURL& origin) { |
| 852 return AllowContentAccess(origin, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 902 return AllowContentAccess(origin, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
| 853 } | 903 } |
| 854 | 904 |
| 855 bool ProfileIOData::ResourceContext::AllowCameraAccess(const GURL& origin) { | 905 bool ProfileIOData::ResourceContext::AllowCameraAccess(const GURL& origin) { |
| 856 return AllowContentAccess(origin, CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 906 return AllowContentAccess(origin, CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
| 857 } | 907 } |
| 858 | 908 |
| 859 bool ProfileIOData::ResourceContext::AllowContentAccess( | 909 bool ProfileIOData::ResourceContext::AllowContentAccess( |
| 860 const GURL& origin, ContentSettingsType type) { | 910 const GURL& origin, ContentSettingsType type) { |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1128 void ProfileIOData::SetCookieSettingsForTesting( | 1178 void ProfileIOData::SetCookieSettingsForTesting( |
| 1129 CookieSettings* cookie_settings) { | 1179 CookieSettings* cookie_settings) { |
| 1130 DCHECK(!cookie_settings_.get()); | 1180 DCHECK(!cookie_settings_.get()); |
| 1131 cookie_settings_ = cookie_settings; | 1181 cookie_settings_ = cookie_settings; |
| 1132 } | 1182 } |
| 1133 | 1183 |
| 1134 void ProfileIOData::set_signin_names_for_testing( | 1184 void ProfileIOData::set_signin_names_for_testing( |
| 1135 SigninNamesOnIOThread* signin_names) { | 1185 SigninNamesOnIOThread* signin_names) { |
| 1136 signin_names_.reset(signin_names); | 1186 signin_names_.reset(signin_names); |
| 1137 } | 1187 } |
| OLD | NEW |