OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_RENDERER_SECURITY_FILTER_PEER_H_ | 5 #ifndef CHROME_RENDERER_SECURITY_FILTER_PEER_H_ |
6 #define CHROME_RENDERER_SECURITY_FILTER_PEER_H_ | 6 #define CHROME_RENDERER_SECURITY_FILTER_PEER_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <string> | 10 #include <string> |
9 | 11 |
| 12 #include "base/macros.h" |
10 #include "content/public/child/request_peer.h" | 13 #include "content/public/child/request_peer.h" |
11 #include "content/public/common/resource_response_info.h" | 14 #include "content/public/common/resource_response_info.h" |
12 #include "content/public/common/resource_type.h" | 15 #include "content/public/common/resource_type.h" |
13 | 16 |
14 // The SecurityFilterPeer is a proxy to a | 17 // The SecurityFilterPeer is a proxy to a |
15 // content::RequestPeer instance. It is used to pre-process | 18 // content::RequestPeer instance. It is used to pre-process |
16 // unsafe resources (such as mixed-content resource). | 19 // unsafe resources (such as mixed-content resource). |
17 // Call the factory method CreateSecurityFilterPeer() to obtain an instance of | 20 // Call the factory method CreateSecurityFilterPeer() to obtain an instance of |
18 // SecurityFilterPeer based on the original Peer. | 21 // SecurityFilterPeer based on the original Peer. |
19 // NOTE: subclasses should ensure they delete themselves at the end of the | 22 // NOTE: subclasses should ensure they delete themselves at the end of the |
20 // OnReceiveComplete call. | 23 // OnReceiveComplete call. |
21 class SecurityFilterPeer : public content::RequestPeer { | 24 class SecurityFilterPeer : public content::RequestPeer { |
22 public: | 25 public: |
23 ~SecurityFilterPeer() override; | 26 ~SecurityFilterPeer() override; |
24 | 27 |
25 static SecurityFilterPeer* CreateSecurityFilterPeerForDeniedRequest( | 28 static SecurityFilterPeer* CreateSecurityFilterPeerForDeniedRequest( |
26 content::ResourceType resource_type, | 29 content::ResourceType resource_type, |
27 content::RequestPeer* peer, | 30 content::RequestPeer* peer, |
28 int os_error); | 31 int os_error); |
29 | 32 |
30 static SecurityFilterPeer* CreateSecurityFilterPeerForFrame( | 33 static SecurityFilterPeer* CreateSecurityFilterPeerForFrame( |
31 content::RequestPeer* peer, | 34 content::RequestPeer* peer, |
32 int os_error); | 35 int os_error); |
33 | 36 |
34 // content::RequestPeer methods. | 37 // content::RequestPeer methods. |
35 void OnUploadProgress(uint64 position, uint64 size) override; | 38 void OnUploadProgress(uint64_t position, uint64_t size) override; |
36 bool OnReceivedRedirect(const net::RedirectInfo& redirect_info, | 39 bool OnReceivedRedirect(const net::RedirectInfo& redirect_info, |
37 const content::ResourceResponseInfo& info) override; | 40 const content::ResourceResponseInfo& info) override; |
38 void OnDownloadedData(int len, int encoded_data_length) override {} | 41 void OnDownloadedData(int len, int encoded_data_length) override {} |
39 protected: | 42 protected: |
40 explicit SecurityFilterPeer(content::RequestPeer* peer); | 43 explicit SecurityFilterPeer(content::RequestPeer* peer); |
41 | 44 |
42 content::RequestPeer* original_peer_; | 45 content::RequestPeer* original_peer_; |
43 | 46 |
44 private: | 47 private: |
45 DISALLOW_COPY_AND_ASSIGN(SecurityFilterPeer); | 48 DISALLOW_COPY_AND_ASSIGN(SecurityFilterPeer); |
46 }; | 49 }; |
47 | 50 |
48 // The BufferedPeer reads all the data of the request into an internal buffer. | 51 // The BufferedPeer reads all the data of the request into an internal buffer. |
49 // Subclasses should implement DataReady() to process the data as necessary. | 52 // Subclasses should implement DataReady() to process the data as necessary. |
50 class BufferedPeer : public SecurityFilterPeer { | 53 class BufferedPeer : public SecurityFilterPeer { |
51 public: | 54 public: |
52 BufferedPeer(content::RequestPeer* peer, const std::string& mime_type); | 55 BufferedPeer(content::RequestPeer* peer, const std::string& mime_type); |
53 ~BufferedPeer() override; | 56 ~BufferedPeer() override; |
54 | 57 |
55 // content::RequestPeer Implementation. | 58 // content::RequestPeer Implementation. |
56 void OnReceivedResponse(const content::ResourceResponseInfo& info) override; | 59 void OnReceivedResponse(const content::ResourceResponseInfo& info) override; |
57 void OnReceivedData(scoped_ptr<ReceivedData> data) override; | 60 void OnReceivedData(scoped_ptr<ReceivedData> data) override; |
58 void OnCompletedRequest(int error_code, | 61 void OnCompletedRequest(int error_code, |
59 bool was_ignored_by_handler, | 62 bool was_ignored_by_handler, |
60 bool stale_copy_in_cache, | 63 bool stale_copy_in_cache, |
61 const std::string& security_info, | 64 const std::string& security_info, |
62 const base::TimeTicks& completion_time, | 65 const base::TimeTicks& completion_time, |
63 int64 total_transfer_size) override; | 66 int64_t total_transfer_size) override; |
64 void OnReceivedCompletedResponse(const content::ResourceResponseInfo& info, | 67 void OnReceivedCompletedResponse(const content::ResourceResponseInfo& info, |
65 scoped_ptr<ReceivedData> data, | 68 scoped_ptr<ReceivedData> data, |
66 int error_code, | 69 int error_code, |
67 bool was_ignored_by_handler, | 70 bool was_ignored_by_handler, |
68 bool stale_copy_in_cache, | 71 bool stale_copy_in_cache, |
69 const std::string& security_info, | 72 const std::string& security_info, |
70 const base::TimeTicks& completion_time, | 73 const base::TimeTicks& completion_time, |
71 int64 total_transfer_size) override; | 74 int64_t total_transfer_size) override; |
72 | 75 |
73 protected: | 76 protected: |
74 // Invoked when the entire request has been processed before the data is sent | 77 // Invoked when the entire request has been processed before the data is sent |
75 // to the original peer, giving an opportunity to subclasses to process the | 78 // to the original peer, giving an opportunity to subclasses to process the |
76 // data in data_. If this method returns true, the data is fed to the | 79 // data in data_. If this method returns true, the data is fed to the |
77 // original peer, if it returns false, an error is sent instead. | 80 // original peer, if it returns false, an error is sent instead. |
78 virtual bool DataReady() = 0; | 81 virtual bool DataReady() = 0; |
79 | 82 |
80 content::ResourceResponseInfo response_info_; | 83 content::ResourceResponseInfo response_info_; |
81 std::string data_; | 84 std::string data_; |
(...skipping 18 matching lines...) Expand all Loading... |
100 ~ReplaceContentPeer() override; | 103 ~ReplaceContentPeer() override; |
101 | 104 |
102 // content::RequestPeer Implementation. | 105 // content::RequestPeer Implementation. |
103 void OnReceivedResponse(const content::ResourceResponseInfo& info) override; | 106 void OnReceivedResponse(const content::ResourceResponseInfo& info) override; |
104 void OnReceivedData(scoped_ptr<ReceivedData> data) override; | 107 void OnReceivedData(scoped_ptr<ReceivedData> data) override; |
105 void OnCompletedRequest(int error_code, | 108 void OnCompletedRequest(int error_code, |
106 bool was_ignored_by_handler, | 109 bool was_ignored_by_handler, |
107 bool stale_copy_in_cache, | 110 bool stale_copy_in_cache, |
108 const std::string& security_info, | 111 const std::string& security_info, |
109 const base::TimeTicks& completion_time, | 112 const base::TimeTicks& completion_time, |
110 int64 total_transfer_size) override; | 113 int64_t total_transfer_size) override; |
111 void OnReceivedCompletedResponse(const content::ResourceResponseInfo& info, | 114 void OnReceivedCompletedResponse(const content::ResourceResponseInfo& info, |
112 scoped_ptr<ReceivedData> data, | 115 scoped_ptr<ReceivedData> data, |
113 int error_code, | 116 int error_code, |
114 bool was_ignored_by_handler, | 117 bool was_ignored_by_handler, |
115 bool stale_copy_in_cache, | 118 bool stale_copy_in_cache, |
116 const std::string& security_info, | 119 const std::string& security_info, |
117 const base::TimeTicks& completion_time, | 120 const base::TimeTicks& completion_time, |
118 int64 total_transfer_size) override; | 121 int64_t total_transfer_size) override; |
119 | 122 |
120 private: | 123 private: |
121 content::ResourceResponseInfo response_info_; | 124 content::ResourceResponseInfo response_info_; |
122 std::string mime_type_; | 125 std::string mime_type_; |
123 std::string data_; | 126 std::string data_; |
124 | 127 |
125 DISALLOW_COPY_AND_ASSIGN(ReplaceContentPeer); | 128 DISALLOW_COPY_AND_ASSIGN(ReplaceContentPeer); |
126 }; | 129 }; |
127 | 130 |
128 #endif // CHROME_RENDERER_SECURITY_FILTER_PEER_H_ | 131 #endif // CHROME_RENDERER_SECURITY_FILTER_PEER_H_ |
OLD | NEW |