| 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 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
| 13 #include "chrome/browser/component_updater/component_updater_service.h" | 13 #include "chrome/browser/component_updater/component_updater_service.h" |
| 14 #include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h" | 14 #include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h" |
| 15 #include "chrome/browser/content_settings/host_content_settings_map.h" | 15 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 16 #include "chrome/browser/download/download_request_limiter.h" | 16 #include "chrome/browser/download/download_request_limiter.h" |
| 17 #include "chrome/browser/download/download_resource_throttle.h" | 17 #include "chrome/browser/download/download_resource_throttle.h" |
| 18 #include "chrome/browser/extensions/api/streams_private/streams_private_api.h" | 18 #include "chrome/browser/extensions/api/streams_private/streams_private_api.h" |
| 19 #include "chrome/browser/extensions/extension_renderer_state.h" | 19 #include "chrome/browser/extensions/extension_renderer_state.h" |
| 20 #include "chrome/browser/extensions/user_script_listener.h" | 20 #include "chrome/browser/extensions/user_script_listener.h" |
| 21 #include "chrome/browser/external_protocol/external_protocol_handler.h" | 21 #include "chrome/browser/external_protocol/external_protocol_handler.h" |
| 22 #include "chrome/browser/google/google_util.h" | 22 #include "chrome/browser/google/google_util.h" |
| 23 #include "chrome/browser/metrics/variations/variations_http_header_provider.h" | 23 #include "chrome/browser/metrics/variations/variations_http_header_provider.h" |
| 24 #include "chrome/browser/net/resource_prefetch_predictor_observer.h" | |
| 25 #include "chrome/browser/prefetch/prefetch_field_trial.h" | 24 #include "chrome/browser/prefetch/prefetch_field_trial.h" |
| 26 #include "chrome/browser/prerender/prerender_manager.h" | 25 #include "chrome/browser/prerender/prerender_manager.h" |
| 27 #include "chrome/browser/prerender/prerender_pending_swap_throttle.h" | 26 #include "chrome/browser/prerender/prerender_pending_swap_throttle.h" |
| 28 #include "chrome/browser/prerender/prerender_resource_throttle.h" | 27 #include "chrome/browser/prerender/prerender_resource_throttle.h" |
| 29 #include "chrome/browser/prerender/prerender_tracker.h" | 28 #include "chrome/browser/prerender/prerender_tracker.h" |
| 30 #include "chrome/browser/prerender/prerender_util.h" | 29 #include "chrome/browser/prerender/prerender_util.h" |
| 31 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
| 32 #include "chrome/browser/profiles/profile_io_data.h" | 31 #include "chrome/browser/profiles/profile_io_data.h" |
| 33 #include "chrome/browser/renderer_host/chrome_url_request_user_data.h" | 32 #include "chrome/browser/renderer_host/chrome_url_request_user_data.h" |
| 34 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle_factory.h
" | 33 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle_factory.h
" |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 AppendStandardResourceThrottles(request, | 316 AppendStandardResourceThrottles(request, |
| 318 resource_context, | 317 resource_context, |
| 319 resource_type, | 318 resource_type, |
| 320 throttles); | 319 throttles); |
| 321 if (!is_prerendering) { | 320 if (!is_prerendering) { |
| 322 AppendComponentUpdaterThrottles(request, | 321 AppendComponentUpdaterThrottles(request, |
| 323 resource_context, | 322 resource_context, |
| 324 resource_type, | 323 resource_type, |
| 325 throttles); | 324 throttles); |
| 326 } | 325 } |
| 327 | |
| 328 if (io_data->resource_prefetch_predictor_observer()) { | |
| 329 io_data->resource_prefetch_predictor_observer()->OnRequestStarted( | |
| 330 request, resource_type, child_id, route_id); | |
| 331 } | |
| 332 } | 326 } |
| 333 | 327 |
| 334 void ChromeResourceDispatcherHostDelegate::WillTransferRequestToNewProcess( | 328 void ChromeResourceDispatcherHostDelegate::WillTransferRequestToNewProcess( |
| 335 int old_child_id, | 329 int old_child_id, |
| 336 int old_route_id, | 330 int old_route_id, |
| 337 int old_request_id, | 331 int old_request_id, |
| 338 int new_child_id, | 332 int new_child_id, |
| 339 int new_route_id, | 333 int new_route_id, |
| 340 int new_request_id) { | 334 int new_request_id) { |
| 341 // If a prerender, it have should been aborted on cross-process | 335 // If a prerender, it have should been aborted on cross-process |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 GURL webstore_url(extension_urls::GetWebstoreLaunchURL()); | 616 GURL webstore_url(extension_urls::GetWebstoreLaunchURL()); |
| 623 if (request->url().DomainIs(webstore_url.host().c_str())) { | 617 if (request->url().DomainIs(webstore_url.host().c_str())) { |
| 624 net::HttpResponseHeaders* response_headers = request->response_headers(); | 618 net::HttpResponseHeaders* response_headers = request->response_headers(); |
| 625 if (!response_headers->HasHeaderValue("x-frame-options", "deny") && | 619 if (!response_headers->HasHeaderValue("x-frame-options", "deny") && |
| 626 !response_headers->HasHeaderValue("x-frame-options", "sameorigin")) { | 620 !response_headers->HasHeaderValue("x-frame-options", "sameorigin")) { |
| 627 response_headers->RemoveHeader("x-frame-options"); | 621 response_headers->RemoveHeader("x-frame-options"); |
| 628 response_headers->AddHeader("x-frame-options: sameorigin"); | 622 response_headers->AddHeader("x-frame-options: sameorigin"); |
| 629 } | 623 } |
| 630 } | 624 } |
| 631 | 625 |
| 632 if (io_data->resource_prefetch_predictor_observer()) | |
| 633 io_data->resource_prefetch_predictor_observer()->OnResponseStarted(request); | |
| 634 | |
| 635 prerender::URLRequestResponseStarted(request); | 626 prerender::URLRequestResponseStarted(request); |
| 636 } | 627 } |
| 637 | 628 |
| 638 void ChromeResourceDispatcherHostDelegate::OnRequestRedirected( | 629 void ChromeResourceDispatcherHostDelegate::OnRequestRedirected( |
| 639 const GURL& redirect_url, | 630 const GURL& redirect_url, |
| 640 net::URLRequest* request, | 631 net::URLRequest* request, |
| 641 content::ResourceContext* resource_context, | 632 content::ResourceContext* resource_context, |
| 642 content::ResourceResponse* response) { | 633 content::ResourceResponse* response) { |
| 643 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | 634 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
| 644 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 635 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
| 645 | 636 |
| 646 #if defined(ENABLE_ONE_CLICK_SIGNIN) | 637 #if defined(ENABLE_ONE_CLICK_SIGNIN) |
| 647 // See if the response contains the Google-Accounts-SignIn header. If so, | 638 // See if the response contains the Google-Accounts-SignIn header. If so, |
| 648 // then the user has just finished signing in, and the server is allowing the | 639 // then the user has just finished signing in, and the server is allowing the |
| 649 // browser to suggest connecting the user's profile to the account. | 640 // browser to suggest connecting the user's profile to the account. |
| 650 OneClickSigninHelper::ShowInfoBarIfPossible(request, io_data, | 641 OneClickSigninHelper::ShowInfoBarIfPossible(request, io_data, |
| 651 info->GetChildID(), | 642 info->GetChildID(), |
| 652 info->GetRouteID()); | 643 info->GetRouteID()); |
| 653 AppendChromeSyncGaiaHeader(request, resource_context); | 644 AppendChromeSyncGaiaHeader(request, resource_context); |
| 654 #endif | 645 #endif |
| 655 | 646 |
| 656 // In the Mirror world, Chrome should append a X-Chrome-Connected header to | 647 // In the Mirror world, Chrome should append a X-Chrome-Connected header to |
| 657 // all Gaia requests from a connected profile so Gaia could return a 204 | 648 // all Gaia requests from a connected profile so Gaia could return a 204 |
| 658 // response and let Chrome handle the action with native UI. The only | 649 // response and let Chrome handle the action with native UI. The only |
| 659 // exception is requests from gaia webview, since the native profile | 650 // exception is requests from gaia webview, since the native profile |
| 660 // management UI is built on top of it. | 651 // management UI is built on top of it. |
| 661 signin::AppendMirrorRequestHeaderIfPossible(request, redirect_url, io_data, | 652 signin::AppendMirrorRequestHeaderIfPossible(request, redirect_url, io_data, |
| 662 info->GetChildID(), info->GetRouteID()); | 653 info->GetChildID(), info->GetRouteID()); |
| 663 | |
| 664 if (io_data->resource_prefetch_predictor_observer()) { | |
| 665 io_data->resource_prefetch_predictor_observer()->OnRequestRedirected( | |
| 666 redirect_url, request); | |
| 667 } | |
| 668 } | 654 } |
| OLD | NEW |