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