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 // The --site-per-process flag enables an out-of-process iframes |
| 481 // prototype. It works by changing the MIME type of cross-site subframe |
| 482 // responses to a Chrome specific one. This new type causes the subframe |
| 483 // to be replaced by a <webview> tag with the same URL, which results in |
| 484 // using a renderer in a different process. |
| 485 // |
| 486 // For prototyping purposes, we will use a small hack to ensure same site |
| 487 // iframes are not changed. We can compare the URL for the subframe |
| 488 // request with the referrer. If the two don't match, then it should be a |
| 489 // cross-site iframe. |
| 490 // Also, we don't do the MIME type change for chrome:// URLs, as those |
| 491 // require different privileges and are not allowed in regular renderers. |
| 492 // |
| 493 // The usage of SiteInstance::IsSameWebSite is safe on the IO thread, |
| 494 // if the browser_context parameter is NULL. This does not work for hosted |
| 495 // apps, but should be fine for prototyping. |
| 496 // TODO(nasko): Once the SiteInstance check is fixed, ensure we do the |
| 497 // right thing here. http://crbug.com/160576 |
| 498 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 499 if (command_line.HasSwitch(switches::kSitePerProcess) && |
| 500 GetRequestInfo()->GetResourceType() == ResourceType::SUB_FRAME && |
| 501 response->head.mime_type == "text/html" && |
| 502 !request_->url().SchemeIs(chrome::kChromeUIScheme) && |
| 503 !SiteInstance::IsSameWebSite(NULL, request_->url(), |
| 504 request_->GetSanitizedReferrer())) { |
| 505 response->head.mime_type = "application/browser-plugin"; |
| 506 } |
| 507 |
478 if (request_->ssl_info().cert) { | 508 if (request_->ssl_info().cert) { |
479 int cert_id = | 509 int cert_id = |
480 CertStore::GetInstance()->StoreCert(request_->ssl_info().cert, | 510 CertStore::GetInstance()->StoreCert(request_->ssl_info().cert, |
481 info->GetChildID()); | 511 info->GetChildID()); |
482 response->head.security_info = SerializeSecurityInfo( | 512 response->head.security_info = SerializeSecurityInfo( |
483 cert_id, | 513 cert_id, |
484 request_->ssl_info().cert_status, | 514 request_->ssl_info().cert_status, |
485 request_->ssl_info().security_bits, | 515 request_->ssl_info().security_bits, |
486 request_->ssl_info().connection_status); | 516 request_->ssl_info().connection_status); |
487 } else { | 517 } else { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 // we resume. | 619 // we resume. |
590 deferred_stage_ = DEFERRED_FINISH; | 620 deferred_stage_ = DEFERRED_FINISH; |
591 } | 621 } |
592 } | 622 } |
593 | 623 |
594 void ResourceLoader::CallDidFinishLoading() { | 624 void ResourceLoader::CallDidFinishLoading() { |
595 delegate_->DidFinishLoading(this); | 625 delegate_->DidFinishLoading(this); |
596 } | 626 } |
597 | 627 |
598 } // namespace content | 628 } // namespace content |
OLD | NEW |