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_CERTIFICATE_RESOURCE_HANDLER_H_ | |
6 #define CONTENT_BROWSER_LOADER_CERTIFICATE_RESOURCE_HANDLER_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/macros.h" | |
11 #include "base/memory/ref_counted.h" | |
12 #include "content/browser/loader/resource_handler.h" | |
13 #include "net/base/mime_util.h" | |
14 | |
15 namespace net { | |
16 class GrowableIOBuffer; | |
17 class URLRequest; | |
18 class URLRequestStatus; | |
19 } // namespace net | |
20 | |
21 namespace content { | |
22 | |
23 // This class handles certificate mime types such as: | |
24 // - "application/x-x509-user-cert" | |
25 // - "application/x-x509-ca-cert" | |
26 // - "application/x-pkcs12" | |
27 // | |
28 class CertificateResourceHandler : public ResourceHandler { | |
29 public: | |
30 explicit CertificateResourceHandler(net::URLRequest* request); | |
31 ~CertificateResourceHandler() override; | |
32 | |
33 // Not needed, as this event handler ought to be the final resource. | |
34 bool OnRequestRedirected(const net::RedirectInfo& redirect_info, | |
35 ResourceResponse* resp, | |
36 bool* defer) override; | |
37 | |
38 // Check if this indeed an X509 cert. | |
39 bool OnResponseStarted(ResourceResponse* resp, bool* defer) override; | |
40 | |
41 // Pass-through implementation. | |
42 bool OnWillStart(const GURL& url, bool* defer) override; | |
43 | |
44 // Pass-through implementation. | |
45 bool OnBeforeNetworkStart(const GURL& url, bool* defer) override; | |
46 | |
47 // Create a new buffer to store received data. | |
48 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, | |
49 int* buf_size, | |
50 int min_size) override; | |
51 | |
52 // A read was completed, maybe allocate a new buffer for further data. | |
53 bool OnReadCompleted(int bytes_read, bool* defer) override; | |
54 | |
55 // Done downloading the certificate. | |
56 void OnResponseCompleted(const net::URLRequestStatus& urs, | |
57 const std::string& sec_info, | |
58 bool* defer) override; | |
59 | |
60 // N/A to cert downloading. | |
61 void OnDataDownloaded(int bytes_downloaded) override; | |
62 | |
63 private: | |
64 scoped_refptr<net::GrowableIOBuffer> buffer_; | |
65 net::CertificateMimeType cert_type_; | |
66 | |
67 DISALLOW_COPY_AND_ASSIGN(CertificateResourceHandler); | |
68 }; | |
69 | |
70 } // namespace content | |
71 | |
72 #endif // CONTENT_BROWSER_LOADER_CERTIFICATE_RESOURCE_HANDLER_H_ | |
OLD | NEW |