summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-13 21:19:40 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-13 21:19:40 +0000
commit7a593db3f93fc3ca3bb51d96ba32694b8568a0df (patch)
tree46f6f091ed336d593e84d1a018ff12d49e0ec3bd /content
parenta2a220bbd154837c4f9e6eaf3e715cbe2ba9362c (diff)
downloadchromium_src-7a593db3f93fc3ca3bb51d96ba32694b8568a0df.zip
chromium_src-7a593db3f93fc3ca3bb51d96ba32694b8568a0df.tar.gz
chromium_src-7a593db3f93fc3ca3bb51d96ba32694b8568a0df.tar.bz2
Remove knowledge about SSLClientAuthHandler from chrome. Instead a callback is given to the embedder to be run when the certificate is available.
BUG=98716 Review URL: https://chromiumcodereview.appspot.com/9384014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121733 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/mock_content_browser_client.cc4
-rw-r--r--content/browser/mock_content_browser_client.h4
-rw-r--r--content/browser/ssl/ssl_client_auth_handler.cc75
-rw-r--r--content/browser/ssl/ssl_client_auth_handler.h50
-rw-r--r--content/browser/ssl/ssl_client_auth_handler_mock.cc16
-rw-r--r--content/browser/ssl/ssl_client_auth_handler_mock.h26
-rw-r--r--content/browser/ssl/ssl_client_auth_notification_details.cc28
-rw-r--r--content/browser/ssl/ssl_client_auth_notification_details.h36
-rw-r--r--content/content_browser.gypi2
-rw-r--r--content/public/browser/content_browser_client.h11
-rw-r--r--content/public/browser/notification_types.h7
-rw-r--r--content/shell/shell_content_browser_client.cc4
-rw-r--r--content/shell/shell_content_browser_client.h4
13 files changed, 23 insertions, 244 deletions
diff --git a/content/browser/mock_content_browser_client.cc b/content/browser/mock_content_browser_client.cc
index 3d96df6f..f5c2065 100644
--- a/content/browser/mock_content_browser_client.cc
+++ b/content/browser/mock_content_browser_client.cc
@@ -179,7 +179,9 @@ void MockContentBrowserClient::AllowCertificateError(
void MockContentBrowserClient::SelectClientCertificate(
int render_process_id,
int render_view_id,
- SSLClientAuthHandler* handler) {
+ const net::HttpNetworkSession* network_session,
+ net::SSLCertRequestInfo* cert_request_info,
+ const base::Callback<void(net::X509Certificate*)>& callback) {
}
void MockContentBrowserClient::AddNewCertificate(
diff --git a/content/browser/mock_content_browser_client.h b/content/browser/mock_content_browser_client.h
index a049ec8..a2380f6 100644
--- a/content/browser/mock_content_browser_client.h
+++ b/content/browser/mock_content_browser_client.h
@@ -95,7 +95,9 @@ class MockContentBrowserClient : public ContentBrowserClient {
virtual void SelectClientCertificate(
int render_process_id,
int render_view_id,
- SSLClientAuthHandler* handler) OVERRIDE;
+ const net::HttpNetworkSession* network_session,
+ net::SSLCertRequestInfo* cert_request_info,
+ const base::Callback<void(net::X509Certificate*)>& callback) OVERRIDE;
virtual void AddNewCertificate(
net::URLRequest* request,
net::X509Certificate* cert,
diff --git a/content/browser/ssl/ssl_client_auth_handler.cc b/content/browser/ssl/ssl_client_auth_handler.cc
index 03db71a..09e07cb 100644
--- a/content/browser/ssl/ssl_client_auth_handler.cc
+++ b/content/browser/ssl/ssl_client_auth_handler.cc
@@ -7,10 +7,8 @@
#include "base/bind.h"
#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/browser/renderer_host/resource_dispatcher_host_request_info.h"
-#include "content/browser/ssl/ssl_client_auth_notification_details.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
-#include "content/public/browser/notification_service.h"
#include "net/base/x509_certificate.h"
#include "net/http/http_transaction_factory.h"
#include "net/url_request/url_request.h"
@@ -58,27 +56,10 @@ void SSLClientAuthHandler::SelectCertificate() {
render_process_host_id, render_view_host_id));
}
-// Sends an SSL_CLIENT_AUTH_CERT_SELECTED notification and notifies the IO
-// thread that we have selected a cert.
void SSLClientAuthHandler::CertificateSelected(net::X509Certificate* cert) {
- VLOG(1) << this << " CertificateSelected " << cert;
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- SSLClientAuthNotificationDetails details(cert_request_info_, this, cert);
- content::NotificationService* service =
- content::NotificationService::current();
- service->Notify(content::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED,
- content::Source<net::HttpNetworkSession>(
- http_network_session()),
- content::Details<SSLClientAuthNotificationDetails>(&details));
-
- CertificateSelectedNoNotify(cert);
-}
-
-// Notifies the IO thread that we have selected a cert.
-void SSLClientAuthHandler::CertificateSelectedNoNotify(
- net::X509Certificate* cert) {
- VLOG(1) << this << " CertificateSelectedNoNotify " << cert;
+ VLOG(1) << this << " CertificateSelected " << cert;
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(
@@ -107,55 +88,7 @@ void SSLClientAuthHandler::DoCertificateSelected(net::X509Certificate* cert) {
void SSLClientAuthHandler::DoSelectCertificate(
int render_process_host_id, int render_view_host_id) {
content::GetContentClient()->browser()->SelectClientCertificate(
- render_process_host_id, render_view_host_id, this);
-}
-
-SSLClientAuthObserver::SSLClientAuthObserver(
- net::SSLCertRequestInfo* cert_request_info,
- SSLClientAuthHandler* handler)
- : cert_request_info_(cert_request_info), handler_(handler) {
-}
-
-SSLClientAuthObserver::~SSLClientAuthObserver() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-}
-
-void SSLClientAuthObserver::Observe(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- VLOG(1) << "SSLClientAuthObserver::Observe " << this << " " << handler_.get();
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(type == content::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED);
-
- SSLClientAuthNotificationDetails* auth_details =
- content::Details<SSLClientAuthNotificationDetails>(details).ptr();
-
- if (auth_details->IsSameHandler(handler_.get())) {
- VLOG(1) << "got notification from ourself " << handler_.get();
- return;
- }
-
- if (!auth_details->IsSameHost(cert_request_info_))
- return;
-
- VLOG(1) << this << " got matching notification for "
- << handler_.get() << ", selecting cert "
- << auth_details->selected_cert();
- StopObserving();
- handler_->CertificateSelectedNoNotify(auth_details->selected_cert());
- OnCertSelectedByNotification();
-}
-
-void SSLClientAuthObserver::StartObserving() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- notification_registrar_.Add(
- this, content::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED,
- content::Source<net::HttpNetworkSession>(
- handler_->http_network_session()));
-}
-
-void SSLClientAuthObserver::StopObserving() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- notification_registrar_.RemoveAll();
+ render_process_host_id, render_view_host_id, http_network_session_,
+ cert_request_info_,
+ base::Bind(&SSLClientAuthHandler::CertificateSelected, this));
}
diff --git a/content/browser/ssl/ssl_client_auth_handler.h b/content/browser/ssl/ssl_client_auth_handler.h
index a5893dc..0461d27 100644
--- a/content/browser/ssl/ssl_client_auth_handler.h
+++ b/content/browser/ssl/ssl_client_auth_handler.h
@@ -11,8 +11,6 @@
#include "base/message_loop_helpers.h"
#include "content/common/content_export.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/notification_observer.h"
-#include "content/public/browser/notification_registrar.h"
#include "net/base/ssl_cert_request_info.h"
namespace net {
@@ -45,19 +43,6 @@ class CONTENT_EXPORT SSLClientAuthHandler
// be long after DoSelectCertificate returns, if the UI is modeless/async.)
void CertificateSelected(net::X509Certificate* cert);
- // Like CertificateSelected, but does not send SSL_CLIENT_AUTH_CERT_SELECTED
- // notification. Used to avoid notification re-spamming when other
- // certificate selectors act on a notification matching the same host.
- virtual void CertificateSelectedNoNotify(net::X509Certificate* cert);
-
- // Returns the SSLCertRequestInfo for this handler.
- net::SSLCertRequestInfo* cert_request_info() { return cert_request_info_; }
-
- // Returns the session the URL request is associated with.
- const net::HttpNetworkSession* http_network_session() const {
- return http_network_session_;
- }
-
protected:
virtual ~SSLClientAuthHandler();
@@ -87,39 +72,4 @@ class CONTENT_EXPORT SSLClientAuthHandler
DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandler);
};
-class CONTENT_EXPORT SSLClientAuthObserver
- : public content::NotificationObserver {
- public:
- SSLClientAuthObserver(net::SSLCertRequestInfo* cert_request_info,
- SSLClientAuthHandler* handler);
- virtual ~SSLClientAuthObserver();
-
- // UI should implement this to close the dialog.
- virtual void OnCertSelectedByNotification() = 0;
-
- // content::NotificationObserver implementation:
- virtual void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) OVERRIDE;
-
- // Begins observing notifications from other SSLClientAuthHandler instances.
- // If another instance chooses a cert for a matching SSLCertRequestInfo, we
- // will also use the same cert and OnCertSelectedByNotification will be called
- // so that the cert selection UI can be closed.
- void StartObserving();
-
- // Stops observing notifications. We will no longer act on client auth
- // notifications.
- void StopObserving();
-
- private:
- scoped_refptr<net::SSLCertRequestInfo> cert_request_info_;
-
- scoped_refptr<SSLClientAuthHandler> handler_;
-
- content::NotificationRegistrar notification_registrar_;
-
- DISALLOW_COPY_AND_ASSIGN(SSLClientAuthObserver);
-};
-
#endif // CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_
diff --git a/content/browser/ssl/ssl_client_auth_handler_mock.cc b/content/browser/ssl/ssl_client_auth_handler_mock.cc
deleted file mode 100644
index 4bc41a7..0000000
--- a/content/browser/ssl/ssl_client_auth_handler_mock.cc
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/browser/ssl/ssl_client_auth_handler_mock.h"
-
-SSLClientAuthHandlerMock::SSLClientAuthHandlerMock(
- net::URLRequest* request,
- net::SSLCertRequestInfo* cert_request_info)
- : SSLClientAuthHandler(request, cert_request_info) {
-}
-
-SSLClientAuthHandlerMock::~SSLClientAuthHandlerMock() {
- // Hack to avoid destructor calling request_->ContinueWithCertificate.
- OnRequestCancelled();
-}
diff --git a/content/browser/ssl/ssl_client_auth_handler_mock.h b/content/browser/ssl/ssl_client_auth_handler_mock.h
deleted file mode 100644
index 33e14ab..0000000
--- a/content/browser/ssl/ssl_client_auth_handler_mock.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_MOCK_H_
-#define CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_MOCK_H_
-#pragma once
-
-#include "content/browser/ssl/ssl_client_auth_handler.h"
-#include "testing/gmock/include/gmock/gmock.h"
-
-class SSLClientAuthHandlerMock : public SSLClientAuthHandler {
- public:
- SSLClientAuthHandlerMock(
- net::URLRequest* request,
- net::SSLCertRequestInfo* cert_request_info);
- ~SSLClientAuthHandlerMock();
-
- MOCK_METHOD1(CertificateSelectedNoNotify, void(net::X509Certificate* cert));
-
- private:
- DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandlerMock);
-};
-
-
-#endif // CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_MOCK_H_
diff --git a/content/browser/ssl/ssl_client_auth_notification_details.cc b/content/browser/ssl/ssl_client_auth_notification_details.cc
deleted file mode 100644
index e5f4dc3..0000000
--- a/content/browser/ssl/ssl_client_auth_notification_details.cc
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/browser/ssl/ssl_client_auth_notification_details.h"
-
-#include "net/base/ssl_cert_request_info.h"
-
-SSLClientAuthNotificationDetails::SSLClientAuthNotificationDetails(
- const net::SSLCertRequestInfo* cert_request_info,
- const SSLClientAuthHandler* handler,
- net::X509Certificate* selected_cert)
- : cert_request_info_(cert_request_info),
- handler_(handler),
- selected_cert_(selected_cert) {
-}
-
-bool SSLClientAuthNotificationDetails::IsSameHost(
- const net::SSLCertRequestInfo* cert_request_info) const {
- // TODO(mattm): should we also compare the DistinguishedNames, or is just
- // matching host&port sufficient?
- return cert_request_info_->host_and_port == cert_request_info->host_and_port;
-}
-
-bool SSLClientAuthNotificationDetails::IsSameHandler(
- const SSLClientAuthHandler* handler) const {
- return handler_ == handler;
-}
diff --git a/content/browser/ssl/ssl_client_auth_notification_details.h b/content/browser/ssl/ssl_client_auth_notification_details.h
deleted file mode 100644
index d33bbc0..0000000
--- a/content/browser/ssl/ssl_client_auth_notification_details.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_NOTIFICATION_DETAILS_H_
-#define CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_NOTIFICATION_DETAILS_H_
-
-#include "base/basictypes.h"
-
-namespace net {
-class X509Certificate;
-class SSLCertRequestInfo;
-}
-class SSLClientAuthHandler;
-
-class SSLClientAuthNotificationDetails {
- public:
- SSLClientAuthNotificationDetails(
- const net::SSLCertRequestInfo* cert_request_info,
- const SSLClientAuthHandler* handler,
- net::X509Certificate* selected_cert);
-
- bool IsSameHost(const net::SSLCertRequestInfo* cert_request_info) const;
- bool IsSameHandler(const SSLClientAuthHandler* handler) const;
- net::X509Certificate* selected_cert() const { return selected_cert_; }
-
- private:
- // Notifications are synchronous, so we don't need to hold our own references.
- const net::SSLCertRequestInfo* cert_request_info_;
- const SSLClientAuthHandler* handler_;
- net::X509Certificate* selected_cert_;
-
- DISALLOW_COPY_AND_ASSIGN(SSLClientAuthNotificationDetails);
-};
-
-#endif // CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_NOTIFICATION_DETAILS_H_
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index 418832d..694c666 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -606,8 +606,6 @@
'browser/ssl/ssl_cert_error_handler.h',
'browser/ssl/ssl_client_auth_handler.cc',
'browser/ssl/ssl_client_auth_handler.h',
- 'browser/ssl/ssl_client_auth_notification_details.cc',
- 'browser/ssl/ssl_client_auth_notification_details.h',
'browser/ssl/ssl_error_handler.cc',
'browser/ssl/ssl_error_handler.h',
'browser/ssl/ssl_host_state.cc',
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
index 9be8e58..400599a 100644
--- a/content/public/browser/content_browser_client.h
+++ b/content/public/browser/content_browser_client.h
@@ -24,7 +24,6 @@ class PluginProcessHost;
class QuotaPermissionContext;
class RenderViewHost;
class ResourceDispatcherHost;
-class SSLClientAuthHandler;
class SkBitmap;
struct WebPreferences;
@@ -46,7 +45,9 @@ class CryptoModuleBlockingPasswordDelegate;
namespace net {
class CookieList;
class CookieOptions;
+class HttpNetworkSession;
class NetLog;
+class SSLCertRequestInfo;
class SSLInfo;
class URLRequest;
class URLRequestContext;
@@ -232,12 +233,14 @@ class ContentBrowserClient {
const base::Callback<void(bool)>& callback,
bool* cancel_request) = 0;
- // Selects a SSL client certificate and returns it to the |handler|. If no
- // certificate was selected NULL is returned to the |handler|.
+ // Selects a SSL client certificate and returns it to the |callback|. If no
+ // certificate was selected NULL is returned to the |callback|.
virtual void SelectClientCertificate(
int render_process_id,
int render_view_id,
- SSLClientAuthHandler* handler) = 0;
+ const net::HttpNetworkSession* network_session,
+ net::SSLCertRequestInfo* cert_request_info,
+ const base::Callback<void(net::X509Certificate*)>& callback) = 0;
// Adds a downloaded client cert. The embedder should ensure that there's
// a private key for the cert, displays the cert to the user, and adds it upon
diff --git a/content/public/browser/notification_types.h b/content/public/browser/notification_types.h
index f51a926..b7b45ce 100644
--- a/content/public/browser/notification_types.h
+++ b/content/public/browser/notification_types.h
@@ -153,13 +153,6 @@ enum NotificationType {
// controller associated with the state change.
NOTIFICATION_SSL_INTERNAL_STATE_CHANGED,
- // The user accepted or dismissed a SSL client authentication request.
- // The source is a Source<SSLClientAuthHandler>. Details is a
- // SSLClientAuthNotificationDetails which records specifies which
- // SSLCertRequestInfo the request was for and which X509Certificate was
- // selected (if any).
- NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED,
-
#if defined(OS_MACOSX)
// This message is sent when the application is made active (Mac OS X only
// at present). No source or details are passed.
diff --git a/content/shell/shell_content_browser_client.cc b/content/shell/shell_content_browser_client.cc
index 154fd73..b4c9e43 100644
--- a/content/shell/shell_content_browser_client.cc
+++ b/content/shell/shell_content_browser_client.cc
@@ -204,7 +204,9 @@ void ShellContentBrowserClient::AllowCertificateError(
void ShellContentBrowserClient::SelectClientCertificate(
int render_process_id,
int render_view_id,
- SSLClientAuthHandler* handler) {
+ const net::HttpNetworkSession* network_session,
+ net::SSLCertRequestInfo* cert_request_info,
+ const base::Callback<void(net::X509Certificate*)>& callback) {
}
void ShellContentBrowserClient::AddNewCertificate(
diff --git a/content/shell/shell_content_browser_client.h b/content/shell/shell_content_browser_client.h
index defb5f5..158aefb 100644
--- a/content/shell/shell_content_browser_client.h
+++ b/content/shell/shell_content_browser_client.h
@@ -100,7 +100,9 @@ class ShellContentBrowserClient : public ContentBrowserClient {
virtual void SelectClientCertificate(
int render_process_id,
int render_view_id,
- SSLClientAuthHandler* handler) OVERRIDE;
+ const net::HttpNetworkSession* network_session,
+ net::SSLCertRequestInfo* cert_request_info,
+ const base::Callback<void(net::X509Certificate*)>& callback) OVERRIDE;
virtual void AddNewCertificate(
net::URLRequest* request,
net::X509Certificate* cert,