OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/renderer_host/buffered_resource_handler.h" | 5 #include "chrome/browser/renderer_host/buffered_resource_handler.h" |
6 | 6 |
7 #include "base/histogram.h" | 7 #include "base/histogram.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "net/base/mime_sniffer.h" | 9 #include "net/base/mime_sniffer.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 } | 151 } |
152 | 152 |
153 if (sniffing_blocked && mime_type.empty()) { | 153 if (sniffing_blocked && mime_type.empty()) { |
154 // Ugg. The server told us not to sniff the content but didn't give us a | 154 // Ugg. The server told us not to sniff the content but didn't give us a |
155 // mime type. What's a browser to do? Turns out, we're supposed to treat | 155 // mime type. What's a browser to do? Turns out, we're supposed to treat |
156 // the response as "text/plain". This is the most secure option. | 156 // the response as "text/plain". This is the most secure option. |
157 mime_type.assign("text/plain"); | 157 mime_type.assign("text/plain"); |
158 response_->response_head.mime_type.assign(mime_type); | 158 response_->response_head.mime_type.assign(mime_type); |
159 } | 159 } |
160 | 160 |
| 161 if (mime_type == "application/rss+xml" || |
| 162 mime_type == "application/atom+xml") { |
| 163 // Sad face. The server told us that they wanted us to treat the response |
| 164 // as RSS or Atom. Unfortunately, we don't have a built-in feed previewer |
| 165 // like other browsers. We can't just render the content as XML because |
| 166 // web sites let third parties inject arbitrary script into their RSS |
| 167 // feeds. That leaves us with little choice but to practically ignore the |
| 168 // response. In the future, when we have an RSS feed previewer, we can |
| 169 // remove this logic. |
| 170 mime_type.assign("text/plain"); |
| 171 response_->response_head.mime_type.assign(mime_type); |
| 172 } |
| 173 |
161 if (ShouldBuffer(request_->url(), mime_type)) { | 174 if (ShouldBuffer(request_->url(), mime_type)) { |
162 // This is a temporary fix for the fact that webkit expects to have | 175 // This is a temporary fix for the fact that webkit expects to have |
163 // enough data to decode the doctype in order to select the rendering | 176 // enough data to decode the doctype in order to select the rendering |
164 // mode. | 177 // mode. |
165 should_buffer_ = true; | 178 should_buffer_ = true; |
166 LOG(INFO) << "To buffer: " << request_->url().spec(); | 179 LOG(INFO) << "To buffer: " << request_->url().spec(); |
167 return true; | 180 return true; |
168 } | 181 } |
169 return false; | 182 return false; |
170 } | 183 } |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 real_handler_ = download_handler; | 299 real_handler_ = download_handler; |
287 } | 300 } |
288 return real_handler_->OnResponseStarted(request_id, response_); | 301 return real_handler_->OnResponseStarted(request_id, response_); |
289 } | 302 } |
290 | 303 |
291 bool BufferedResourceHandler::DidBufferEnough(int bytes_read) { | 304 bool BufferedResourceHandler::DidBufferEnough(int bytes_read) { |
292 const int kRequiredLength = 256; | 305 const int kRequiredLength = 256; |
293 | 306 |
294 return bytes_read >= kRequiredLength; | 307 return bytes_read >= kRequiredLength; |
295 } | 308 } |
OLD | NEW |