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

Unified Diff: chrome/browser/renderer_host/buffered_resource_handler.cc

Issue 271112: Adds support for the <keygen> tag for client certificate enrollment... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Upload before checkin Created 11 years, 2 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 | « no previous file | chrome/browser/renderer_host/resource_message_filter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/renderer_host/buffered_resource_handler.cc
===================================================================
--- chrome/browser/renderer_host/buffered_resource_handler.cc (revision 29898)
+++ chrome/browser/renderer_host/buffered_resource_handler.cc (working copy)
@@ -14,6 +14,7 @@
#include "chrome/browser/renderer_host/download_throttling_resource_handler.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h"
+#include "chrome/browser/renderer_host/x509_user_cert_resource_handler.h"
#include "chrome/common/url_constants.h"
#include "net/base/io_buffer.h"
#include "net/base/mime_sniffer.h"
@@ -293,7 +294,51 @@
// TODO(paulg): Only download if the context from the renderer allows it.
ResourceDispatcherHostRequestInfo* info =
ResourceDispatcherHost::InfoForRequest(request_);
+ std::string mime_type;
+ request_->GetMimeType(&mime_type);
+ // Check if this is an X.509 certificate, if yes, let it be handled
+ // by X509UserCertResourceHandler.
+ if (mime_type == "application/x-x509-user-cert") {
+
+ // This is entirely similar to how DownloadThrottlingResourceHandler
+ // works except we are doing it for an X.509 client certificates.
+
+ if (response_->response_head.headers && // Can be NULL if FTP.
+ response_->response_head.headers->response_code() / 100 != 2) {
+ // The response code indicates that this is an error page, but we are
+ // expecting an X.509 user certificate. We follow Firefox here and show
+ // our own error page instead of handling the error page as a
+ // certificate.
+ // TODO(abarth): We should abstract the response_code test, but this kind
+ // of check is scattered throughout our codebase.
+ request_->SimulateError(net::ERR_FILE_NOT_FOUND);
+ return false;
+ }
+
+ scoped_refptr<X509UserCertResourceHandler> x509_cert_handler =
+ new X509UserCertResourceHandler(host_, request_);
+
+ if (bytes_read_) {
+ // A Read has already occured and we need to copy the data into the
+ // EventHandler.
+ net::IOBuffer* buf = NULL;
+ int buf_len = 0;
+ x509_cert_handler->OnWillRead(request_id, &buf, &buf_len, bytes_read_);
+ CHECK((buf_len >= bytes_read_) && (bytes_read_ >= 0));
+ memcpy(buf->data(), read_buffer_->data(), bytes_read_);
+ }
+
+ // Inform the renderer that this will be handled entirely by the browser.
+ real_handler_->OnResponseStarted(info->request_id(), response_);
+ URLRequestStatus status(URLRequestStatus::HANDLED_EXTERNALLY, 0);
+ real_handler_->OnResponseCompleted(info->request_id(), status,
+ std::string());
+
+ // This is handled entirely within the browser, so just reset the handler.
+ real_handler_ = x509_cert_handler;
+ }
+
if (info->allow_download() && ShouldDownload(NULL)) {
if (response_->response_head.headers && // Can be NULL if FTP.
response_->response_head.headers->response_code() / 100 != 2) {
@@ -310,14 +355,14 @@
scoped_refptr<DownloadThrottlingResourceHandler> download_handler =
new DownloadThrottlingResourceHandler(host_,
- request_,
- request_->url(),
- info->child_id(),
- info->route_id(),
- request_id,
- in_complete);
+ request_,
+ request_->url(),
+ info->child_id(),
+ info->route_id(),
+ request_id,
+ in_complete);
if (bytes_read_) {
- // a Read has already occurred and we need to copy the data into the
+ // A Read has already occurred and we need to copy the data into the
// EventHandler.
net::IOBuffer* buf = NULL;
int buf_len = 0;
« no previous file with comments | « no previous file | chrome/browser/renderer_host/resource_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698