Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: chrome/browser/profiles/profile_io_data.cc

Issue 61643007: Update keygen to use correct NSS slot on ChromeOS multiprofile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: unit_test compile fix Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 28 matching lines...) Expand all
103 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" 104 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h"
104 #include "chrome/browser/chromeos/settings/cros_settings.h" 105 #include "chrome/browser/chromeos/settings/cros_settings.h"
105 #include "chromeos/dbus/cryptohome_client.h" 106 #include "chromeos/dbus/cryptohome_client.h"
106 #include "chromeos/dbus/dbus_thread_manager.h" 107 #include "chromeos/dbus/dbus_thread_manager.h"
107 #include "chromeos/settings/cros_settings_names.h" 108 #include "chromeos/settings/cros_settings_names.h"
108 #include "crypto/nss_util.h" 109 #include "crypto/nss_util.h"
109 #include "crypto/nss_util_internal.h" 110 #include "crypto/nss_util_internal.h"
110 #endif // defined(OS_CHROMEOS) 111 #endif // defined(OS_CHROMEOS)
111 112
112 #if defined(USE_NSS) 113 #if defined(USE_NSS)
113 #include "chrome/browser/ui/crypto_module_password_dialog.h" 114 #include "chrome/browser/ui/crypto_module_delegate_nss.h"
114 #include "net/ssl/client_cert_store_nss.h" 115 #include "net/ssl/client_cert_store_nss.h"
115 #endif 116 #endif
116 117
117 #if defined(OS_WIN) 118 #if defined(OS_WIN)
118 #include "net/ssl/client_cert_store_win.h" 119 #include "net/ssl/client_cert_store_win.h"
119 #endif 120 #endif
120 121
121 #if defined(OS_MACOSX) 122 #if defined(OS_MACOSX)
122 #include "net/ssl/client_cert_store_mac.h" 123 #include "net/ssl/client_cert_store_mac.h"
123 #endif 124 #endif
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 StartTPMSlotInitializationOnIOThread(username, username_hash); 350 StartTPMSlotInitializationOnIOThread(username, username_hash);
350 } else { 351 } else {
351 DVLOG(1) << "Waiting for tpm ready ..."; 352 DVLOG(1) << "Waiting for tpm ready ...";
352 } 353 }
353 } else { 354 } else {
354 crypto::InitializePrivateSoftwareSlotForChromeOSUser(username_hash); 355 crypto::InitializePrivateSoftwareSlotForChromeOSUser(username_hash);
355 } 356 }
356 } 357 }
357 #endif // defined(OS_CHROMEOS) 358 #endif // defined(OS_CHROMEOS)
358 359
360 #if defined(USE_NSS)
361 void KeygenHandlerCallbackHelper(
362 const base::Callback<void(scoped_ptr<net::KeygenHandler>)>& callback,
363 scoped_ptr<net::KeygenHandler>* keygen_handler) {
364 callback.Run(keygen_handler->Pass());
365 }
366 #endif // defined(USE_NSS)
367
359 } // namespace 368 } // namespace
360 369
361 void ProfileIOData::InitializeOnUIThread(Profile* profile) { 370 void ProfileIOData::InitializeOnUIThread(Profile* profile) {
362 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 371 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
363 PrefService* pref_service = profile->GetPrefs(); 372 PrefService* pref_service = profile->GetPrefs();
364 PrefService* local_state_pref_service = g_browser_process->local_state(); 373 PrefService* local_state_pref_service = g_browser_process->local_state();
365 374
366 scoped_ptr<ProfileParams> params(new ProfileParams); 375 scoped_ptr<ProfileParams> params(new ProfileParams);
367 params->path = profile->GetPath(); 376 params->path = profile->GetPath();
368 377
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 net::URLRequestContext* ProfileIOData::ResourceContext::GetRequestContext() { 856 net::URLRequestContext* ProfileIOData::ResourceContext::GetRequestContext() {
848 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 857 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
849 DCHECK(io_data_->initialized_); 858 DCHECK(io_data_->initialized_);
850 return request_context_; 859 return request_context_;
851 } 860 }
852 861
853 scoped_ptr<net::ClientCertStore> 862 scoped_ptr<net::ClientCertStore>
854 ProfileIOData::ResourceContext::CreateClientCertStore() { 863 ProfileIOData::ResourceContext::CreateClientCertStore() {
855 #if defined(USE_NSS) 864 #if defined(USE_NSS)
856 return scoped_ptr<net::ClientCertStore>(new net::ClientCertStoreNSS( 865 return scoped_ptr<net::ClientCertStore>(new net::ClientCertStoreNSS(
857 base::Bind(&chrome::NewCryptoModuleBlockingDialogDelegate, 866 base::Bind(&CreateCryptoModuleBlockingPasswordDelegate,
858 chrome::kCryptoModulePasswordClientAuth))); 867 chrome::kCryptoModulePasswordClientAuth)));
859 #elif defined(OS_WIN) 868 #elif defined(OS_WIN)
860 return scoped_ptr<net::ClientCertStore>(new net::ClientCertStoreWin()); 869 return scoped_ptr<net::ClientCertStore>(new net::ClientCertStoreWin());
861 #elif defined(OS_MACOSX) 870 #elif defined(OS_MACOSX)
862 return scoped_ptr<net::ClientCertStore>(new net::ClientCertStoreMac()); 871 return scoped_ptr<net::ClientCertStore>(new net::ClientCertStoreMac());
863 #elif defined(USE_OPENSSL) 872 #elif defined(USE_OPENSSL)
864 // OpenSSL does not use the ClientCertStore infrastructure. On Android client 873 // OpenSSL does not use the ClientCertStore infrastructure. On Android client
865 // cert matching is done by the OS as part of the call to show the cert 874 // cert matching is done by the OS as part of the call to show the cert
866 // selection dialog. 875 // selection dialog.
867 return scoped_ptr<net::ClientCertStore>(); 876 return scoped_ptr<net::ClientCertStore>();
868 #else 877 #else
869 #error Unknown platform. 878 #error Unknown platform.
870 #endif 879 #endif
871 } 880 }
872 881
882 scoped_ptr<net::KeygenHandler>
883 ProfileIOData::ResourceContext::CreateKeygenHandler(
884 uint32 key_size_in_bits,
885 const std::string& challenge_string,
886 const GURL& url,
887 const base::Callback<void(scoped_ptr<net::KeygenHandler>)>& callback) {
888 DCHECK(!callback.is_null());
889 #if defined(USE_NSS)
890 // Store the KeygenHandler scoped_ptr on the heap, which will be Owned by
891 // the helper_callback below. This allows the KeygenHandler to be retrieved
892 // and returned directly in the synchronous success case.
893 scoped_ptr<net::KeygenHandler>* keygen_handler =
894 new scoped_ptr<net::KeygenHandler>(
895 new net::KeygenHandler(key_size_in_bits, challenge_string, url));
896
897 scoped_ptr<ChromeNSSCryptoModuleDelegate> delegate(
898 new ChromeNSSCryptoModuleDelegate(chrome::kCryptoModulePasswordKeygen,
899 url.host()));
900 ChromeNSSCryptoModuleDelegate* delegate_ptr = delegate.get();
901 (*keygen_handler)->set_crypto_module_delegate(
902 delegate.PassAs<crypto::NSSCryptoModuleDelegate>());
903
904 // Keep |helper_callback| on the stack, since ownership of
905 // |keygen_handler| is transferred to |helper_callback|. This allows
906 // |keygen_handler| to still be accessed if InitializeSlot returns with
907 // synchronous success.
908 base::Closure helper_callback = base::Bind(
909 &KeygenHandlerCallbackHelper, callback, base::Owned(keygen_handler));
910 if (delegate_ptr->InitializeSlot(this, helper_callback)) {
911 // Synchronous success, return the KeygenHandler directly.
912 return keygen_handler->Pass();
913 }
914 // The KeygenHandler will be passed to |callback| by
915 // KeygenHandlerCallbackHelper.
916 return scoped_ptr<net::KeygenHandler>();
917 #else
918 return scoped_ptr<net::KeygenHandler>(
919 new net::KeygenHandler(key_size_in_bits, challenge_string, url));
920 #endif
921 }
922
873 bool ProfileIOData::ResourceContext::AllowMicAccess(const GURL& origin) { 923 bool ProfileIOData::ResourceContext::AllowMicAccess(const GURL& origin) {
874 return AllowContentAccess(origin, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); 924 return AllowContentAccess(origin, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC);
875 } 925 }
876 926
877 bool ProfileIOData::ResourceContext::AllowCameraAccess(const GURL& origin) { 927 bool ProfileIOData::ResourceContext::AllowCameraAccess(const GURL& origin) {
878 return AllowContentAccess(origin, CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); 928 return AllowContentAccess(origin, CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
879 } 929 }
880 930
881 bool ProfileIOData::ResourceContext::AllowContentAccess( 931 bool ProfileIOData::ResourceContext::AllowContentAccess(
882 const GURL& origin, ContentSettingsType type) { 932 const GURL& origin, ContentSettingsType type) {
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 void ProfileIOData::SetCookieSettingsForTesting( 1201 void ProfileIOData::SetCookieSettingsForTesting(
1152 CookieSettings* cookie_settings) { 1202 CookieSettings* cookie_settings) {
1153 DCHECK(!cookie_settings_.get()); 1203 DCHECK(!cookie_settings_.get());
1154 cookie_settings_ = cookie_settings; 1204 cookie_settings_ = cookie_settings;
1155 } 1205 }
1156 1206
1157 void ProfileIOData::set_signin_names_for_testing( 1207 void ProfileIOData::set_signin_names_for_testing(
1158 SigninNamesOnIOThread* signin_names) { 1208 SigninNamesOnIOThread* signin_names) {
1159 signin_names_.reset(signin_names); 1209 signin_names_.reset(signin_names);
1160 } 1210 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698