OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_RENDERER_HOST_X509_USER_CERT_RESOURCE_HANDLER_H_ |
| 6 #define CHROME_BROWSER_RENDERER_HOST_X509_USER_CERT_RESOURCE_HANDLER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
| 11 #include "chrome/browser/renderer_host/resource_handler.h" |
| 12 #include "chrome/browser/download/download_file.h" |
| 13 |
| 14 // This class handles the "application/x-x509-user-cert" mime-type |
| 15 // which is a certificate generated by a CA after a previous |
| 16 // <keygen> form post. |
| 17 |
| 18 class X509UserCertResourceHandler : public ResourceHandler { |
| 19 public: |
| 20 X509UserCertResourceHandler(ResourceDispatcherHost* host, |
| 21 URLRequest *request); |
| 22 |
| 23 // Not needed, as this event handler ought to be the final resource. |
| 24 bool OnRequestRedirected(int request_id, const GURL& url, |
| 25 ResourceResponse* resp, bool* defer); |
| 26 |
| 27 // Check if this indeed an X509 cert. |
| 28 bool OnResponseStarted(int request_id, ResourceResponse* resp); |
| 29 |
| 30 // Create a new buffer to store received data. |
| 31 bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size, |
| 32 int min_size); |
| 33 |
| 34 // A read was completed, maybe allocate a new buffer for further data. |
| 35 bool OnReadCompleted(int request_id, int* bytes_read); |
| 36 |
| 37 // Done downloading the certificate. |
| 38 bool OnResponseCompleted(int request_id, |
| 39 const URLRequestStatus& urs, |
| 40 const std::string& sec_info); |
| 41 |
| 42 |
| 43 private: |
| 44 void AssembleResource(); |
| 45 |
| 46 GURL url_; |
| 47 ResourceDispatcherHost* host_; |
| 48 URLRequest* request_; |
| 49 size_t content_length_; |
| 50 scoped_ptr<DownloadBuffer> buffer_; |
| 51 scoped_refptr<net::IOBuffer> read_buffer_; |
| 52 scoped_refptr<net::IOBuffer> resource_buffer_; // Downloaded certificate. |
| 53 static const int kReadBufSize = 32768; |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(X509UserCertResourceHandler); |
| 56 }; |
| 57 |
| 58 #endif // CHROME_BROWSER_RENDERER_HOST_X509_USER_CERT__RESOURCE_HANDLER_H_ |
OLD | NEW |