| 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 "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" | 5 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| 11 #include "base/guid.h" | 11 #include "base/guid.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
| 15 #include "chrome/browser/component_updater/component_updater_resource_throttle.h
" | 15 #include "chrome/browser/component_updater/component_updater_resource_throttle.h
" |
| 16 #include "chrome/browser/content_settings/host_content_settings_map.h" | 16 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 17 #include "chrome/browser/download/download_request_limiter.h" | 17 #include "chrome/browser/download/download_request_limiter.h" |
| 18 #include "chrome/browser/download/download_resource_throttle.h" | 18 #include "chrome/browser/download/download_resource_throttle.h" |
| 19 #include "chrome/browser/net/resource_prefetch_predictor_observer.h" |
| 19 #include "chrome/browser/prefetch/prefetch.h" | 20 #include "chrome/browser/prefetch/prefetch.h" |
| 20 #include "chrome/browser/prerender/prerender_manager.h" | 21 #include "chrome/browser/prerender/prerender_manager.h" |
| 21 #include "chrome/browser/prerender/prerender_manager_factory.h" | 22 #include "chrome/browser/prerender/prerender_manager_factory.h" |
| 22 #include "chrome/browser/prerender/prerender_pending_swap_throttle.h" | 23 #include "chrome/browser/prerender/prerender_pending_swap_throttle.h" |
| 23 #include "chrome/browser/prerender/prerender_resource_throttle.h" | 24 #include "chrome/browser/prerender/prerender_resource_throttle.h" |
| 24 #include "chrome/browser/prerender/prerender_tracker.h" | 25 #include "chrome/browser/prerender/prerender_tracker.h" |
| 25 #include "chrome/browser/prerender/prerender_util.h" | 26 #include "chrome/browser/prerender/prerender_util.h" |
| 26 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
| 27 #include "chrome/browser/profiles/profile_io_data.h" | 28 #include "chrome/browser/profiles/profile_io_data.h" |
| 28 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle_factory.h
" | 29 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle_factory.h
" |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 resource_type, | 404 resource_type, |
| 404 throttles); | 405 throttles); |
| 405 #if !defined(DISABLE_NACL) | 406 #if !defined(DISABLE_NACL) |
| 406 if (!is_prerendering) { | 407 if (!is_prerendering) { |
| 407 AppendComponentUpdaterThrottles(request, | 408 AppendComponentUpdaterThrottles(request, |
| 408 resource_context, | 409 resource_context, |
| 409 resource_type, | 410 resource_type, |
| 410 throttles); | 411 throttles); |
| 411 } | 412 } |
| 412 #endif | 413 #endif |
| 414 |
| 415 if (io_data->resource_prefetch_predictor_observer()) { |
| 416 io_data->resource_prefetch_predictor_observer()->OnRequestStarted( |
| 417 request, resource_type, info->GetChildID(), info->GetRenderFrameID()); |
| 418 } |
| 413 } | 419 } |
| 414 | 420 |
| 415 void ChromeResourceDispatcherHostDelegate::DownloadStarting( | 421 void ChromeResourceDispatcherHostDelegate::DownloadStarting( |
| 416 net::URLRequest* request, | 422 net::URLRequest* request, |
| 417 content::ResourceContext* resource_context, | 423 content::ResourceContext* resource_context, |
| 418 int child_id, | 424 int child_id, |
| 419 int route_id, | 425 int route_id, |
| 420 int request_id, | 426 int request_id, |
| 421 bool is_content_initiated, | 427 bool is_content_initiated, |
| 422 bool must_download, | 428 bool must_download, |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 GURL webstore_url(extension_urls::GetWebstoreLaunchURL()); | 670 GURL webstore_url(extension_urls::GetWebstoreLaunchURL()); |
| 665 if (request->url().DomainIs(webstore_url.host().c_str())) { | 671 if (request->url().DomainIs(webstore_url.host().c_str())) { |
| 666 net::HttpResponseHeaders* response_headers = request->response_headers(); | 672 net::HttpResponseHeaders* response_headers = request->response_headers(); |
| 667 if (!response_headers->HasHeaderValue("x-frame-options", "deny") && | 673 if (!response_headers->HasHeaderValue("x-frame-options", "deny") && |
| 668 !response_headers->HasHeaderValue("x-frame-options", "sameorigin")) { | 674 !response_headers->HasHeaderValue("x-frame-options", "sameorigin")) { |
| 669 response_headers->RemoveHeader("x-frame-options"); | 675 response_headers->RemoveHeader("x-frame-options"); |
| 670 response_headers->AddHeader("x-frame-options: sameorigin"); | 676 response_headers->AddHeader("x-frame-options: sameorigin"); |
| 671 } | 677 } |
| 672 } | 678 } |
| 673 | 679 |
| 680 if (io_data->resource_prefetch_predictor_observer()) |
| 681 io_data->resource_prefetch_predictor_observer()->OnResponseStarted(request); |
| 682 |
| 674 // Ignores x-frame-options for the chrome signin UI. | 683 // Ignores x-frame-options for the chrome signin UI. |
| 675 const std::string request_spec( | 684 const std::string request_spec( |
| 676 request->first_party_for_cookies().GetOrigin().spec()); | 685 request->first_party_for_cookies().GetOrigin().spec()); |
| 677 #if defined(OS_CHROMEOS) | 686 #if defined(OS_CHROMEOS) |
| 678 if (request_spec == chrome::kChromeUIOobeURL || | 687 if (request_spec == chrome::kChromeUIOobeURL || |
| 679 request_spec == chrome::kChromeUIChromeSigninURL) { | 688 request_spec == chrome::kChromeUIChromeSigninURL) { |
| 680 #else | 689 #else |
| 681 if (request_spec == chrome::kChromeUIChromeSigninURL) { | 690 if (request_spec == chrome::kChromeUIChromeSigninURL) { |
| 682 #endif | 691 #endif |
| 683 net::HttpResponseHeaders* response_headers = request->response_headers(); | 692 net::HttpResponseHeaders* response_headers = request->response_headers(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 707 AppendChromeSyncGaiaHeader(request, resource_context); | 716 AppendChromeSyncGaiaHeader(request, resource_context); |
| 708 #endif | 717 #endif |
| 709 | 718 |
| 710 // In the Mirror world, Chrome should append a X-Chrome-Connected header to | 719 // In the Mirror world, Chrome should append a X-Chrome-Connected header to |
| 711 // all Gaia requests from a connected profile so Gaia could return a 204 | 720 // all Gaia requests from a connected profile so Gaia could return a 204 |
| 712 // response and let Chrome handle the action with native UI. The only | 721 // response and let Chrome handle the action with native UI. The only |
| 713 // exception is requests from gaia webview, since the native profile | 722 // exception is requests from gaia webview, since the native profile |
| 714 // management UI is built on top of it. | 723 // management UI is built on top of it. |
| 715 signin::AppendMirrorRequestHeaderIfPossible(request, redirect_url, io_data); | 724 signin::AppendMirrorRequestHeaderIfPossible(request, redirect_url, io_data); |
| 716 | 725 |
| 726 if (io_data->resource_prefetch_predictor_observer()) { |
| 727 io_data->resource_prefetch_predictor_observer()->OnRequestRedirected( |
| 728 redirect_url, request); |
| 729 } |
| 730 |
| 717 #if defined(ENABLE_CONFIGURATION_POLICY) | 731 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 718 if (io_data->policy_header_helper()) | 732 if (io_data->policy_header_helper()) |
| 719 io_data->policy_header_helper()->AddPolicyHeaders(redirect_url, request); | 733 io_data->policy_header_helper()->AddPolicyHeaders(redirect_url, request); |
| 720 #endif | 734 #endif |
| 721 } | 735 } |
| 722 | 736 |
| 723 // Notification that a request has completed. | 737 // Notification that a request has completed. |
| 724 void ChromeResourceDispatcherHostDelegate::RequestComplete( | 738 void ChromeResourceDispatcherHostDelegate::RequestComplete( |
| 725 net::URLRequest* url_request) { | 739 net::URLRequest* url_request) { |
| 726 // Jump on the UI thread and inform the prerender about the bytes. | 740 // Jump on the UI thread and inform the prerender about the bytes. |
| 727 const ResourceRequestInfo* info = | 741 const ResourceRequestInfo* info = |
| 728 ResourceRequestInfo::ForRequest(url_request); | 742 ResourceRequestInfo::ForRequest(url_request); |
| 729 if (url_request && !url_request->was_cached()) { | 743 if (url_request && !url_request->was_cached()) { |
| 730 BrowserThread::PostTask(BrowserThread::UI, | 744 BrowserThread::PostTask(BrowserThread::UI, |
| 731 FROM_HERE, | 745 FROM_HERE, |
| 732 base::Bind(&UpdatePrerenderNetworkBytesCallback, | 746 base::Bind(&UpdatePrerenderNetworkBytesCallback, |
| 733 info->GetChildID(), | 747 info->GetChildID(), |
| 734 info->GetRouteID(), | 748 info->GetRouteID(), |
| 735 url_request->GetTotalReceivedBytes())); | 749 url_request->GetTotalReceivedBytes())); |
| 736 } | 750 } |
| 737 } | 751 } |
| 738 | 752 |
| 739 // static | 753 // static |
| 740 void ChromeResourceDispatcherHostDelegate:: | 754 void ChromeResourceDispatcherHostDelegate:: |
| 741 SetExternalProtocolHandlerDelegateForTesting( | 755 SetExternalProtocolHandlerDelegateForTesting( |
| 742 ExternalProtocolHandler::Delegate* delegate) { | 756 ExternalProtocolHandler::Delegate* delegate) { |
| 743 g_external_protocol_handler_delegate = delegate; | 757 g_external_protocol_handler_delegate = delegate; |
| 744 } | 758 } |
| OLD | NEW |