Chromium Code Reviews| 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/resource_loader.h" | 5 #include "content/browser/loader/resource_loader.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "content/browser/child_process_security_policy_impl.h" | 10 #include "content/browser/child_process_security_policy_impl.h" |
| 11 #include "content/browser/loader/doomed_resource_handler.h" | 11 #include "content/browser/loader/doomed_resource_handler.h" |
| 12 #include "content/browser/loader/resource_loader_delegate.h" | 12 #include "content/browser/loader/resource_loader_delegate.h" |
| 13 #include "content/browser/loader/resource_request_info_impl.h" | 13 #include "content/browser/loader/resource_request_info_impl.h" |
| 14 #include "content/browser/ssl/ssl_client_auth_handler.h" | 14 #include "content/browser/ssl/ssl_client_auth_handler.h" |
| 15 #include "content/browser/ssl/ssl_manager.h" | 15 #include "content/browser/ssl/ssl_manager.h" |
| 16 #include "content/common/ssl_status_serialization.h" | 16 #include "content/common/ssl_status_serialization.h" |
| 17 #include "content/public/browser/cert_store.h" | 17 #include "content/public/browser/cert_store.h" |
| 18 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" | 18 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" |
| 19 #include "content/public/browser/site_instance.h" | |
| 19 #include "content/public/common/content_client.h" | 20 #include "content/public/common/content_client.h" |
| 20 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
| 21 #include "content/public/common/resource_response.h" | 22 #include "content/public/common/resource_response.h" |
| 23 #include "content/public/common/url_constants.h" | |
| 22 #include "net/base/load_flags.h" | 24 #include "net/base/load_flags.h" |
| 23 #include "net/http/http_response_headers.h" | 25 #include "net/http/http_response_headers.h" |
| 24 #include "webkit/appcache/appcache_interceptor.h" | 26 #include "webkit/appcache/appcache_interceptor.h" |
| 25 | 27 |
| 26 using base::TimeDelta; | 28 using base::TimeDelta; |
| 27 using base::TimeTicks; | 29 using base::TimeTicks; |
| 28 | 30 |
| 29 namespace content { | 31 namespace content { |
| 30 namespace { | 32 namespace { |
| 31 | 33 |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 weak_ptr_factory_.GetWeakPtr())); | 470 weak_ptr_factory_.GetWeakPtr())); |
| 469 } | 471 } |
| 470 } | 472 } |
| 471 | 473 |
| 472 void ResourceLoader::CompleteResponseStarted() { | 474 void ResourceLoader::CompleteResponseStarted() { |
| 473 ResourceRequestInfoImpl* info = GetRequestInfo(); | 475 ResourceRequestInfoImpl* info = GetRequestInfo(); |
| 474 | 476 |
| 475 scoped_refptr<ResourceResponse> response(new ResourceResponse()); | 477 scoped_refptr<ResourceResponse> response(new ResourceResponse()); |
| 476 PopulateResourceResponse(request_.get(), response); | 478 PopulateResourceResponse(request_.get(), response); |
| 477 | 479 |
| 480 // Change the MIME type of the response if --site-per-process flag | |
|
Charlie Reis
2013/01/17 19:44:54
We should introduce this comment very clearly sayi
nasko
2013/01/17 22:19:13
Done.
| |
| 481 // is passed and the current request is for the Sub-Frame page. Avoid | |
|
Charlie Reis
2013/01/17 19:44:54
nit: the Sub-Frame page -> for a subframe.
nasko
2013/01/17 22:19:13
Done.
| |
| 482 // doing this for chrome:// URLs, as those require different privileges | |
| 483 // and are not allowed in regular renderers. | |
| 484 // | |
| 485 // We are going to use a small hack for prototyping purposes - compare | |
| 486 // the URL for the subframe with the referrer. If the two don't match, | |
| 487 // then it should be a cross-site iframe. | |
| 488 // The usage of SiteInstance::IsSameWebSite is safe on the IO thread, | |
| 489 // if the browser_context parameter is NULL. This does not work for hosted | |
| 490 // apps, but should be fine for prototyping. | |
| 491 // TODO(nasko): Once the SiteInstance check is fixed, ensure we do the | |
| 492 // right thing here. http://crbug.com/160576 | |
| 493 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 494 if (command_line.HasSwitch(switches::kSitePerProcess) && | |
| 495 GetRequestInfo()->GetResourceType() == ResourceType::SUB_FRAME && | |
| 496 response->head.mime_type == "text/html" && | |
| 497 !request_->url().SchemeIs(chrome::kChromeUIScheme) && | |
| 498 !SiteInstance::IsSameWebSite(NULL, request_->url(), | |
| 499 request_->GetSanitizedReferrer())) { | |
| 500 response->head.mime_type = "application/browser-plugin"; | |
| 501 } | |
| 502 | |
| 478 if (request_->ssl_info().cert) { | 503 if (request_->ssl_info().cert) { |
| 479 int cert_id = | 504 int cert_id = |
| 480 CertStore::GetInstance()->StoreCert(request_->ssl_info().cert, | 505 CertStore::GetInstance()->StoreCert(request_->ssl_info().cert, |
| 481 info->GetChildID()); | 506 info->GetChildID()); |
| 482 response->head.security_info = SerializeSecurityInfo( | 507 response->head.security_info = SerializeSecurityInfo( |
| 483 cert_id, | 508 cert_id, |
| 484 request_->ssl_info().cert_status, | 509 request_->ssl_info().cert_status, |
| 485 request_->ssl_info().security_bits, | 510 request_->ssl_info().security_bits, |
| 486 request_->ssl_info().connection_status); | 511 request_->ssl_info().connection_status); |
| 487 } else { | 512 } else { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 589 // we resume. | 614 // we resume. |
| 590 deferred_stage_ = DEFERRED_FINISH; | 615 deferred_stage_ = DEFERRED_FINISH; |
| 591 } | 616 } |
| 592 } | 617 } |
| 593 | 618 |
| 594 void ResourceLoader::CallDidFinishLoading() { | 619 void ResourceLoader::CallDidFinishLoading() { |
| 595 delegate_->DidFinishLoading(this); | 620 delegate_->DidFinishLoading(this); |
| 596 } | 621 } |
| 597 | 622 |
| 598 } // namespace content | 623 } // namespace content |
| OLD | NEW |