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/renderer_host/buffered_resource_handler.h" | 5 #include "content/browser/renderer_host/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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 } | 176 } |
177 | 177 |
178 if (sniffing_blocked && mime_type.empty() && !not_modified_status) { | 178 if (sniffing_blocked && mime_type.empty() && !not_modified_status) { |
179 // Ugg. The server told us not to sniff the content but didn't give us a | 179 // Ugg. The server told us not to sniff the content but didn't give us a |
180 // mime type. What's a browser to do? Turns out, we're supposed to treat | 180 // mime type. What's a browser to do? Turns out, we're supposed to treat |
181 // the response as "text/plain". This is the most secure option. | 181 // the response as "text/plain". This is the most secure option. |
182 mime_type.assign("text/plain"); | 182 mime_type.assign("text/plain"); |
183 response_->mime_type.assign(mime_type); | 183 response_->mime_type.assign(mime_type); |
184 } | 184 } |
185 | 185 |
186 /* | |
darin (slow to review)
2012/03/10 01:02:14
are these comments intended?
Greg Billock
2012/03/13 17:56:10
They're needed to enable feed content type handlin
| |
186 if (mime_type == "application/rss+xml" || | 187 if (mime_type == "application/rss+xml" || |
187 mime_type == "application/atom+xml") { | 188 mime_type == "application/atom+xml") { |
188 // Sad face. The server told us that they wanted us to treat the response | 189 // Sad face. The server told us that they wanted us to treat the response |
189 // as RSS or Atom. Unfortunately, we don't have a built-in feed previewer | 190 // as RSS or Atom. Unfortunately, we don't have a built-in feed previewer |
190 // like other browsers. We can't just render the content as XML because | 191 // like other browsers. We can't just render the content as XML because |
191 // web sites let third parties inject arbitrary script into their RSS | 192 // web sites let third parties inject arbitrary script into their RSS |
192 // feeds. That leaves us with little choice but to practically ignore the | 193 // feeds. That leaves us with little choice but to practically ignore the |
193 // response. In the future, when we have an RSS feed previewer, we can | 194 // response. In the future, when we have an RSS feed previewer, we can |
194 // remove this logic. | 195 // remove this logic. |
195 mime_type.assign("text/plain"); | 196 mime_type.assign("text/plain"); |
196 response_->mime_type.assign(mime_type); | 197 response_->mime_type.assign(mime_type); |
197 } | 198 } |
199 */ | |
198 | 200 |
199 if (!not_modified_status && ShouldWaitForPlugins()) { | 201 if (!not_modified_status && ShouldWaitForPlugins()) { |
200 wait_for_plugins_ = true; | 202 wait_for_plugins_ = true; |
201 return true; | 203 return true; |
202 } | 204 } |
203 | 205 |
204 return false; | 206 return false; |
205 } | 207 } |
206 | 208 |
207 bool BufferedResourceHandler::DidBufferEnough(int bytes_read) { | 209 bool BufferedResourceHandler::DidBufferEnough(int bytes_read) { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
353 if (!disposition.empty()) { | 355 if (!disposition.empty()) { |
354 net::HttpContentDisposition parsed_disposition(disposition, std::string()); | 356 net::HttpContentDisposition parsed_disposition(disposition, std::string()); |
355 if (parsed_disposition.is_attachment()) | 357 if (parsed_disposition.is_attachment()) |
356 return true; | 358 return true; |
357 } | 359 } |
358 | 360 |
359 if (host_->delegate() && | 361 if (host_->delegate() && |
360 host_->delegate()->ShouldForceDownloadResource(request_->url(), type)) | 362 host_->delegate()->ShouldForceDownloadResource(request_->url(), type)) |
361 return true; | 363 return true; |
362 | 364 |
365 // mime type support currently says it supports feed types. | |
366 if (type == "application/rss+xml" || | |
367 type == "application/atom+xml") { | |
368 return true; | |
369 } | |
370 | |
363 // MIME type checking. | 371 // MIME type checking. |
364 if (net::IsSupportedMimeType(type)) | 372 if (net::IsSupportedMimeType(type)) |
365 return false; | 373 return false; |
366 | 374 |
367 // Finally, check the plugin list. | 375 // Finally, check the plugin list. |
368 bool allow_wildcard = false; | 376 bool allow_wildcard = false; |
369 ResourceDispatcherHostRequestInfo* info = | 377 ResourceDispatcherHostRequestInfo* info = |
370 ResourceDispatcherHost::InfoForRequest(request_); | 378 ResourceDispatcherHost::InfoForRequest(request_); |
371 bool stale = false; | 379 bool stale = false; |
372 webkit::WebPluginInfo plugin; | 380 webkit::WebPluginInfo plugin; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
461 return; | 469 return; |
462 | 470 |
463 ResourceDispatcherHostRequestInfo* info = | 471 ResourceDispatcherHostRequestInfo* info = |
464 ResourceDispatcherHost::InfoForRequest(request_); | 472 ResourceDispatcherHost::InfoForRequest(request_); |
465 host_->PauseRequest(info->child_id(), info->request_id(), false); | 473 host_->PauseRequest(info->child_id(), info->request_id(), false); |
466 if (!CompleteResponseStarted(info->request_id())) | 474 if (!CompleteResponseStarted(info->request_id())) |
467 host_->CancelRequest(info->child_id(), info->request_id(), false); | 475 host_->CancelRequest(info->child_id(), info->request_id(), false); |
468 } | 476 } |
469 | 477 |
470 } // namespace content | 478 } // namespace content |
OLD | NEW |