| 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 #include "content/browser/loader/buffered_resource_handler.h" | 5 #include "content/browser/loader/buffered_resource_handler.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 state_ = STATE_BUFFERING; | 126 state_ = STATE_BUFFERING; |
| 127 return true; | 127 return true; |
| 128 } | 128 } |
| 129 | 129 |
| 130 if (response_->head.mime_type.empty()) { | 130 if (response_->head.mime_type.empty()) { |
| 131 // Ugg. The server told us not to sniff the content but didn't give us | 131 // Ugg. The server told us not to sniff the content but didn't give us |
| 132 // a mime type. What's a browser to do? Turns out, we're supposed to | 132 // a mime type. What's a browser to do? Turns out, we're supposed to |
| 133 // treat the response as "text/plain". This is the most secure option. | 133 // treat the response as "text/plain". This is the most secure option. |
| 134 response_->head.mime_type.assign("text/plain"); | 134 response_->head.mime_type.assign("text/plain"); |
| 135 } | 135 } |
| 136 | |
| 137 // Treat feed types as text/plain. | |
| 138 if (response_->head.mime_type == "application/rss+xml" || | |
| 139 response_->head.mime_type == "application/atom+xml") { | |
| 140 response_->head.mime_type.assign("text/plain"); | |
| 141 } | |
| 142 } | 136 } |
| 143 | 137 |
| 144 state_ = STATE_PROCESSING; | 138 state_ = STATE_PROCESSING; |
| 145 return ProcessResponse(defer); | 139 return ProcessResponse(defer); |
| 146 } | 140 } |
| 147 | 141 |
| 148 // We'll let the original event handler provide a buffer, and reuse it for | 142 // We'll let the original event handler provide a buffer, and reuse it for |
| 149 // subsequent reads until we're done buffering. | 143 // subsequent reads until we're done buffering. |
| 150 bool BufferedResourceHandler::OnWillRead(int request_id, net::IOBuffer** buf, | 144 bool BufferedResourceHandler::OnWillRead(int request_id, net::IOBuffer** buf, |
| 151 int* buf_size, int min_size) { | 145 int* buf_size, int min_size) { |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 const std::vector<WebPluginInfo>& plugins) { | 458 const std::vector<WebPluginInfo>& plugins) { |
| 465 bool defer = false; | 459 bool defer = false; |
| 466 if (!ProcessResponse(&defer)) { | 460 if (!ProcessResponse(&defer)) { |
| 467 controller()->Cancel(); | 461 controller()->Cancel(); |
| 468 } else if (!defer) { | 462 } else if (!defer) { |
| 469 controller()->Resume(); | 463 controller()->Resume(); |
| 470 } | 464 } |
| 471 } | 465 } |
| 472 | 466 |
| 473 } // namespace content | 467 } // namespace content |
| OLD | NEW |