| 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 // This job type handles Chrome plugin network interception. When a plugin | 5 // This job type handles Chrome plugin network interception. When a plugin |
| 6 // wants to intercept a request, a job of this type is created. The intercept | 6 // wants to intercept a request, a job of this type is created. The intercept |
| 7 // job communicates with the plugin to retrieve the response headers and data. | 7 // job communicates with the plugin to retrieve the response headers and data. |
| 8 | 8 |
| 9 #include "chrome/common/net/url_request_intercept_job.h" | 9 #include "chrome/common/net/url_request_intercept_job.h" |
| 10 | 10 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 bool URLRequestInterceptJob::GetMimeType(std::string* mime_type) const { | 104 bool URLRequestInterceptJob::GetMimeType(std::string* mime_type) const { |
| 105 return request_->response_headers()->GetMimeType(mime_type); | 105 return request_->response_headers()->GetMimeType(mime_type); |
| 106 } | 106 } |
| 107 | 107 |
| 108 bool URLRequestInterceptJob::GetCharset(std::string* charset) { | 108 bool URLRequestInterceptJob::GetCharset(std::string* charset) { |
| 109 return request_->response_headers()->GetCharset(charset); | 109 return request_->response_headers()->GetCharset(charset); |
| 110 } | 110 } |
| 111 | 111 |
| 112 bool URLRequestInterceptJob::GetContentEncodings( | 112 bool URLRequestInterceptJob::GetContentEncodings( |
| 113 std::vector<Filter::FilterType>* encoding_types) { | 113 std::vector<net::Filter::FilterType>* encoding_types) { |
| 114 DCHECK(encoding_types->empty()); | 114 DCHECK(encoding_types->empty()); |
| 115 if (!request_->response_headers()) | 115 if (!request_->response_headers()) |
| 116 return false; | 116 return false; |
| 117 | 117 |
| 118 std::string encoding_type; | 118 std::string encoding_type; |
| 119 void* iter = NULL; | 119 void* iter = NULL; |
| 120 while (request_->response_headers()->EnumerateHeader( | 120 while (request_->response_headers()->EnumerateHeader( |
| 121 &iter, "Content-Encoding", &encoding_type)) { | 121 &iter, "Content-Encoding", &encoding_type)) { |
| 122 encoding_types->push_back(Filter::ConvertEncodingToType(encoding_type)); | 122 encoding_types->push_back( |
| 123 net::Filter::ConvertEncodingToType(encoding_type)); |
| 123 } | 124 } |
| 124 | 125 |
| 125 // Even if encoding types are empty, there is a chance that we need to add | 126 // Even if encoding types are empty, there is a chance that we need to add |
| 126 // some decoding, as some proxies strip encoding completely. In such cases, | 127 // some decoding, as some proxies strip encoding completely. In such cases, |
| 127 // we may need to add (for example) SDCH filtering (when the context suggests | 128 // we may need to add (for example) SDCH filtering (when the context suggests |
| 128 // it is appropriate). | 129 // it is appropriate). |
| 129 Filter::FixupEncodingTypes(*this, encoding_types); | 130 net::Filter::FixupEncodingTypes(*this, encoding_types); |
| 130 return !encoding_types->empty(); | 131 return !encoding_types->empty(); |
| 131 } | 132 } |
| 132 | 133 |
| 133 void URLRequestInterceptJob::GetResponseInfo(net::HttpResponseInfo* info) { | 134 void URLRequestInterceptJob::GetResponseInfo(net::HttpResponseInfo* info) { |
| 134 if (!plugin_) | 135 if (!plugin_) |
| 135 return; | 136 return; |
| 136 | 137 |
| 137 std::string raw_headers; | 138 std::string raw_headers; |
| 138 int size = plugin_->functions().request_funcs->get_response_info( | 139 int size = plugin_->functions().request_funcs->get_response_info( |
| 139 cprequest_.get(), CPRESPONSEINFO_HTTP_RAW_HEADERS, NULL, 0); | 140 cprequest_.get(), CPRESPONSEINFO_HTTP_RAW_HEADERS, NULL, 0); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 NotifyReadComplete(bytes_read); | 229 NotifyReadComplete(bytes_read); |
| 229 } | 230 } |
| 230 | 231 |
| 231 void URLRequestInterceptJob::Observe(NotificationType type, | 232 void URLRequestInterceptJob::Observe(NotificationType type, |
| 232 const NotificationSource& source, | 233 const NotificationSource& source, |
| 233 const NotificationDetails& details) { | 234 const NotificationDetails& details) { |
| 234 DCHECK(type == NotificationType::CHROME_PLUGIN_UNLOADED); | 235 DCHECK(type == NotificationType::CHROME_PLUGIN_UNLOADED); |
| 235 DCHECK(plugin_ == Source<ChromePluginLib>(source).ptr()); | 236 DCHECK(plugin_ == Source<ChromePluginLib>(source).ptr()); |
| 236 DetachPlugin(); | 237 DetachPlugin(); |
| 237 } | 238 } |
| OLD | NEW |