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/client_cert_store_impl.h" | 75 #include "net/ssl/client_cert_store_impl.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 96 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" | 97 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" |
| 97 #include "chrome/browser/chromeos/settings/cros_settings.h" | 98 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 98 #include "chromeos/dbus/cryptohome_client.h" | 99 #include "chromeos/dbus/cryptohome_client.h" |
| 99 #include "chromeos/dbus/dbus_thread_manager.h" | 100 #include "chromeos/dbus/dbus_thread_manager.h" |
| 100 #include "chromeos/settings/cros_settings_names.h" | 101 #include "chromeos/settings/cros_settings_names.h" |
| 101 #include "crypto/nss_util.h" | 102 #include "crypto/nss_util.h" |
| 102 #include "crypto/nss_util_internal.h" | 103 #include "crypto/nss_util_internal.h" |
| 103 #endif // defined(OS_CHROMEOS) | 104 #endif // defined(OS_CHROMEOS) |
| 104 | 105 |
| 105 #if defined(USE_NSS) | 106 #if defined(USE_NSS) |
| 106 #include "chrome/browser/ui/crypto_module_password_dialog.h" | 107 #include "chrome/browser/ui/crypto_module_delegate_nss.h" |
| 107 #endif | 108 #endif |
| 108 | 109 |
| 109 using content::BrowserContext; | 110 using content::BrowserContext; |
| 110 using content::BrowserThread; | 111 using content::BrowserThread; |
| 111 using content::ResourceContext; | 112 using content::ResourceContext; |
| 112 | 113 |
| 113 namespace { | 114 namespace { |
| 114 | 115 |
| 115 // ---------------------------------------------------------------------------- | 116 // ---------------------------------------------------------------------------- |
| 116 // CookieMonster::Delegate implementation | 117 // CookieMonster::Delegate implementation |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 StartTPMSlotInitializationOnIOThread(username, username_hash); | 334 StartTPMSlotInitializationOnIOThread(username, username_hash); |
| 334 } else { | 335 } else { |
| 335 DVLOG(1) << "Waiting for tpm ready ..."; | 336 DVLOG(1) << "Waiting for tpm ready ..."; |
| 336 } | 337 } |
| 337 } else { | 338 } else { |
| 338 crypto::InitializePrivateSoftwareSlotForChromeOSUser(username_hash); | 339 crypto::InitializePrivateSoftwareSlotForChromeOSUser(username_hash); |
| 339 } | 340 } |
| 340 } | 341 } |
| 341 #endif // defined(OS_CHROMEOS) | 342 #endif // defined(OS_CHROMEOS) |
| 342 | 343 |
| 344 #if defined(USE_NSS) | |
| 345 void KeygenHandlerCallbackHelper( | |
| 346 const base::Callback<void(scoped_ptr<net::KeygenHandler>)>& callback, | |
| 347 scoped_ptr<net::KeygenHandler>* keygen_handler) { | |
| 348 callback.Run(keygen_handler->Pass()); | |
| 349 }; | |
| 350 #endif // defined(USE_NSS) | |
| 351 | |
| 343 } // namespace | 352 } // namespace |
| 344 | 353 |
| 345 void ProfileIOData::InitializeOnUIThread(Profile* profile) { | 354 void ProfileIOData::InitializeOnUIThread(Profile* profile) { |
| 346 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 355 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 347 PrefService* pref_service = profile->GetPrefs(); | 356 PrefService* pref_service = profile->GetPrefs(); |
| 348 PrefService* local_state_pref_service = g_browser_process->local_state(); | 357 PrefService* local_state_pref_service = g_browser_process->local_state(); |
| 349 | 358 |
| 350 scoped_ptr<ProfileParams> params(new ProfileParams); | 359 scoped_ptr<ProfileParams> params(new ProfileParams); |
| 351 params->path = profile->GetPath(); | 360 params->path = profile->GetPath(); |
| 352 | 361 |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 819 DCHECK(io_data_->initialized_); | 828 DCHECK(io_data_->initialized_); |
| 820 return request_context_; | 829 return request_context_; |
| 821 } | 830 } |
| 822 | 831 |
| 823 scoped_ptr<net::ClientCertStore> | 832 scoped_ptr<net::ClientCertStore> |
| 824 ProfileIOData::ResourceContext::CreateClientCertStore() { | 833 ProfileIOData::ResourceContext::CreateClientCertStore() { |
| 825 #if !defined(USE_OPENSSL) | 834 #if !defined(USE_OPENSSL) |
| 826 scoped_ptr<net::ClientCertStoreImpl> store(new net::ClientCertStoreImpl()); | 835 scoped_ptr<net::ClientCertStoreImpl> store(new net::ClientCertStoreImpl()); |
| 827 #if defined(USE_NSS) | 836 #if defined(USE_NSS) |
| 828 store->set_password_delegate_factory( | 837 store->set_password_delegate_factory( |
| 829 base::Bind(&chrome::NewCryptoModuleBlockingDialogDelegate, | 838 base::Bind(&CreateCryptoModuleBlockingPasswordDelegate, |
| 830 chrome::kCryptoModulePasswordClientAuth)); | 839 chrome::kCryptoModulePasswordClientAuth)); |
| 831 #endif | 840 #endif |
| 832 return store.PassAs<net::ClientCertStore>(); | 841 return store.PassAs<net::ClientCertStore>(); |
| 833 #else // defined(USE_OPENSSL) | 842 #else // defined(USE_OPENSSL) |
| 834 // OpenSSL does not use the ClientCertStore infrastructure. On Android client | 843 // OpenSSL does not use the ClientCertStore infrastructure. On Android client |
| 835 // cert matching is done by the OS as part of the call to show the cert | 844 // cert matching is done by the OS as part of the call to show the cert |
| 836 // selection dialog. | 845 // selection dialog. |
| 837 return scoped_ptr<net::ClientCertStore>(); | 846 return scoped_ptr<net::ClientCertStore>(); |
| 838 #endif | 847 #endif |
| 839 } | 848 } |
| 840 | 849 |
| 850 scoped_ptr<net::KeygenHandler> | |
| 851 ProfileIOData::ResourceContext::CreateKeygenHandler( | |
| 852 uint32 key_size_in_bits, | |
| 853 const std::string& challenge_string, | |
| 854 const GURL& url, | |
| 855 const base::Callback<void(scoped_ptr<net::KeygenHandler>)>& callback) { | |
| 856 DCHECK(!callback.is_null()); | |
| 857 #if defined(USE_NSS) | |
| 858 scoped_ptr<net::KeygenHandler>* keygen_handler = | |
|
sky
2013/12/11 00:26:00
Can't you use a scoped_ptr rather than scoped_ptr*
mattm
2013/12/11 01:10:46
see the comment on line 869, I'll add a comment he
sky
2013/12/11 14:20:42
I thought base::Passed(XXX) was the preferred way
| |
| 859 new scoped_ptr<net::KeygenHandler>( | |
| 860 new net::KeygenHandler(key_size_in_bits, challenge_string, url)); | |
| 861 | |
| 862 scoped_ptr<ChromeNSSCryptoModuleDelegate> delegate( | |
| 863 new ChromeNSSCryptoModuleDelegate(chrome::kCryptoModulePasswordKeygen, | |
| 864 url.host())); | |
| 865 ChromeNSSCryptoModuleDelegate* delegate_ptr = delegate.get(); | |
| 866 (*keygen_handler)->set_crypto_module_delegate( | |
| 867 delegate.PassAs<crypto::NSSCryptoModuleDelegate>()); | |
| 868 | |
| 869 // Keep |helper_callback| on the stack, since ownership of | |
| 870 // |keygen_handler| is transferred to |helper_callback|. This allows | |
| 871 // |keygen_handler| to still be accessed if InitializeSlot returns with | |
| 872 // synchronous success. | |
| 873 base::Closure helper_callback = base::Bind( | |
| 874 &KeygenHandlerCallbackHelper, callback, base::Owned(keygen_handler)); | |
| 875 if (delegate_ptr->InitializeSlot(this, helper_callback)) { | |
| 876 // Synchronous success, return the KeygenHandler directly. | |
| 877 return keygen_handler->Pass(); | |
| 878 } | |
| 879 // The KeygenHandler will be passed to |callback| by | |
| 880 // KeygenHandlerCallbackHelper. | |
| 881 return scoped_ptr<net::KeygenHandler>(); | |
| 882 #else | |
| 883 return scoped_ptr<net::KeygenHandler>( | |
| 884 new net::KeygenHandler(key_size_in_bits, challenge_string, url)); | |
| 885 #endif | |
| 886 } | |
| 887 | |
| 841 bool ProfileIOData::ResourceContext::AllowMicAccess(const GURL& origin) { | 888 bool ProfileIOData::ResourceContext::AllowMicAccess(const GURL& origin) { |
| 842 return AllowContentAccess(origin, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 889 return AllowContentAccess(origin, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
| 843 } | 890 } |
| 844 | 891 |
| 845 bool ProfileIOData::ResourceContext::AllowCameraAccess(const GURL& origin) { | 892 bool ProfileIOData::ResourceContext::AllowCameraAccess(const GURL& origin) { |
| 846 return AllowContentAccess(origin, CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 893 return AllowContentAccess(origin, CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
| 847 } | 894 } |
| 848 | 895 |
| 849 bool ProfileIOData::ResourceContext::AllowContentAccess( | 896 bool ProfileIOData::ResourceContext::AllowContentAccess( |
| 850 const GURL& origin, ContentSettingsType type) { | 897 const GURL& origin, ContentSettingsType type) { |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1118 void ProfileIOData::SetCookieSettingsForTesting( | 1165 void ProfileIOData::SetCookieSettingsForTesting( |
| 1119 CookieSettings* cookie_settings) { | 1166 CookieSettings* cookie_settings) { |
| 1120 DCHECK(!cookie_settings_.get()); | 1167 DCHECK(!cookie_settings_.get()); |
| 1121 cookie_settings_ = cookie_settings; | 1168 cookie_settings_ = cookie_settings; |
| 1122 } | 1169 } |
| 1123 | 1170 |
| 1124 void ProfileIOData::set_signin_names_for_testing( | 1171 void ProfileIOData::set_signin_names_for_testing( |
| 1125 SigninNamesOnIOThread* signin_names) { | 1172 SigninNamesOnIOThread* signin_names) { |
| 1126 signin_names_.reset(signin_names); | 1173 signin_names_.reset(signin_names); |
| 1127 } | 1174 } |
| OLD | NEW |