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