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

Unified Diff: chrome/browser/ssl/ssl_client_auth_handler.cc

Issue 2823038: Refactor SSLClientAuthHandler and certificate selection (Closed)
Patch Set: Rebase the patch Created 10 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ssl/ssl_client_auth_handler.h ('k') | chrome/browser/ssl/ssl_client_auth_handler_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ssl/ssl_client_auth_handler.cc
diff --git a/chrome/browser/ssl/ssl_client_auth_handler.cc b/chrome/browser/ssl/ssl_client_auth_handler.cc
index f46c6f31f95dfaaad32a7819008d4a7faf79b775..74b25bf590d88e30707bf5220fedb6e6f5fa0272 100644
--- a/chrome/browser/ssl/ssl_client_auth_handler.cc
+++ b/chrome/browser/ssl/ssl_client_auth_handler.cc
@@ -4,13 +4,10 @@
#include "chrome/browser/ssl/ssl_client_auth_handler.h"
-#include "app/l10n_util.h"
-#include "base/string_util.h"
-#include "chrome/browser/browser_list.h"
-#include "chrome/browser/browser.h"
-#include "chrome/browser/browser_window.h"
#include "chrome/browser/chrome_thread.h"
-#include "grit/generated_resources.h"
+#include "chrome/browser/renderer_host/render_view_host_delegate.h"
+#include "chrome/browser/renderer_host/render_view_host_notification_task.h"
+#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
#include "net/url_request/url_request.h"
SSLClientAuthHandler::SSLClientAuthHandler(
@@ -18,11 +15,11 @@ SSLClientAuthHandler::SSLClientAuthHandler(
net::SSLCertRequestInfo* cert_request_info)
: request_(request),
cert_request_info_(cert_request_info) {
- // Keep us alive until a cert is selected.
- AddRef();
}
SSLClientAuthHandler::~SSLClientAuthHandler() {
+ // If we were simply dropped, then act as if we selected no certificate.
+ DoCertificateSelected(NULL);
}
void SSLClientAuthHandler::OnRequestCancelled() {
@@ -30,14 +27,24 @@ void SSLClientAuthHandler::OnRequestCancelled() {
}
void SSLClientAuthHandler::SelectCertificate() {
- // Let's move the request to the UI thread.
- ChromeThread::PostTask(
- ChromeThread::UI, FROM_HERE,
- NewRunnableMethod(this, &SSLClientAuthHandler::DoSelectCertificate));
-}
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
-// Looking for DoSelectCertificate()?
-// It's implemented in a separate source file for each platform.
+ int render_process_host_id;
+ int render_view_host_id;
+ if (!ResourceDispatcherHost::RenderViewForRequest(request_,
+ &render_process_host_id,
+ &render_view_host_id))
+ NOTREACHED();
+
+ // If the RVH does not exist by the time this task gets run, then the task
+ // will be dropped and the scoped_refptr to SSLClientAuthHandler will go
+ // away, so we do not leak anything. The destructor takes care of ensuring
+ // the URLRequest always gets a response.
+ CallRenderViewHostSSLDelegate(
+ render_process_host_id, render_view_host_id,
+ &RenderViewHostDelegate::SSL::ShowClientCertificateRequestDialog,
+ scoped_refptr<SSLClientAuthHandler>(this));
+}
// Notify the IO thread that we have selected a cert.
void SSLClientAuthHandler::CertificateSelected(net::X509Certificate* cert) {
@@ -48,11 +55,12 @@ void SSLClientAuthHandler::CertificateSelected(net::X509Certificate* cert) {
}
void SSLClientAuthHandler::DoCertificateSelected(net::X509Certificate* cert) {
- // request_ could have been NULLed if the request was cancelled while the user
- // was choosing a cert.
- if (request_)
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
+ // request_ could have been NULLed if the request was cancelled while the
+ // user was choosing a cert, or because we have already responded to the
+ // certificate.
+ if (request_) {
request_->ContinueWithCertificate(cert);
-
- // We are done.
- Release();
+ request_ = NULL;
+ }
}
« no previous file with comments | « chrome/browser/ssl/ssl_client_auth_handler.h ('k') | chrome/browser/ssl/ssl_client_auth_handler_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698