| 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" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 #if defined(USE_SYSTEM_PROTOBUF) | 59 #if defined(USE_SYSTEM_PROTOBUF) |
| 60 #include <google/protobuf/repeated_field.h> | 60 #include <google/protobuf/repeated_field.h> |
| 61 #else | 61 #else |
| 62 #include "third_party/protobuf/src/google/protobuf/repeated_field.h" | 62 #include "third_party/protobuf/src/google/protobuf/repeated_field.h" |
| 63 #endif | 63 #endif |
| 64 | 64 |
| 65 #if defined(OS_ANDROID) | 65 #if defined(OS_ANDROID) |
| 66 #include "chrome/browser/android/intercept_download_resource_throttle.h" | 66 #include "chrome/browser/android/intercept_download_resource_throttle.h" |
| 67 #include "components/navigation_interception/intercept_navigation_delegate.h" | 67 #include "components/navigation_interception/intercept_navigation_delegate.h" |
| 68 #else |
| 69 #include "chrome/browser/apps/app_url_redirector.h" |
| 68 #endif | 70 #endif |
| 69 | 71 |
| 70 #if defined(OS_CHROMEOS) | 72 #if defined(OS_CHROMEOS) |
| 71 #include "chrome/browser/chromeos/login/merge_session_throttle.h" | 73 #include "chrome/browser/chromeos/login/merge_session_throttle.h" |
| 72 // TODO(oshima): Enable this for other platforms. | 74 // TODO(oshima): Enable this for other platforms. |
| 73 #include "chrome/browser/renderer_host/offline_resource_throttle.h" | 75 #include "chrome/browser/renderer_host/offline_resource_throttle.h" |
| 74 #endif | 76 #endif |
| 75 | 77 |
| 76 using content::BrowserThread; | 78 using content::BrowserThread; |
| 77 using content::RenderViewHost; | 79 using content::RenderViewHost; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 | 258 |
| 257 ChromeURLRequestUserData* user_data = | 259 ChromeURLRequestUserData* user_data = |
| 258 ChromeURLRequestUserData::Create(request); | 260 ChromeURLRequestUserData::Create(request); |
| 259 bool is_prerendering = prerender_tracker_->IsPrerenderingOnIOThread( | 261 bool is_prerendering = prerender_tracker_->IsPrerenderingOnIOThread( |
| 260 child_id, route_id); | 262 child_id, route_id); |
| 261 if (is_prerendering) { | 263 if (is_prerendering) { |
| 262 user_data->set_is_prerender(true); | 264 user_data->set_is_prerender(true); |
| 263 request->SetPriority(net::IDLE); | 265 request->SetPriority(net::IDLE); |
| 264 } | 266 } |
| 265 | 267 |
| 268 ProfileIOData* io_data = ProfileIOData::FromResourceContext( |
| 269 resource_context); |
| 270 |
| 271 if (!is_prerendering && resource_type == ResourceType::MAIN_FRAME) { |
| 266 #if defined(OS_ANDROID) | 272 #if defined(OS_ANDROID) |
| 267 if (!is_prerendering && resource_type == ResourceType::MAIN_FRAME) { | |
| 268 throttles->push_back( | 273 throttles->push_back( |
| 269 InterceptNavigationDelegate::CreateThrottleFor(request)); | 274 InterceptNavigationDelegate::CreateThrottleFor(request)); |
| 275 #else |
| 276 // Redirect some navigations to apps that have registered matching URL |
| 277 // handlers ('url_handlers' in the manifest). |
| 278 content::ResourceThrottle* url_to_app_throttle = |
| 279 AppUrlRedirector::MaybeCreateThrottleFor(request, io_data); |
| 280 if (url_to_app_throttle) |
| 281 throttles->push_back(url_to_app_throttle); |
| 282 #endif |
| 270 } | 283 } |
| 271 #endif | 284 |
| 272 #if defined(OS_CHROMEOS) | 285 #if defined(OS_CHROMEOS) |
| 273 if (resource_type == ResourceType::MAIN_FRAME) { | 286 if (resource_type == ResourceType::MAIN_FRAME) { |
| 274 // We check offline first, then check safe browsing so that we still can | 287 // We check offline first, then check safe browsing so that we still can |
| 275 // block unsafe site after we remove offline page. | 288 // block unsafe site after we remove offline page. |
| 276 throttles->push_back(new OfflineResourceThrottle( | 289 throttles->push_back(new OfflineResourceThrottle( |
| 277 child_id, route_id, request, appcache_service)); | 290 child_id, route_id, request, appcache_service)); |
| 278 // Add interstitial page while merge session process (cookie | 291 // Add interstitial page while merge session process (cookie |
| 279 // reconstruction from OAuth2 refresh token in ChromeOS login) is still in | 292 // reconstruction from OAuth2 refresh token in ChromeOS login) is still in |
| 280 // progress while we are attempting to load a google property. | 293 // progress while we are attempting to load a google property. |
| 281 throttles->push_back(new MergeSessionThrottle( | 294 throttles->push_back(new MergeSessionThrottle( |
| 282 child_id, route_id, request)); | 295 child_id, route_id, request)); |
| 283 } | 296 } |
| 284 #endif | 297 #endif |
| 285 | 298 |
| 286 // Don't attempt to append headers to requests that have already started. | 299 // Don't attempt to append headers to requests that have already started. |
| 287 // TODO(stevet): Remove this once the request ordering issues are resolved | 300 // TODO(stevet): Remove this once the request ordering issues are resolved |
| 288 // in crbug.com/128048. | 301 // in crbug.com/128048. |
| 289 if (!request->is_pending()) { | 302 if (!request->is_pending()) { |
| 290 net::HttpRequestHeaders headers; | 303 net::HttpRequestHeaders headers; |
| 291 headers.CopyFrom(request->extra_request_headers()); | 304 headers.CopyFrom(request->extra_request_headers()); |
| 292 ProfileIOData* io_data = ProfileIOData::FromResourceContext( | |
| 293 resource_context); | |
| 294 bool incognito = io_data->is_incognito(); | 305 bool incognito = io_data->is_incognito(); |
| 295 chrome_variations::VariationsHttpHeaderProvider::GetInstance()-> | 306 chrome_variations::VariationsHttpHeaderProvider::GetInstance()-> |
| 296 AppendHeaders(request->url(), | 307 AppendHeaders(request->url(), |
| 297 incognito, | 308 incognito, |
| 298 !incognito && io_data->GetMetricsEnabledStateOnIOThread(), | 309 !incognito && io_data->GetMetricsEnabledStateOnIOThread(), |
| 299 &headers); | 310 &headers); |
| 300 request->SetExtraRequestHeaders(headers); | 311 request->SetExtraRequestHeaders(headers); |
| 301 } | 312 } |
| 302 | 313 |
| 303 #if defined(ENABLE_ONE_CLICK_SIGNIN) | 314 #if defined(ENABLE_ONE_CLICK_SIGNIN) |
| 304 AppendChromeSyncGaiaHeader(request, resource_context); | 315 AppendChromeSyncGaiaHeader(request, resource_context); |
| 305 #endif | 316 #endif |
| 306 | 317 |
| 307 AppendStandardResourceThrottles(request, | 318 AppendStandardResourceThrottles(request, |
| 308 resource_context, | 319 resource_context, |
| 309 child_id, | 320 child_id, |
| 310 route_id, | 321 route_id, |
| 311 resource_type, | 322 resource_type, |
| 312 throttles); | 323 throttles); |
| 313 | 324 |
| 314 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | |
| 315 if (io_data->resource_prefetch_predictor_observer()) { | 325 if (io_data->resource_prefetch_predictor_observer()) { |
| 316 io_data->resource_prefetch_predictor_observer()->OnRequestStarted( | 326 io_data->resource_prefetch_predictor_observer()->OnRequestStarted( |
| 317 request, resource_type, child_id, route_id); | 327 request, resource_type, child_id, route_id); |
| 318 } | 328 } |
| 319 } | 329 } |
| 320 | 330 |
| 321 void ChromeResourceDispatcherHostDelegate::DownloadStarting( | 331 void ChromeResourceDispatcherHostDelegate::DownloadStarting( |
| 322 net::URLRequest* request, | 332 net::URLRequest* request, |
| 323 content::ResourceContext* resource_context, | 333 content::ResourceContext* resource_context, |
| 324 int child_id, | 334 int child_id, |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 if (!prerender::PrerenderManager::DoesURLHaveValidScheme(redirect_url) && | 651 if (!prerender::PrerenderManager::DoesURLHaveValidScheme(redirect_url) && |
| 642 ResourceRequestInfo::ForRequest(request)->GetAssociatedRenderView( | 652 ResourceRequestInfo::ForRequest(request)->GetAssociatedRenderView( |
| 643 &child_id, &route_id) && | 653 &child_id, &route_id) && |
| 644 prerender_tracker_->IsPrerenderingOnIOThread(child_id, route_id)) { | 654 prerender_tracker_->IsPrerenderingOnIOThread(child_id, route_id)) { |
| 645 ReportUnsupportedPrerenderScheme(redirect_url); | 655 ReportUnsupportedPrerenderScheme(redirect_url); |
| 646 prerender_tracker_->TryCancel( | 656 prerender_tracker_->TryCancel( |
| 647 child_id, route_id, prerender::FINAL_STATUS_UNSUPPORTED_SCHEME); | 657 child_id, route_id, prerender::FINAL_STATUS_UNSUPPORTED_SCHEME); |
| 648 request->Cancel(); | 658 request->Cancel(); |
| 649 } | 659 } |
| 650 } | 660 } |
| OLD | NEW |