diff options
32 files changed, 109 insertions, 108 deletions
diff --git a/android_webview/browser/aw_content_browser_client.cc b/android_webview/browser/aw_content_browser_client.cc index c590984..75a082a 100644 --- a/android_webview/browser/aw_content_browser_client.cc +++ b/android_webview/browser/aw_content_browser_client.cc @@ -348,7 +348,7 @@ void AwContentBrowserClient::SelectClientCertificate( net::SSLCertRequestInfo* cert_request_info, const base::Callback<void(net::X509Certificate*)>& callback) { LOG(WARNING) << "Client certificate request from " - << cert_request_info->host_and_port + << cert_request_info->host_and_port.ToString() << " rejected. (Client certificates not supported in WebView)"; callback.Run(NULL); } diff --git a/chrome/browser/certificate_manager_model.cc b/chrome/browser/certificate_manager_model.cc index 826a29a..4832cdb 100644 --- a/chrome/browser/certificate_manager_model.cc +++ b/chrome/browser/certificate_manager_model.cc @@ -32,7 +32,7 @@ void CertificateManagerModel::Refresh() { chrome::UnlockSlotsIfNecessary( modules, chrome::kCryptoModulePasswordListCerts, - std::string(), // unused. + net::HostPortPair(), // unused. NULL, // TODO(mattm): supply parent window. base::Bind(&CertificateManagerModel::RefreshSlotsUnlocked, base::Unretained(this))); diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index e25a503..9c23d5c 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -1815,9 +1815,10 @@ void ChromeContentBrowserClient::SelectClientCertificate( return; } - GURL requesting_url("https://" + cert_request_info->host_and_port); - DCHECK(requesting_url.is_valid()) << "Invalid URL string: https://" - << cert_request_info->host_and_port; + GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); + DCHECK(requesting_url.is_valid()) + << "Invalid URL string: https://" + << cert_request_info->host_and_port.ToString(); Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); scoped_ptr<Value> filter( diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index b0e4154..0a23eaf 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc @@ -889,7 +889,7 @@ void ProfileIOData::ResourceContext::CreateKeygenHandler( scoped_ptr<ChromeNSSCryptoModuleDelegate> delegate( new ChromeNSSCryptoModuleDelegate(chrome::kCryptoModulePasswordKeygen, - url.host())); + net::HostPortPair::FromURL(url))); ChromeNSSCryptoModuleDelegate* delegate_ptr = delegate.get(); keygen_handler->set_crypto_module_delegate( delegate.PassAs<crypto::NSSCryptoModuleDelegate>()); diff --git a/chrome/browser/ssl/ssl_client_auth_observer.cc b/chrome/browser/ssl/ssl_client_auth_observer.cc index 93a90c0..07d9274 100644 --- a/chrome/browser/ssl/ssl_client_auth_observer.cc +++ b/chrome/browser/ssl/ssl_client_auth_observer.cc @@ -60,7 +60,8 @@ void SSLClientAuthObserver::Observe( DCHECK(type == chrome::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED); CertDetails* cert_details = content::Details<CertDetails>(details).ptr(); - if (cert_details->first->host_and_port != cert_request_info_->host_and_port) + if (!cert_details->first->host_and_port.Equals( + cert_request_info_->host_and_port)) return; VLOG(1) << this << " got matching notification and selecting cert " diff --git a/chrome/browser/ssl/ssl_client_certificate_selector_test.cc b/chrome/browser/ssl/ssl_client_certificate_selector_test.cc index 429980b..f0a0918 100644 --- a/chrome/browser/ssl/ssl_client_certificate_selector_test.cc +++ b/chrome/browser/ssl/ssl_client_certificate_selector_test.cc @@ -44,7 +44,7 @@ void SSLClientCertificateSelectorTestBase::SetUpInProcessBrowserTestFixture() { ASSERT_TRUE(foaf_me_chromium_test_cert_.get()); cert_request_info_ = new net::SSLCertRequestInfo; - cert_request_info_->host_and_port = "foo:123"; + cert_request_info_->host_and_port = net::HostPortPair("foo", 123); cert_request_info_->client_certs.push_back(mit_davidben_cert_); cert_request_info_->client_certs.push_back(foaf_me_chromium_test_cert_); } diff --git a/chrome/browser/ui/android/ssl_client_certificate_request.cc b/chrome/browser/ui/android/ssl_client_certificate_request.cc index ea80270..468b53b 100644 --- a/chrome/browser/ui/android/ssl_client_certificate_request.cc +++ b/chrome/browser/ui/android/ssl_client_certificate_request.cc @@ -91,16 +91,9 @@ void StartClientCertificateRequest( // Build the |host_name| and |port| JNI parameters, as a String and // a jint. - net::HostPortPair host_and_port = - net::HostPortPair::FromString(cert_request_info->host_and_port); - ScopedJavaLocalRef<jstring> host_name_ref = - base::android::ConvertUTF8ToJavaString(env, host_and_port.host()); - if (host_name_ref.is_null()) { - LOG(ERROR) << "Could not extract host name from: '" - << cert_request_info->host_and_port << "'"; - return; - } + base::android::ConvertUTF8ToJavaString( + env, cert_request_info->host_and_port.host()); // Create a copy of the callback on the heap so that its address // and ownership can be passed through and returned from Java via JNI. @@ -112,7 +105,7 @@ void StartClientCertificateRequest( if (!chrome::android:: Java_SSLClientCertificateRequest_selectClientCertificate( env, request_id, key_types_ref.obj(), principals_ref.obj(), - host_name_ref.obj(), host_and_port.port())) { + host_name_ref.obj(), cert_request_info->host_and_port.port())) { return; } diff --git a/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.mm b/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.mm index 4598725..2a4830d 100644 --- a/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.mm +++ b/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.mm @@ -143,7 +143,7 @@ void ShowSSLClientCertificateSelector( // Get the message to display: NSString* message = l10n_util::GetNSStringF( IDS_CLIENT_CERT_DIALOG_TEXT, - ASCIIToUTF16(observer_->cert_request_info()->host_and_port)); + ASCIIToUTF16(observer_->cert_request_info()->host_and_port.ToString())); // Create and set up a system choose-identity panel. panel_.reset([[SFChooseIdentityPanel alloc] init]); diff --git a/chrome/browser/ui/crypto_module_delegate_nss.cc b/chrome/browser/ui/crypto_module_delegate_nss.cc index b52c6ca..1ee6a89 100644 --- a/chrome/browser/ui/crypto_module_delegate_nss.cc +++ b/chrome/browser/ui/crypto_module_delegate_nss.cc @@ -13,7 +13,7 @@ using content::BrowserThread; ChromeNSSCryptoModuleDelegate::ChromeNSSCryptoModuleDelegate( chrome::CryptoModulePasswordReason reason, - const std::string& server) + const net::HostPortPair& server) : reason_(reason), server_(server), event_(false, false), @@ -71,7 +71,7 @@ void ChromeNSSCryptoModuleDelegate::ShowDialog(const std::string& slot_name, slot_name, retry, reason_, - server_, + server_.host(), NULL, // TODO(mattm): Supply parent window. base::Bind(&ChromeNSSCryptoModuleDelegate::GotPassword, // RequestPassword is blocked on |event_| until GotPassword is @@ -96,7 +96,7 @@ void ChromeNSSCryptoModuleDelegate::DidGetSlot(const base::Closure& callback, crypto::CryptoModuleBlockingPasswordDelegate* CreateCryptoModuleBlockingPasswordDelegate( chrome::CryptoModulePasswordReason reason, - const std::string& server) { + const net::HostPortPair& server) { // Returns a ChromeNSSCryptoModuleDelegate without calling InitializeSlot. // Since it is only being used as a CreateCryptoModuleBlockingDialogDelegate, // initializing the slot handle is unnecessary. diff --git a/chrome/browser/ui/crypto_module_delegate_nss.h b/chrome/browser/ui/crypto_module_delegate_nss.h index c99af16..f3b7c37 100644 --- a/chrome/browser/ui/crypto_module_delegate_nss.h +++ b/chrome/browser/ui/crypto_module_delegate_nss.h @@ -11,6 +11,7 @@ #include "base/synchronization/waitable_event.h" #include "chrome/browser/ui/crypto_module_password_dialog.h" #include "crypto/nss_crypto_module_delegate.h" +#include "net/base/host_port_pair.h" namespace content { class ResourceContext; @@ -26,7 +27,7 @@ class ChromeNSSCryptoModuleDelegate // string to show the user, |server| is displayed to indicate which connection // is causing the dialog to appear. ChromeNSSCryptoModuleDelegate(chrome::CryptoModulePasswordReason reason, - const std::string& server); + const net::HostPortPair& server); virtual ~ChromeNSSCryptoModuleDelegate(); @@ -56,7 +57,7 @@ class ChromeNSSCryptoModuleDelegate // Parameters displayed in the dialog. const chrome::CryptoModulePasswordReason reason_; - const std::string server_; + net::HostPortPair server_; // Event to block worker thread while waiting for dialog on UI thread. base::WaitableEvent event_; @@ -75,6 +76,6 @@ class ChromeNSSCryptoModuleDelegate crypto::CryptoModuleBlockingPasswordDelegate* CreateCryptoModuleBlockingPasswordDelegate( chrome::CryptoModulePasswordReason reason, - const std::string& server); + const net::HostPortPair& server); #endif // CHROME_BROWSER_UI_CRYPTO_MODULE_DELEGATE_NSS_H_ diff --git a/chrome/browser/ui/crypto_module_password_dialog.h b/chrome/browser/ui/crypto_module_password_dialog.h index 16a9691..86dc087 100644 --- a/chrome/browser/ui/crypto_module_password_dialog.h +++ b/chrome/browser/ui/crypto_module_password_dialog.h @@ -26,13 +26,13 @@ typedef base::Callback<void(const std::string&)> CryptoModulePasswordCallback; // Display a dialog, prompting the user to authenticate to unlock // |module|. |reason| describes the purpose of the authentication and -// affects the message displayed in the dialog. |server| is the name +// affects the message displayed in the dialog. |hostname| is the hostname // of the server which requested the access. void ShowCryptoModulePasswordDialog( const std::string& module_name, bool retry, CryptoModulePasswordReason reason, - const std::string& server, + const std::string& hostname, gfx::NativeWindow parent, const CryptoModulePasswordCallback& callback); diff --git a/chrome/browser/ui/crypto_module_password_dialog_nss.cc b/chrome/browser/ui/crypto_module_password_dialog_nss.cc index 0f0587a..7c290da 100644 --- a/chrome/browser/ui/crypto_module_password_dialog_nss.cc +++ b/chrome/browser/ui/crypto_module_password_dialog_nss.cc @@ -29,7 +29,7 @@ class SlotUnlocker { public: SlotUnlocker(const net::CryptoModuleList& modules, chrome::CryptoModulePasswordReason reason, - const std::string& host, + const net::HostPortPair& server, gfx::NativeWindow parent, const base::Closure& callback); @@ -42,7 +42,7 @@ class SlotUnlocker { size_t current_; net::CryptoModuleList modules_; chrome::CryptoModulePasswordReason reason_; - std::string host_; + net::HostPortPair server_; gfx::NativeWindow parent_; base::Closure callback_; PRBool retry_; @@ -50,13 +50,13 @@ class SlotUnlocker { SlotUnlocker::SlotUnlocker(const net::CryptoModuleList& modules, chrome::CryptoModulePasswordReason reason, - const std::string& host, + const net::HostPortPair& server, gfx::NativeWindow parent, const base::Closure& callback) : current_(0), modules_(modules), reason_(reason), - host_(host), + server_(server), parent_(parent), callback_(callback), retry_(PR_FALSE) { @@ -72,7 +72,7 @@ void SlotUnlocker::Start() { modules_[current_]->GetTokenName(), retry_, reason_, - host_, + server_.host(), parent_, base::Bind(&SlotUnlocker::GotPassword, base::Unretained(this))); return; @@ -124,13 +124,13 @@ namespace chrome { void UnlockSlotsIfNecessary(const net::CryptoModuleList& modules, chrome::CryptoModulePasswordReason reason, - const std::string& host, + const net::HostPortPair& server, gfx::NativeWindow parent, const base::Closure& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); for (size_t i = 0; i < modules.size(); ++i) { if (ShouldShowDialog(modules[i].get())) { - (new SlotUnlocker(modules, reason, host, parent, callback))->Start(); + (new SlotUnlocker(modules, reason, server, parent, callback))->Start(); return; } } @@ -139,13 +139,13 @@ void UnlockSlotsIfNecessary(const net::CryptoModuleList& modules, void UnlockCertSlotIfNecessary(net::X509Certificate* cert, chrome::CryptoModulePasswordReason reason, - const std::string& host, + const net::HostPortPair& server, gfx::NativeWindow parent, const base::Closure& callback) { net::CryptoModuleList modules; modules.push_back(net::CryptoModule::CreateFromHandle( cert->os_cert_handle()->slot)); - UnlockSlotsIfNecessary(modules, reason, host, parent, callback); + UnlockSlotsIfNecessary(modules, reason, server, parent, callback); } } // namespace chrome diff --git a/chrome/browser/ui/crypto_module_password_dialog_nss.h b/chrome/browser/ui/crypto_module_password_dialog_nss.h index 2d1980b..6d871f3 100644 --- a/chrome/browser/ui/crypto_module_password_dialog_nss.h +++ b/chrome/browser/ui/crypto_module_password_dialog_nss.h @@ -11,6 +11,7 @@ #include "base/callback_forward.h" #include "base/memory/ref_counted.h" #include "chrome/browser/ui/crypto_module_password_dialog.h" +#include "net/base/host_port_pair.h" #include "ui/gfx/native_widget_types.h" namespace net { @@ -26,7 +27,7 @@ namespace chrome { // only be called on UI thread. void UnlockSlotsIfNecessary(const net::CryptoModuleList& modules, CryptoModulePasswordReason reason, - const std::string& server, + const net::HostPortPair& server, gfx::NativeWindow parent, const base::Closure& callback); @@ -35,7 +36,7 @@ void UnlockSlotsIfNecessary(const net::CryptoModuleList& modules, // Should only be called on UI thread. void UnlockCertSlotIfNecessary(net::X509Certificate* cert, CryptoModulePasswordReason reason, - const std::string& server, + const net::HostPortPair& server, gfx::NativeWindow parent, const base::Closure& callback); diff --git a/chrome/browser/ui/gtk/crypto_module_password_dialog_gtk.cc b/chrome/browser/ui/gtk/crypto_module_password_dialog_gtk.cc index e28516b..701958b 100644 --- a/chrome/browser/ui/gtk/crypto_module_password_dialog_gtk.cc +++ b/chrome/browser/ui/gtk/crypto_module_password_dialog_gtk.cc @@ -24,7 +24,7 @@ class CryptoModulePasswordDialog { const std::string& slot_name, bool retry, chrome::CryptoModulePasswordReason reason, - const std::string& server, + const std::string& hostname, gfx::NativeWindow parent, const chrome::CryptoModulePasswordCallback& callback); @@ -48,7 +48,7 @@ CryptoModulePasswordDialog::CryptoModulePasswordDialog( const std::string& slot_name, bool retry, chrome::CryptoModulePasswordReason reason, - const std::string& server, + const std::string& hostname, gfx::NativeWindow parent, const chrome::CryptoModulePasswordCallback& callback) : callback_(callback) { @@ -70,20 +70,22 @@ CryptoModulePasswordDialog::CryptoModulePasswordDialog( // Select an appropriate text for the reason. std::string text; - const base::string16& server16 = UTF8ToUTF16(server); + const base::string16& hostname16 = UTF8ToUTF16(hostname); const base::string16& slot16 = UTF8ToUTF16(slot_name); switch (reason) { case chrome::kCryptoModulePasswordKeygen: text = l10n_util::GetStringFUTF8( - IDS_CRYPTO_MODULE_AUTH_DIALOG_TEXT_KEYGEN, slot16, server16); + IDS_CRYPTO_MODULE_AUTH_DIALOG_TEXT_KEYGEN, slot16, hostname16); break; case chrome::kCryptoModulePasswordCertEnrollment: text = l10n_util::GetStringFUTF8( - IDS_CRYPTO_MODULE_AUTH_DIALOG_TEXT_CERT_ENROLLMENT, slot16, server16); + IDS_CRYPTO_MODULE_AUTH_DIALOG_TEXT_CERT_ENROLLMENT, + slot16, + hostname16); break; case chrome::kCryptoModulePasswordClientAuth: text = l10n_util::GetStringFUTF8( - IDS_CRYPTO_MODULE_AUTH_DIALOG_TEXT_CLIENT_AUTH, slot16, server16); + IDS_CRYPTO_MODULE_AUTH_DIALOG_TEXT_CLIENT_AUTH, slot16, hostname16); break; case chrome::kCryptoModulePasswordListCerts: text = l10n_util::GetStringFUTF8( @@ -157,11 +159,11 @@ void ShowCryptoModulePasswordDialog( const std::string& slot_name, bool retry, CryptoModulePasswordReason reason, - const std::string& server, + const std::string& hostname, gfx::NativeWindow parent, const CryptoModulePasswordCallback& callback) { (new CryptoModulePasswordDialog( - slot_name, retry, reason, server, parent, callback))->Show(); + slot_name, retry, reason, hostname, parent, callback))->Show(); } } // namespace chrome diff --git a/chrome/browser/ui/gtk/ssl_client_certificate_selector.cc b/chrome/browser/ui/gtk/ssl_client_certificate_selector.cc index 99cfba7..78b6fa2 100644 --- a/chrome/browser/ui/gtk/ssl_client_certificate_selector.cc +++ b/chrome/browser/ui/gtk/ssl_client_certificate_selector.cc @@ -120,7 +120,7 @@ SSLClientCertificateSelector::SSLClientCertificateSelector( FALSE, FALSE, 0); GtkWidget* site_label = gtk_label_new( - cert_request_info->host_and_port.c_str()); + cert_request_info->host_and_port.ToString().c_str()); gtk_util::LeftAlignMisc(site_label); gtk_box_pack_start(GTK_BOX(site_vbox), site_label, FALSE, FALSE, 0); diff --git a/chrome/browser/ui/views/crypto_module_password_dialog_view.cc b/chrome/browser/ui/views/crypto_module_password_dialog_view.cc index 041fad7..7bfa159 100644 --- a/chrome/browser/ui/views/crypto_module_password_dialog_view.cc +++ b/chrome/browser/ui/views/crypto_module_password_dialog_view.cc @@ -23,10 +23,10 @@ namespace chrome { CryptoModulePasswordDialogView::CryptoModulePasswordDialogView( const std::string& slot_name, CryptoModulePasswordReason reason, - const std::string& server, + const std::string& hostname, const CryptoModulePasswordCallback& callback) : callback_(callback) { - Init(server, slot_name, reason); + Init(hostname, slot_name, reason); } CryptoModulePasswordDialogView::~CryptoModulePasswordDialogView() { @@ -78,25 +78,27 @@ bool CryptoModulePasswordDialogView::HandleKeyEvent( return false; } -void CryptoModulePasswordDialogView::Init(const std::string& server, +void CryptoModulePasswordDialogView::Init(const std::string& hostname, const std::string& slot_name, CryptoModulePasswordReason reason) { // Select an appropriate text for the reason. std::string text; - const base::string16& server16 = UTF8ToUTF16(server); + const base::string16& hostname16 = UTF8ToUTF16(hostname); const base::string16& slot16 = UTF8ToUTF16(slot_name); switch (reason) { case chrome::kCryptoModulePasswordKeygen: text = l10n_util::GetStringFUTF8( - IDS_CRYPTO_MODULE_AUTH_DIALOG_TEXT_KEYGEN, slot16, server16); + IDS_CRYPTO_MODULE_AUTH_DIALOG_TEXT_KEYGEN, slot16, hostname16); break; case chrome::kCryptoModulePasswordCertEnrollment: text = l10n_util::GetStringFUTF8( - IDS_CRYPTO_MODULE_AUTH_DIALOG_TEXT_CERT_ENROLLMENT, slot16, server16); + IDS_CRYPTO_MODULE_AUTH_DIALOG_TEXT_CERT_ENROLLMENT, + slot16, + hostname16); break; case chrome::kCryptoModulePasswordClientAuth: text = l10n_util::GetStringFUTF8( - IDS_CRYPTO_MODULE_AUTH_DIALOG_TEXT_CLIENT_AUTH, slot16, server16); + IDS_CRYPTO_MODULE_AUTH_DIALOG_TEXT_CLIENT_AUTH, slot16, hostname16); break; case chrome::kCryptoModulePasswordListCerts: text = l10n_util::GetStringFUTF8( @@ -152,11 +154,11 @@ void ShowCryptoModulePasswordDialog( const std::string& slot_name, bool retry, CryptoModulePasswordReason reason, - const std::string& server, + const std::string& hostname, gfx::NativeWindow parent, const CryptoModulePasswordCallback& callback) { CryptoModulePasswordDialogView* dialog = - new CryptoModulePasswordDialogView(slot_name, reason, server, callback); + new CryptoModulePasswordDialogView(slot_name, reason, hostname, callback); views::DialogDelegate::CreateDialogWidget(dialog, NULL, parent)->Show(); } diff --git a/chrome/browser/ui/views/ssl_client_certificate_selector.cc b/chrome/browser/ui/views/ssl_client_certificate_selector.cc index 3e8b2f9..a97a0ac 100644 --- a/chrome/browser/ui/views/ssl_client_certificate_selector.cc +++ b/chrome/browser/ui/views/ssl_client_certificate_selector.cc @@ -130,7 +130,7 @@ void SSLClientCertificateSelector::Init() { layout->StartRow(0, column_set_id); base::string16 text = l10n_util::GetStringFUTF16( IDS_CLIENT_CERT_DIALOG_TEXT, - ASCIIToUTF16(cert_request_info()->host_and_port)); + ASCIIToUTF16(cert_request_info()->host_and_port.ToString())); views::Label* label = new views::Label(text); label->SetMultiLine(true); label->SetHorizontalAlignment(gfx::ALIGN_LEFT); diff --git a/chrome/browser/ui/views/ssl_client_certificate_selector_browsertest.cc b/chrome/browser/ui/views/ssl_client_certificate_selector_browsertest.cc index bc71798..3c61796 100644 --- a/chrome/browser/ui/views/ssl_client_certificate_selector_browsertest.cc +++ b/chrome/browser/ui/views/ssl_client_certificate_selector_browsertest.cc @@ -54,7 +54,7 @@ class SSLClientCertificateSelectorTest : public InProcessBrowserTest { foaf_me_chromium_test_cert_); cert_request_info_ = new net::SSLCertRequestInfo; - cert_request_info_->host_and_port = "foo:123"; + cert_request_info_->host_and_port = net::HostPortPair("foo", 123); cert_request_info_->client_certs.push_back(mit_davidben_cert_); cert_request_info_->client_certs.push_back(foaf_me_chromium_test_cert_); } @@ -136,12 +136,12 @@ class SSLClientCertificateSelectorMultiTabTest SSLClientCertificateSelectorTest::SetUpInProcessBrowserTestFixture(); cert_request_info_1_ = new net::SSLCertRequestInfo; - cert_request_info_1_->host_and_port = "bar:123"; + cert_request_info_1_->host_and_port = net::HostPortPair("bar", 123); cert_request_info_1_->client_certs.push_back(mit_davidben_cert_); cert_request_info_1_->client_certs.push_back(foaf_me_chromium_test_cert_); cert_request_info_2_ = new net::SSLCertRequestInfo; - cert_request_info_2_->host_and_port = "bar:123"; + cert_request_info_2_->host_and_port = net::HostPortPair("bar", 123); cert_request_info_2_->client_certs.push_back(mit_davidben_cert_); cert_request_info_2_->client_certs.push_back(foaf_me_chromium_test_cert_); } @@ -222,7 +222,7 @@ class SSLClientCertificateSelectorMultiProfileTest SSLClientCertificateSelectorTest::SetUpInProcessBrowserTestFixture(); cert_request_info_1_ = new net::SSLCertRequestInfo; - cert_request_info_1_->host_and_port = "foo:123"; + cert_request_info_1_->host_and_port = net::HostPortPair("foo", 123); cert_request_info_1_->client_certs.push_back(mit_davidben_cert_); cert_request_info_1_->client_certs.push_back(foaf_me_chromium_test_cert_); } diff --git a/chrome/browser/ui/webui/options/certificate_manager_handler.cc b/chrome/browser/ui/webui/options/certificate_manager_handler.cc index 691c354e..5a94a30 100644 --- a/chrome/browser/ui/webui/options/certificate_manager_handler.cc +++ b/chrome/browser/ui/webui/options/certificate_manager_handler.cc @@ -642,7 +642,7 @@ void CertificateManagerHandler::ExportPersonalPasswordSelected( chrome::UnlockCertSlotIfNecessary( selected_cert_list_[0].get(), chrome::kCryptoModulePasswordCertExport, - std::string(), // unused. + net::HostPortPair(), // unused. GetParentWindow(), base::Bind(&CertificateManagerHandler::ExportPersonalSlotsUnlocked, base::Unretained(this))); @@ -751,7 +751,7 @@ void CertificateManagerHandler::ImportPersonalFileRead( chrome::UnlockSlotsIfNecessary( modules, chrome::kCryptoModulePasswordCertImport, - std::string(), // unused. + net::HostPortPair(), // unused. GetParentWindow(), base::Bind(&CertificateManagerHandler::ImportPersonalSlotUnlocked, base::Unretained(this))); diff --git a/jingle/glue/proxy_resolving_client_socket.cc b/jingle/glue/proxy_resolving_client_socket.cc index d63411b..f0b98d0 100644 --- a/jingle/glue/proxy_resolving_client_socket.cc +++ b/jingle/glue/proxy_resolving_client_socket.cc @@ -266,7 +266,7 @@ int ProxyResolvingClientSocket::ReconsiderProxyAfterError(int error) { if (proxy_info_.is_https() && ssl_config_.send_client_cert) { network_session_->ssl_client_auth_cache()->Remove( - proxy_info_.proxy_server().host_port_pair().ToString()); + proxy_info_.proxy_server().host_port_pair()); } int rv = network_session_->proxy_service()->ReconsiderProxyAfterError( diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index 66d7364..a6d5069 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -1291,7 +1291,7 @@ void HttpNetworkTransaction::HandleClientAuthError(int error) { if (server_ssl_config_.send_client_cert && (error == ERR_SSL_PROTOCOL_ERROR || IsClientCertificateError(error))) { session_->ssl_client_auth_cache()->Remove( - GetHostAndPort(request_->url)); + HostPortPair::FromURL(request_->url)); } } diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc index dd9eefe..6df20ac 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -10130,7 +10130,7 @@ TEST_P(HttpNetworkTransactionTest, request_info.load_flags = net::LOAD_NORMAL; scoped_refptr<SSLCertRequestInfo> cert_request(new SSLCertRequestInfo()); - cert_request->host_and_port = "www.example.com:443"; + cert_request->host_and_port = HostPortPair("www.example.com", 443); // [ssl_]data1 contains the data for the first SSL handshake. When a // CertificateRequest is received for the first time, the handshake will @@ -10210,8 +10210,8 @@ TEST_P(HttpNetworkTransactionTest, // Ensure the certificate was added to the client auth cache before // allowing the connection to continue restarting. scoped_refptr<X509Certificate> client_cert; - ASSERT_TRUE(session->ssl_client_auth_cache()->Lookup("www.example.com:443", - &client_cert)); + ASSERT_TRUE(session->ssl_client_auth_cache()->Lookup( + HostPortPair("www.example.com", 443), &client_cert)); ASSERT_EQ(NULL, client_cert.get()); // Restart the handshake. This will consume ssl_data2, which fails, and @@ -10222,8 +10222,8 @@ TEST_P(HttpNetworkTransactionTest, // Ensure that the client certificate is removed from the cache on a // handshake failure. - ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup("www.example.com:443", - &client_cert)); + ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup( + HostPortPair("www.example.com", 443), &client_cert)); } // Ensure that a client certificate is removed from the SSL client auth @@ -10240,7 +10240,7 @@ TEST_P(HttpNetworkTransactionTest, request_info.load_flags = net::LOAD_NORMAL; scoped_refptr<SSLCertRequestInfo> cert_request(new SSLCertRequestInfo()); - cert_request->host_and_port = "www.example.com:443"; + cert_request->host_and_port = HostPortPair("www.example.com", 443); // When TLS False Start is used, SSLClientSocket::Connect() calls will // return successfully after reading up to the peer's Certificate message. @@ -10331,8 +10331,8 @@ TEST_P(HttpNetworkTransactionTest, // Ensure the certificate was added to the client auth cache before // allowing the connection to continue restarting. scoped_refptr<X509Certificate> client_cert; - ASSERT_TRUE(session->ssl_client_auth_cache()->Lookup("www.example.com:443", - &client_cert)); + ASSERT_TRUE(session->ssl_client_auth_cache()->Lookup( + HostPortPair("www.example.com", 443), &client_cert)); ASSERT_EQ(NULL, client_cert.get()); // Restart the handshake. This will consume ssl_data2, which fails, and @@ -10343,8 +10343,8 @@ TEST_P(HttpNetworkTransactionTest, // Ensure that the client certificate is removed from the cache on a // handshake failure. - ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup("www.example.com:443", - &client_cert)); + ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup( + HostPortPair("www.example.com", 443), &client_cert)); } // Ensure that a client certificate is removed from the SSL client auth @@ -10362,7 +10362,7 @@ TEST_P(HttpNetworkTransactionTest, ClientAuthCertCache_Proxy_Fail) { session_deps_.net_log = log.bound().net_log(); scoped_refptr<SSLCertRequestInfo> cert_request(new SSLCertRequestInfo()); - cert_request->host_and_port = "proxy:70"; + cert_request->host_and_port = HostPortPair("proxy", 70); // See ClientAuthCertCache_Direct_NoFalseStart for the explanation of // [ssl_]data[1-3]. Rather than represending the endpoint @@ -10425,13 +10425,13 @@ TEST_P(HttpNetworkTransactionTest, ClientAuthCertCache_Proxy_Fail) { // Ensure the certificate was added to the client auth cache before // allowing the connection to continue restarting. scoped_refptr<X509Certificate> client_cert; - ASSERT_TRUE(session->ssl_client_auth_cache()->Lookup("proxy:70", - &client_cert)); + ASSERT_TRUE(session->ssl_client_auth_cache()->Lookup( + HostPortPair("proxy", 70), &client_cert)); ASSERT_EQ(NULL, client_cert.get()); // Ensure the certificate was NOT cached for the endpoint. This only // applies to HTTPS requests, but is fine to check for HTTP requests. - ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup("www.example.com:443", - &client_cert)); + ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup( + HostPortPair("www.example.com", 443), &client_cert)); // Restart the handshake. This will consume ssl_data2, which fails, and // then consume ssl_data3, which should also fail. The result code is @@ -10441,10 +10441,10 @@ TEST_P(HttpNetworkTransactionTest, ClientAuthCertCache_Proxy_Fail) { // Now that the new handshake has failed, ensure that the client // certificate was removed from the client auth cache. - ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup("proxy:70", - &client_cert)); - ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup("www.example.com:443", - &client_cert)); + ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup( + HostPortPair("proxy", 70), &client_cert)); + ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup( + HostPortPair("www.example.com", 443), &client_cert)); } } diff --git a/net/http/http_stream_factory_impl_job.cc b/net/http/http_stream_factory_impl_job.cc index c86bee7..d60c522 100644 --- a/net/http/http_stream_factory_impl_job.cc +++ b/net/http/http_stream_factory_impl_job.cc @@ -1338,7 +1338,7 @@ int HttpStreamFactoryImpl::Job::ReconsiderProxyAfterError(int error) { if (proxy_info_.is_https() && proxy_ssl_config_.send_client_cert) { session_->ssl_client_auth_cache()->Remove( - proxy_info_.proxy_server().host_port_pair().ToString()); + proxy_info_.proxy_server().host_port_pair()); } int rv = session_->proxy_service()->ReconsiderProxyAfterError( diff --git a/net/socket/ssl_client_socket_nss.cc b/net/socket/ssl_client_socket_nss.cc index dbf64af..5df2fd0 100644 --- a/net/socket/ssl_client_socket_nss.cc +++ b/net/socket/ssl_client_socket_nss.cc @@ -2875,8 +2875,7 @@ bool SSLClientSocketNSS::GetSSLInfo(SSLInfo* ssl_info) { void SSLClientSocketNSS::GetSSLCertRequestInfo( SSLCertRequestInfo* cert_request_info) { EnterFunction(""); - // TODO(rch): switch SSLCertRequestInfo.host_and_port to a HostPortPair - cert_request_info->host_and_port = host_and_port_.ToString(); + cert_request_info->host_and_port = host_and_port_; cert_request_info->cert_authorities = core_->state().cert_authorities; LeaveFunction(""); } diff --git a/net/socket/ssl_client_socket_openssl.cc b/net/socket/ssl_client_socket_openssl.cc index 4c426e3..effd9c0 100644 --- a/net/socket/ssl_client_socket_openssl.cc +++ b/net/socket/ssl_client_socket_openssl.cc @@ -366,7 +366,7 @@ SSLClientSocketOpenSSL::~SSLClientSocketOpenSSL() { void SSLClientSocketOpenSSL::GetSSLCertRequestInfo( SSLCertRequestInfo* cert_request_info) { - cert_request_info->host_and_port = host_and_port_.ToString(); + cert_request_info->host_and_port = host_and_port_; cert_request_info->cert_authorities = cert_authorities_; } diff --git a/net/ssl/client_cert_store_mac.cc b/net/ssl/client_cert_store_mac.cc index 746d123..06d7d06 100644 --- a/net/ssl/client_cert_store_mac.cc +++ b/net/ssl/client_cert_store_mac.cc @@ -179,8 +179,7 @@ ClientCertStoreMac::~ClientCertStoreMac() {} void ClientCertStoreMac::GetClientCerts(const SSLCertRequestInfo& request, CertificateList* selected_certs, const base::Closure& callback) { - std::string server_domain = - HostPortPair::FromString(request.host_and_port).host(); + std::string server_domain = request.host_and_port.host(); ScopedCFTypeRef<SecIdentityRef> preferred_identity; if (!server_domain.empty()) { diff --git a/net/ssl/client_cert_store_nss.h b/net/ssl/client_cert_store_nss.h index c2a9611..4e2e1c4 100644 --- a/net/ssl/client_cert_store_nss.h +++ b/net/ssl/client_cert_store_nss.h @@ -23,7 +23,7 @@ namespace net { class NET_EXPORT ClientCertStoreNSS : public ClientCertStore { public: typedef base::Callback<crypto::CryptoModuleBlockingPasswordDelegate*( - const std::string& /* server */)> PasswordDelegateFactory; + const HostPortPair& /* server */)> PasswordDelegateFactory; explicit ClientCertStoreNSS( const PasswordDelegateFactory& password_delegate_factory); diff --git a/net/ssl/ssl_cert_request_info.cc b/net/ssl/ssl_cert_request_info.cc index 10750b6..e76aa45 100644 --- a/net/ssl/ssl_cert_request_info.cc +++ b/net/ssl/ssl_cert_request_info.cc @@ -12,7 +12,7 @@ SSLCertRequestInfo::SSLCertRequestInfo() : is_proxy(false) { } void SSLCertRequestInfo::Reset() { - host_and_port.clear(); + host_and_port = HostPortPair(); is_proxy = false; cert_authorities.clear(); cert_key_types.clear(); diff --git a/net/ssl/ssl_cert_request_info.h b/net/ssl/ssl_cert_request_info.h index fecffb8..13f91d6 100644 --- a/net/ssl/ssl_cert_request_info.h +++ b/net/ssl/ssl_cert_request_info.h @@ -9,6 +9,7 @@ #include <vector> #include "base/memory/ref_counted.h" +#include "net/base/host_port_pair.h" #include "net/base/net_export.h" #include "net/ssl/ssl_client_cert_type.h" @@ -41,7 +42,7 @@ class NET_EXPORT SSLCertRequestInfo void Reset(); // The host and port of the SSL server that requested client authentication. - std::string host_and_port; + HostPortPair host_and_port; // True if the server that issues this request was the HTTPS proxy used in // the request. False, if the server was the origin server. diff --git a/net/ssl/ssl_client_auth_cache.cc b/net/ssl/ssl_client_auth_cache.cc index 0c0704e..4c6b0d8 100644 --- a/net/ssl/ssl_client_auth_cache.cc +++ b/net/ssl/ssl_client_auth_cache.cc @@ -18,7 +18,7 @@ SSLClientAuthCache::~SSLClientAuthCache() { } bool SSLClientAuthCache::Lookup( - const std::string& server, + const HostPortPair& server, scoped_refptr<X509Certificate>* certificate) { DCHECK(certificate); @@ -30,14 +30,14 @@ bool SSLClientAuthCache::Lookup( return true; } -void SSLClientAuthCache::Add(const std::string& server, +void SSLClientAuthCache::Add(const HostPortPair& server, X509Certificate* value) { cache_[server] = value; // TODO(wtc): enforce a maximum number of entries. } -void SSLClientAuthCache::Remove(const std::string& server) { +void SSLClientAuthCache::Remove(const HostPortPair& server) { cache_.erase(server); } diff --git a/net/ssl/ssl_client_auth_cache.h b/net/ssl/ssl_client_auth_cache.h index 250841b..93ad8c0 100644 --- a/net/ssl/ssl_client_auth_cache.h +++ b/net/ssl/ssl_client_auth_cache.h @@ -10,6 +10,7 @@ #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" +#include "net/base/host_port_pair.h" #include "net/base/net_export.h" #include "net/cert/cert_database.h" @@ -34,23 +35,23 @@ class NET_EXPORT_PRIVATE SSLClientAuthCache : public CertDatabase::Observer { // desired client certificate. The desired certificate may be NULL, which // indicates a preference to not send any certificate to |server|. // If a certificate preference is not found, returns false. - bool Lookup(const std::string& server, + bool Lookup(const HostPortPair& server, scoped_refptr<X509Certificate>* certificate); // Add a client certificate for |server| to the cache. If there is already // a client certificate for |server|, it will be overwritten. A NULL // |client_cert| indicates a preference that no client certificate should // be sent to |server|. - void Add(const std::string& server, X509Certificate* client_cert); + void Add(const HostPortPair& server, X509Certificate* client_cert); // Remove the client certificate for |server| from the cache, if one exists. - void Remove(const std::string& server); + void Remove(const HostPortPair& server); // CertDatabase::Observer methods: virtual void OnCertAdded(const X509Certificate* cert) OVERRIDE; private: - typedef std::string AuthCacheKey; + typedef HostPortPair AuthCacheKey; typedef scoped_refptr<X509Certificate> AuthCacheValue; typedef std::map<AuthCacheKey, AuthCacheValue> AuthCacheMap; diff --git a/net/ssl/ssl_client_auth_cache_unittest.cc b/net/ssl/ssl_client_auth_cache_unittest.cc index 6b4b8c3..284fb46 100644 --- a/net/ssl/ssl_client_auth_cache_unittest.cc +++ b/net/ssl/ssl_client_auth_cache_unittest.cc @@ -16,15 +16,15 @@ TEST(SSLClientAuthCacheTest, LookupAddRemove) { base::Time start_date = base::Time::Now(); base::Time expiration_date = start_date + base::TimeDelta::FromDays(1); - std::string server1("foo1:443"); + HostPortPair server1("foo1", 443); scoped_refptr<X509Certificate> cert1( new X509Certificate("foo1", "CA", start_date, expiration_date)); - std::string server2("foo2:443"); + HostPortPair server2("foo2", 443); scoped_refptr<X509Certificate> cert2( new X509Certificate("foo2", "CA", start_date, expiration_date)); - std::string server3("foo3:443"); + HostPortPair server3("foo3", 443); scoped_refptr<X509Certificate> cert3( new X509Certificate("foo3", "CA", start_date, expiration_date)); @@ -82,11 +82,11 @@ TEST(SSLClientAuthCacheTest, LookupWithPort) { base::Time start_date = base::Time::Now(); base::Time expiration_date = start_date + base::TimeDelta::FromDays(1); - std::string server1("foo:443"); + HostPortPair server1("foo", 443); scoped_refptr<X509Certificate> cert1( new X509Certificate("foo", "CA", start_date, expiration_date)); - std::string server2("foo:8443"); + HostPortPair server2("foo", 8443); scoped_refptr<X509Certificate> cert2( new X509Certificate("foo", "CA", start_date, expiration_date)); @@ -107,7 +107,7 @@ TEST(SSLClientAuthCacheTest, LookupNullPreference) { base::Time start_date = base::Time::Now(); base::Time expiration_date = start_date + base::TimeDelta::FromDays(1); - std::string server1("foo:443"); + HostPortPair server1("foo", 443); scoped_refptr<X509Certificate> cert1( new X509Certificate("foo", "CA", start_date, expiration_date)); @@ -143,13 +143,13 @@ TEST(SSLClientAuthCacheTest, OnCertAdded) { base::Time start_date = base::Time::Now(); base::Time expiration_date = start_date + base::TimeDelta::FromDays(1); - std::string server1("foo:443"); + HostPortPair server1("foo", 443); scoped_refptr<X509Certificate> cert1( new X509Certificate("foo", "CA", start_date, expiration_date)); cache.Add(server1, cert1.get()); - std::string server2("foo2:443"); + HostPortPair server2("foo2", 443); cache.Add(server2, NULL); scoped_refptr<X509Certificate> cached_cert; |