OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_LOADER_CERTIFICATE_RESOURCE_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_CERTIFICATE_RESOURCE_HANDLER_H_ |
6 #define CONTENT_BROWSER_LOADER_CERTIFICATE_RESOURCE_HANDLER_H_ | 6 #define CONTENT_BROWSER_LOADER_CERTIFICATE_RESOURCE_HANDLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "content/browser/loader/resource_handler.h" | 15 #include "content/browser/loader/resource_handler.h" |
16 #include "net/base/mime_util.h" | 16 #include "net/base/mime_util.h" |
17 #include "url/gurl.h" | |
18 | 17 |
19 namespace net { | 18 namespace net { |
20 class IOBuffer; | 19 class IOBuffer; |
21 class URLRequest; | 20 class URLRequest; |
22 class URLRequestStatus; | 21 class URLRequestStatus; |
23 } // namespace net | 22 } // namespace net |
24 | 23 |
25 namespace content { | 24 namespace content { |
26 | 25 |
27 // This class handles certificate mime types such as: | 26 // This class handles certificate mime types such as: |
28 // - "application/x-x509-user-cert" | 27 // - "application/x-x509-user-cert" |
29 // - "application/x-x509-ca-cert" | 28 // - "application/x-x509-ca-cert" |
30 // - "application/x-pkcs12" | 29 // - "application/x-pkcs12" |
31 // | 30 // |
32 class CertificateResourceHandler : public ResourceHandler { | 31 class CertificateResourceHandler : public ResourceHandler { |
33 public: | 32 public: |
34 explicit CertificateResourceHandler(net::URLRequest* request); | 33 explicit CertificateResourceHandler(net::URLRequest* request); |
35 virtual ~CertificateResourceHandler(); | 34 virtual ~CertificateResourceHandler(); |
36 | 35 |
37 virtual bool OnUploadProgress(uint64 position, uint64 size) OVERRIDE; | 36 virtual bool OnUploadProgress(uint64 position, uint64 size) OVERRIDE; |
38 | 37 |
39 // Not needed, as this event handler ought to be the final resource. | 38 // Not needed, as this event handler ought to be the final resource. |
40 virtual bool OnRequestRedirected(const GURL& url, | 39 virtual bool OnRequestRedirected(const net::RedirectInfo& redirect_info, |
41 ResourceResponse* resp, | 40 ResourceResponse* resp, |
42 bool* defer) OVERRIDE; | 41 bool* defer) OVERRIDE; |
43 | 42 |
44 // Check if this indeed an X509 cert. | 43 // Check if this indeed an X509 cert. |
45 virtual bool OnResponseStarted(ResourceResponse* resp, | 44 virtual bool OnResponseStarted(ResourceResponse* resp, |
46 bool* defer) OVERRIDE; | 45 bool* defer) OVERRIDE; |
47 | 46 |
48 // Pass-through implementation. | 47 // Pass-through implementation. |
49 virtual bool OnWillStart(const GURL& url, bool* defer) OVERRIDE; | 48 virtual bool OnWillStart(const GURL& url, bool* defer) OVERRIDE; |
50 | 49 |
(...skipping 15 matching lines...) Expand all Loading... |
66 | 65 |
67 // N/A to cert downloading. | 66 // N/A to cert downloading. |
68 virtual void OnDataDownloaded(int bytes_downloaded) OVERRIDE; | 67 virtual void OnDataDownloaded(int bytes_downloaded) OVERRIDE; |
69 | 68 |
70 private: | 69 private: |
71 typedef std::vector<std::pair<scoped_refptr<net::IOBuffer>, | 70 typedef std::vector<std::pair<scoped_refptr<net::IOBuffer>, |
72 size_t> > ContentVector; | 71 size_t> > ContentVector; |
73 | 72 |
74 void AssembleResource(); | 73 void AssembleResource(); |
75 | 74 |
76 GURL url_; | |
77 size_t content_length_; | 75 size_t content_length_; |
78 ContentVector buffer_; | 76 ContentVector buffer_; |
79 scoped_refptr<net::IOBuffer> read_buffer_; | 77 scoped_refptr<net::IOBuffer> read_buffer_; |
80 scoped_refptr<net::IOBuffer> resource_buffer_; // Downloaded certificate. | 78 scoped_refptr<net::IOBuffer> resource_buffer_; // Downloaded certificate. |
81 net::CertificateMimeType cert_type_; | 79 net::CertificateMimeType cert_type_; |
82 DISALLOW_COPY_AND_ASSIGN(CertificateResourceHandler); | 80 DISALLOW_COPY_AND_ASSIGN(CertificateResourceHandler); |
83 }; | 81 }; |
84 | 82 |
85 } // namespace content | 83 } // namespace content |
86 | 84 |
87 #endif // CONTENT_BROWSER_LOADER_CERTIFICATE_RESOURCE_HANDLER_H_ | 85 #endif // CONTENT_BROWSER_LOADER_CERTIFICATE_RESOURCE_HANDLER_H_ |
OLD | NEW |