| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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 CONTENT_BROWSER_LOADER_X509_USER_CERT_RESOURCE_HANDLER_H_ | |
| 6 #define CONTENT_BROWSER_LOADER_X509_USER_CERT_RESOURCE_HANDLER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <utility> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/compiler_specific.h" | |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "base/memory/ref_counted.h" | |
| 15 #include "content/browser/loader/resource_handler.h" | |
| 16 #include "googleurl/src/gurl.h" | |
| 17 | |
| 18 namespace net { | |
| 19 class IOBuffer; | |
| 20 class URLRequest; | |
| 21 class URLRequestStatus; | |
| 22 } // namespace net | |
| 23 | |
| 24 namespace content { | |
| 25 | |
| 26 // This class handles the "application/x-x509-user-cert" mime-type | |
| 27 // which is a certificate generated by a CA, typically after a previous | |
| 28 // <keygen> form post. | |
| 29 | |
| 30 class X509UserCertResourceHandler : public ResourceHandler { | |
| 31 public: | |
| 32 X509UserCertResourceHandler(net::URLRequest* request, | |
| 33 int render_process_host_id, | |
| 34 int render_view_id); | |
| 35 virtual ~X509UserCertResourceHandler(); | |
| 36 | |
| 37 virtual bool OnUploadProgress(int request_id, | |
| 38 uint64 position, | |
| 39 uint64 size) OVERRIDE; | |
| 40 | |
| 41 // Not needed, as this event handler ought to be the final resource. | |
| 42 virtual bool OnRequestRedirected(int request_id, | |
| 43 const GURL& url, | |
| 44 ResourceResponse* resp, | |
| 45 bool* defer) OVERRIDE; | |
| 46 | |
| 47 // Check if this indeed an X509 cert. | |
| 48 virtual bool OnResponseStarted(int request_id, | |
| 49 ResourceResponse* resp, | |
| 50 bool* defer) OVERRIDE; | |
| 51 | |
| 52 // Pass-through implementation. | |
| 53 virtual bool OnWillStart(int request_id, | |
| 54 const GURL& url, | |
| 55 bool* defer) OVERRIDE; | |
| 56 | |
| 57 // Create a new buffer to store received data. | |
| 58 virtual bool OnWillRead(int request_id, | |
| 59 net::IOBuffer** buf, | |
| 60 int* buf_size, | |
| 61 int min_size) OVERRIDE; | |
| 62 | |
| 63 // A read was completed, maybe allocate a new buffer for further data. | |
| 64 virtual bool OnReadCompleted(int request_id, | |
| 65 int bytes_read, | |
| 66 bool* defer) OVERRIDE; | |
| 67 | |
| 68 // Done downloading the certificate. | |
| 69 virtual bool OnResponseCompleted(int request_id, | |
| 70 const net::URLRequestStatus& urs, | |
| 71 const std::string& sec_info) OVERRIDE; | |
| 72 | |
| 73 private: | |
| 74 typedef std::vector<std::pair<scoped_refptr<net::IOBuffer>, | |
| 75 size_t> > ContentVector; | |
| 76 | |
| 77 void AssembleResource(); | |
| 78 | |
| 79 GURL url_; | |
| 80 net::URLRequest* request_; | |
| 81 size_t content_length_; | |
| 82 ContentVector buffer_; | |
| 83 scoped_refptr<net::IOBuffer> read_buffer_; | |
| 84 scoped_refptr<net::IOBuffer> resource_buffer_; // Downloaded certificate. | |
| 85 // The id of the |RenderProcessHost| which started the download. | |
| 86 int render_process_host_id_; | |
| 87 // The id of the |RenderView| which started the download. | |
| 88 int render_view_id_; | |
| 89 | |
| 90 DISALLOW_COPY_AND_ASSIGN(X509UserCertResourceHandler); | |
| 91 }; | |
| 92 | |
| 93 } // namespace content | |
| 94 | |
| 95 #endif // CONTENT_BROWSER_LOADER_X509_USER_CERT_RESOURCE_HANDLER_H_ | |
| OLD | NEW |