| OLD | NEW |
| 1 // Copyright (c) 2010 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 | 5 #ifndef CHROME_COMMON_SECURITY_FILTER_PEER_H_ |
| 6 #ifndef CHROME_COMMON_SECURITY_FILTER_PEER_H__ | 6 #define CHROME_COMMON_SECURITY_FILTER_PEER_H_ |
| 7 #define CHROME_COMMON_SECURITY_FILTER_PEER_H__ | |
| 8 #pragma once | 7 #pragma once |
| 9 | 8 |
| 10 #include "webkit/glue/resource_loader_bridge.h" | 9 #include "webkit/glue/resource_loader_bridge.h" |
| 11 | 10 |
| 12 // The SecurityFilterPeer is a proxy to a | 11 // The SecurityFilterPeer is a proxy to a |
| 13 // webkit_glue::ResourceLoaderBridge::Peer instance. It is used to pre-process | 12 // webkit_glue::ResourceLoaderBridge::Peer instance. It is used to pre-process |
| 14 // unsafe resources (such as mixed-content resource). | 13 // unsafe resources (such as mixed-content resource). |
| 15 // Call the factory method CreateSecurityFilterPeer() to obtain an instance of | 14 // Call the factory method CreateSecurityFilterPeer() to obtain an instance of |
| 16 // SecurityFilterPeer based on the original Peer. | 15 // SecurityFilterPeer based on the original Peer. |
| 17 // NOTE: subclasses should insure they delete themselves at the end of the | 16 // NOTE: subclasses should insure they delete themselves at the end of the |
| (...skipping 16 matching lines...) Expand all Loading... |
| 34 virtual bool OnReceivedRedirect( | 33 virtual bool OnReceivedRedirect( |
| 35 const GURL& new_url, | 34 const GURL& new_url, |
| 36 const webkit_glue::ResourceResponseInfo& info, | 35 const webkit_glue::ResourceResponseInfo& info, |
| 37 bool* has_new_first_party_for_cookies, | 36 bool* has_new_first_party_for_cookies, |
| 38 GURL* new_first_party_for_cookies); | 37 GURL* new_first_party_for_cookies); |
| 39 virtual void OnReceivedResponse( | 38 virtual void OnReceivedResponse( |
| 40 const webkit_glue::ResourceResponseInfo& info, | 39 const webkit_glue::ResourceResponseInfo& info, |
| 41 bool content_filtered); | 40 bool content_filtered); |
| 42 virtual void OnDownloadedData(int len) {} | 41 virtual void OnDownloadedData(int len) {} |
| 43 virtual void OnReceivedData(const char* data, int len); | 42 virtual void OnReceivedData(const char* data, int len); |
| 44 virtual void OnCompletedRequest(const URLRequestStatus& status, | 43 virtual void OnCompletedRequest(const net::URLRequestStatus& status, |
| 45 const std::string& security_info, | 44 const std::string& security_info, |
| 46 const base::Time& completion_time); | 45 const base::Time& completion_time); |
| 47 | 46 |
| 48 protected: | 47 protected: |
| 49 SecurityFilterPeer(webkit_glue::ResourceLoaderBridge* resource_loader_bridge, | 48 SecurityFilterPeer(webkit_glue::ResourceLoaderBridge* resource_loader_bridge, |
| 50 webkit_glue::ResourceLoaderBridge::Peer* peer); | 49 webkit_glue::ResourceLoaderBridge::Peer* peer); |
| 51 | 50 |
| 52 webkit_glue::ResourceLoaderBridge::Peer* original_peer_; | 51 webkit_glue::ResourceLoaderBridge::Peer* original_peer_; |
| 53 webkit_glue::ResourceLoaderBridge* resource_loader_bridge_; | 52 webkit_glue::ResourceLoaderBridge* resource_loader_bridge_; |
| 54 | 53 |
| 55 private: | 54 private: |
| 56 DISALLOW_COPY_AND_ASSIGN(SecurityFilterPeer); | 55 DISALLOW_COPY_AND_ASSIGN(SecurityFilterPeer); |
| 57 }; | 56 }; |
| 58 | 57 |
| 59 // The BufferedPeer reads all the data of the request into an internal buffer. | 58 // The BufferedPeer reads all the data of the request into an internal buffer. |
| 60 // Subclasses should implement DataReady() to process the data as necessary. | 59 // Subclasses should implement DataReady() to process the data as necessary. |
| 61 class BufferedPeer : public SecurityFilterPeer { | 60 class BufferedPeer : public SecurityFilterPeer { |
| 62 public: | 61 public: |
| 63 BufferedPeer(webkit_glue::ResourceLoaderBridge* resource_loader_bridge, | 62 BufferedPeer(webkit_glue::ResourceLoaderBridge* resource_loader_bridge, |
| 64 webkit_glue::ResourceLoaderBridge::Peer* peer, | 63 webkit_glue::ResourceLoaderBridge::Peer* peer, |
| 65 const std::string& mime_type); | 64 const std::string& mime_type); |
| 66 virtual ~BufferedPeer(); | 65 virtual ~BufferedPeer(); |
| 67 | 66 |
| 68 // ResourceLoaderBridge::Peer Implementation. | 67 // ResourceLoaderBridge::Peer Implementation. |
| 69 virtual void OnReceivedResponse( | 68 virtual void OnReceivedResponse( |
| 70 const webkit_glue::ResourceResponseInfo& info, | 69 const webkit_glue::ResourceResponseInfo& info, |
| 71 bool content_filtered); | 70 bool content_filtered); |
| 72 virtual void OnReceivedData(const char* data, int len); | 71 virtual void OnReceivedData(const char* data, int len); |
| 73 virtual void OnCompletedRequest(const URLRequestStatus& status, | 72 virtual void OnCompletedRequest(const net::URLRequestStatus& status, |
| 74 const std::string& security_info, | 73 const std::string& security_info, |
| 75 const base::Time& completion_time); | 74 const base::Time& completion_time); |
| 76 | 75 |
| 77 protected: | 76 protected: |
| 78 // 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 |
| 79 // 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 |
| 80 // 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 |
| 81 // original peer, if it returns false, an error is sent instead. | 80 // original peer, if it returns false, an error is sent instead. |
| 82 virtual bool DataReady() = 0; | 81 virtual bool DataReady() = 0; |
| 83 | 82 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 104 webkit_glue::ResourceLoaderBridge::Peer* peer, | 103 webkit_glue::ResourceLoaderBridge::Peer* peer, |
| 105 const std::string& mime_type, | 104 const std::string& mime_type, |
| 106 const std::string& data); | 105 const std::string& data); |
| 107 virtual ~ReplaceContentPeer(); | 106 virtual ~ReplaceContentPeer(); |
| 108 | 107 |
| 109 // ResourceLoaderBridge::Peer Implementation. | 108 // ResourceLoaderBridge::Peer Implementation. |
| 110 virtual void OnReceivedResponse( | 109 virtual void OnReceivedResponse( |
| 111 const webkit_glue::ResourceResponseInfo& info, | 110 const webkit_glue::ResourceResponseInfo& info, |
| 112 bool content_filtered); | 111 bool content_filtered); |
| 113 virtual void OnReceivedData(const char* data, int len); | 112 virtual void OnReceivedData(const char* data, int len); |
| 114 virtual void OnCompletedRequest(const URLRequestStatus& status, | 113 virtual void OnCompletedRequest(const net::URLRequestStatus& status, |
| 115 const std::string& security_info, | 114 const std::string& security_info, |
| 116 const base::Time& completion_time); | 115 const base::Time& completion_time); |
| 117 | 116 |
| 118 private: | 117 private: |
| 119 webkit_glue::ResourceResponseInfo response_info_; | 118 webkit_glue::ResourceResponseInfo response_info_; |
| 120 std::string mime_type_; | 119 std::string mime_type_; |
| 121 std::string data_; | 120 std::string data_; |
| 122 | 121 |
| 123 DISALLOW_COPY_AND_ASSIGN(ReplaceContentPeer); | 122 DISALLOW_COPY_AND_ASSIGN(ReplaceContentPeer); |
| 124 }; | 123 }; |
| 125 | 124 |
| 126 #endif // CHROME_COMMON_SECURITY_FILTER_PEER_H__ | 125 #endif // CHROME_COMMON_SECURITY_FILTER_PEER_H_ |
| OLD | NEW |