| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/histogram.h" | 9 #include "base/histogram.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 bool BufferedResourceHandler::CompleteResponseStarted(int request_id, | 297 bool BufferedResourceHandler::CompleteResponseStarted(int request_id, |
| 298 bool in_complete) { | 298 bool in_complete) { |
| 299 ResourceDispatcherHostRequestInfo* info = | 299 ResourceDispatcherHostRequestInfo* info = |
| 300 ResourceDispatcherHost::InfoForRequest(request_); | 300 ResourceDispatcherHost::InfoForRequest(request_); |
| 301 std::string mime_type; | 301 std::string mime_type; |
| 302 request_->GetMimeType(&mime_type); | 302 request_->GetMimeType(&mime_type); |
| 303 | 303 |
| 304 // Check if this is an X.509 certificate, if yes, let it be handled | 304 // Check if this is an X.509 certificate, if yes, let it be handled |
| 305 // by X509UserCertResourceHandler. | 305 // by X509UserCertResourceHandler. |
| 306 if (mime_type == "application/x-x509-user-cert") { | 306 if (mime_type == "application/x-x509-user-cert") { |
| 307 | |
| 308 // This is entirely similar to how DownloadThrottlingResourceHandler | 307 // This is entirely similar to how DownloadThrottlingResourceHandler |
| 309 // works except we are doing it for an X.509 client certificates. | 308 // works except we are doing it for an X.509 client certificates. |
| 310 | 309 |
| 311 if (response_->response_head.headers && // Can be NULL if FTP. | 310 if (response_->response_head.headers && // Can be NULL if FTP. |
| 312 response_->response_head.headers->response_code() / 100 != 2) { | 311 response_->response_head.headers->response_code() / 100 != 2) { |
| 313 // The response code indicates that this is an error page, but we are | 312 // The response code indicates that this is an error page, but we are |
| 314 // expecting an X.509 user certificate. We follow Firefox here and show | 313 // expecting an X.509 user certificate. We follow Firefox here and show |
| 315 // our own error page instead of handling the error page as a | 314 // our own error page instead of handling the error page as a |
| 316 // certificate. | 315 // certificate. |
| 317 // TODO(abarth): We should abstract the response_code test, but this kind | 316 // TODO(abarth): We should abstract the response_code test, but this kind |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 CHECK((buf_len >= bytes_read_) && (bytes_read_ >= 0)); | 449 CHECK((buf_len >= bytes_read_) && (bytes_read_ >= 0)); |
| 451 memcpy(buf->data(), read_buffer_->data(), bytes_read_); | 450 memcpy(buf->data(), read_buffer_->data(), bytes_read_); |
| 452 } | 451 } |
| 453 | 452 |
| 454 // Inform the original ResourceHandler that this will be handled entirely by | 453 // Inform the original ResourceHandler that this will be handled entirely by |
| 455 // the new ResourceHandler. | 454 // the new ResourceHandler. |
| 456 real_handler_->OnResponseStarted(info->request_id(), response_); | 455 real_handler_->OnResponseStarted(info->request_id(), response_); |
| 457 URLRequestStatus status(URLRequestStatus::HANDLED_EXTERNALLY, 0); | 456 URLRequestStatus status(URLRequestStatus::HANDLED_EXTERNALLY, 0); |
| 458 real_handler_->OnResponseCompleted(info->request_id(), status, std::string()); | 457 real_handler_->OnResponseCompleted(info->request_id(), status, std::string()); |
| 459 | 458 |
| 459 // Remove the non-owning pointer to the CrossSiteResourceHandler, if any, |
| 460 // from the extra request info because the CrossSiteResourceHandler (part of |
| 461 // the original ResourceHandler chain) will be deleted by the next statement. |
| 462 info->set_cross_site_handler(NULL); |
| 463 |
| 460 // This is handled entirely within the new ResourceHandler, so just reset the | 464 // This is handled entirely within the new ResourceHandler, so just reset the |
| 461 // original ResourceHandler. | 465 // original ResourceHandler. |
| 462 real_handler_ = handler; | 466 real_handler_ = handler; |
| 463 } | 467 } |
| 464 | 468 |
| 465 void BufferedResourceHandler::LoadPlugins() { | 469 void BufferedResourceHandler::LoadPlugins() { |
| 466 std::vector<WebPluginInfo> plugins; | 470 std::vector<WebPluginInfo> plugins; |
| 467 NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins); | 471 NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins); |
| 468 | 472 |
| 469 ChromeThread::PostTask( | 473 ChromeThread::PostTask( |
| 470 ChromeThread::IO, FROM_HERE, | 474 ChromeThread::IO, FROM_HERE, |
| 471 NewRunnableMethod(this, &BufferedResourceHandler::OnPluginsLoaded)); | 475 NewRunnableMethod(this, &BufferedResourceHandler::OnPluginsLoaded)); |
| 472 } | 476 } |
| 473 | 477 |
| 474 void BufferedResourceHandler::OnPluginsLoaded() { | 478 void BufferedResourceHandler::OnPluginsLoaded() { |
| 475 wait_for_plugins_ = false; | 479 wait_for_plugins_ = false; |
| 476 if (!request_) | 480 if (!request_) |
| 477 return; | 481 return; |
| 478 | 482 |
| 479 ResourceDispatcherHostRequestInfo* info = | 483 ResourceDispatcherHostRequestInfo* info = |
| 480 ResourceDispatcherHost::InfoForRequest(request_); | 484 ResourceDispatcherHost::InfoForRequest(request_); |
| 481 host_->PauseRequest(info->child_id(), info->request_id(), false); | 485 host_->PauseRequest(info->child_id(), info->request_id(), false); |
| 482 if (!CompleteResponseStarted(info->request_id(), false)) | 486 if (!CompleteResponseStarted(info->request_id(), false)) |
| 483 host_->CancelRequest(info->child_id(), info->request_id(), false); | 487 host_->CancelRequest(info->child_id(), info->request_id(), false); |
| 484 } | 488 } |
| OLD | NEW |