| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/content_settings/host_content_settings_map.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 10 #include "chrome/browser/download/download_request_limiter.h" | 10 #include "chrome/browser/download/download_request_limiter.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle.h" | 23 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle.h" |
| 24 #include "chrome/browser/renderer_host/transfer_navigation_resource_throttle.h" | 24 #include "chrome/browser/renderer_host/transfer_navigation_resource_throttle.h" |
| 25 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 25 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 26 #include "chrome/browser/ui/auto_login_prompter.h" | 26 #include "chrome/browser/ui/auto_login_prompter.h" |
| 27 #include "chrome/browser/ui/login/login_prompt.h" | 27 #include "chrome/browser/ui/login/login_prompt.h" |
| 28 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | 28 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
| 29 #include "chrome/common/chrome_notification_types.h" | 29 #include "chrome/common/chrome_notification_types.h" |
| 30 #include "chrome/common/extensions/user_script.h" | 30 #include "chrome/common/extensions/user_script.h" |
| 31 #include "chrome/common/render_messages.h" | 31 #include "chrome/common/render_messages.h" |
| 32 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 32 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 33 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | |
| 34 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
| 35 #include "content/public/browser/notification_service.h" | 34 #include "content/public/browser/notification_service.h" |
| 36 #include "content/public/browser/render_view_host.h" | 35 #include "content/public/browser/render_view_host.h" |
| 37 #include "content/public/browser/resource_context.h" | 36 #include "content/public/browser/resource_context.h" |
| 37 #include "content/public/browser/resource_request_info.h" |
| 38 #include "net/base/load_flags.h" | 38 #include "net/base/load_flags.h" |
| 39 #include "net/base/ssl_config_service.h" | 39 #include "net/base/ssl_config_service.h" |
| 40 | 40 |
| 41 // TODO(oshima): Enable this for other platforms. | 41 // TODO(oshima): Enable this for other platforms. |
| 42 #if defined(OS_CHROMEOS) | 42 #if defined(OS_CHROMEOS) |
| 43 #include "chrome/browser/renderer_host/offline_resource_throttle.h" | 43 #include "chrome/browser/renderer_host/offline_resource_throttle.h" |
| 44 #endif | 44 #endif |
| 45 | 45 |
| 46 using content::BrowserThread; | 46 using content::BrowserThread; |
| 47 using content::RenderViewHost; | 47 using content::RenderViewHost; |
| 48 using content::ResourceDispatcherHostLoginDelegate; | 48 using content::ResourceDispatcherHostLoginDelegate; |
| 49 using content::ResourceRequestInfo; |
| 49 | 50 |
| 50 namespace { | 51 namespace { |
| 51 | 52 |
| 52 void AddPrerenderOnUI( | 53 void AddPrerenderOnUI( |
| 53 int render_process_id, int render_view_id, | 54 int render_process_id, int render_view_id, |
| 54 const GURL& url, const content::Referrer& referrer) { | 55 const GURL& url, const content::Referrer& referrer) { |
| 55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 56 prerender::PrerenderManager* prerender_manager = | 57 prerender::PrerenderManager* prerender_manager = |
| 57 prerender::FindPrerenderManagerUsingRenderProcessId(render_process_id); | 58 prerender::FindPrerenderManagerUsingRenderProcessId(render_process_id); |
| 58 if (!prerender_manager || !prerender_manager->is_enabled()) | 59 if (!prerender_manager || !prerender_manager->is_enabled()) |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 } | 209 } |
| 209 | 210 |
| 210 bool ChromeResourceDispatcherHostDelegate::AcceptSSLClientCertificateRequest( | 211 bool ChromeResourceDispatcherHostDelegate::AcceptSSLClientCertificateRequest( |
| 211 net::URLRequest* request, net::SSLCertRequestInfo* cert_request_info) { | 212 net::URLRequest* request, net::SSLCertRequestInfo* cert_request_info) { |
| 212 if (request->load_flags() & net::LOAD_PREFETCH) | 213 if (request->load_flags() & net::LOAD_PREFETCH) |
| 213 return false; | 214 return false; |
| 214 | 215 |
| 215 ChromeURLRequestUserData* user_data = ChromeURLRequestUserData::Get(request); | 216 ChromeURLRequestUserData* user_data = ChromeURLRequestUserData::Get(request); |
| 216 if (user_data && user_data->is_prerender()) { | 217 if (user_data && user_data->is_prerender()) { |
| 217 int child_id, route_id; | 218 int child_id, route_id; |
| 218 if (ResourceDispatcherHost::RenderViewForRequest( | 219 if (ResourceRequestInfo::ForRequest(request)->GetAssociatedRenderView( |
| 219 request, &child_id, &route_id)) { | 220 &child_id, &route_id)) { |
| 220 if (prerender_tracker_->TryCancel( | 221 if (prerender_tracker_->TryCancel( |
| 221 child_id, route_id, | 222 child_id, route_id, |
| 222 prerender::FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED)) { | 223 prerender::FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED)) { |
| 223 return false; | 224 return false; |
| 224 } | 225 } |
| 225 } | 226 } |
| 226 } | 227 } |
| 227 | 228 |
| 228 return true; | 229 return true; |
| 229 } | 230 } |
| 230 | 231 |
| 231 bool ChromeResourceDispatcherHostDelegate::AcceptAuthRequest( | 232 bool ChromeResourceDispatcherHostDelegate::AcceptAuthRequest( |
| 232 net::URLRequest* request, | 233 net::URLRequest* request, |
| 233 net::AuthChallengeInfo* auth_info) { | 234 net::AuthChallengeInfo* auth_info) { |
| 234 ChromeURLRequestUserData* user_data = ChromeURLRequestUserData::Get(request); | 235 ChromeURLRequestUserData* user_data = ChromeURLRequestUserData::Get(request); |
| 235 if (!user_data || !user_data->is_prerender()) | 236 if (!user_data || !user_data->is_prerender()) |
| 236 return true; | 237 return true; |
| 237 | 238 |
| 238 int child_id, route_id; | 239 int child_id, route_id; |
| 239 if (!ResourceDispatcherHost::RenderViewForRequest( | 240 if (!ResourceRequestInfo::ForRequest(request)->GetAssociatedRenderView( |
| 240 request, &child_id, &route_id)) { | 241 &child_id, &route_id)) { |
| 241 NOTREACHED(); | 242 NOTREACHED(); |
| 242 return true; | 243 return true; |
| 243 } | 244 } |
| 244 | 245 |
| 245 if (!prerender_tracker_->TryCancelOnIOThread( | 246 if (!prerender_tracker_->TryCancelOnIOThread( |
| 246 child_id, route_id, prerender::FINAL_STATUS_AUTH_NEEDED)) { | 247 child_id, route_id, prerender::FINAL_STATUS_AUTH_NEEDED)) { |
| 247 return true; | 248 return true; |
| 248 } | 249 } |
| 249 | 250 |
| 250 return false; | 251 return false; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 // Special-case user scripts to get downloaded instead of viewed. | 305 // Special-case user scripts to get downloaded instead of viewed. |
| 305 return UserScript::IsURLUserScript(url, mime_type); | 306 return UserScript::IsURLUserScript(url, mime_type); |
| 306 } | 307 } |
| 307 | 308 |
| 308 void ChromeResourceDispatcherHostDelegate::OnResponseStarted( | 309 void ChromeResourceDispatcherHostDelegate::OnResponseStarted( |
| 309 net::URLRequest* request, | 310 net::URLRequest* request, |
| 310 content::ResourceResponse* response, | 311 content::ResourceResponse* response, |
| 311 IPC::Message::Sender* sender) { | 312 IPC::Message::Sender* sender) { |
| 312 LoadTimingObserver::PopulateTimingInfo(request, response); | 313 LoadTimingObserver::PopulateTimingInfo(request, response); |
| 313 | 314 |
| 314 ResourceDispatcherHostRequestInfo* info = | 315 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
| 315 resource_dispatcher_host_->InfoForRequest(request); | |
| 316 | 316 |
| 317 if (request->url().SchemeIsSecure()) { | 317 if (request->url().SchemeIsSecure()) { |
| 318 const net::URLRequestContext* context = request->context(); | 318 const net::URLRequestContext* context = request->context(); |
| 319 net::TransportSecurityState* state = context->transport_security_state(); | 319 net::TransportSecurityState* state = context->transport_security_state(); |
| 320 if (state) { | 320 if (state) { |
| 321 net::TransportSecurityState::DomainState domain_state; | 321 net::TransportSecurityState::DomainState domain_state; |
| 322 bool has_sni = net::SSLConfigService::IsSNIAvailable( | 322 bool has_sni = net::SSLConfigService::IsSNIAvailable( |
| 323 context->ssl_config_service()); | 323 context->ssl_config_service()); |
| 324 if (state->GetDomainState( | 324 if (state->GetDomainState( |
| 325 &domain_state, request->url().host(), has_sni)) { | 325 &domain_state, request->url().host(), has_sni)) { |
| 326 sender->Send(new ChromeViewMsg_AddStrictSecurityHost( | 326 sender->Send(new ChromeViewMsg_AddStrictSecurityHost( |
| 327 info->route_id(), request->url().host())); | 327 info->GetRouteID(), request->url().host())); |
| 328 } | 328 } |
| 329 } | 329 } |
| 330 } | 330 } |
| 331 | 331 |
| 332 // See if the response contains the X-Auto-Login header. If so, this was | 332 // See if the response contains the X-Auto-Login header. If so, this was |
| 333 // a request for a login page, and the server is allowing the browser to | 333 // a request for a login page, and the server is allowing the browser to |
| 334 // suggest auto-login, if available. | 334 // suggest auto-login, if available. |
| 335 AutoLoginPrompter::ShowInfoBarIfPossible(request, info->child_id(), | 335 AutoLoginPrompter::ShowInfoBarIfPossible(request, info->GetChildID(), |
| 336 info->route_id()); | 336 info->GetRouteID()); |
| 337 } | 337 } |
| 338 | 338 |
| 339 void ChromeResourceDispatcherHostDelegate::OnRequestRedirected( | 339 void ChromeResourceDispatcherHostDelegate::OnRequestRedirected( |
| 340 net::URLRequest* request, | 340 net::URLRequest* request, |
| 341 content::ResourceResponse* response) { | 341 content::ResourceResponse* response) { |
| 342 LoadTimingObserver::PopulateTimingInfo(request, response); | 342 LoadTimingObserver::PopulateTimingInfo(request, response); |
| 343 | 343 |
| 344 #if defined(ENABLE_ONE_CLICK_SIGNIN) | 344 #if defined(ENABLE_ONE_CLICK_SIGNIN) |
| 345 ResourceDispatcherHostRequestInfo* info = | 345 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
| 346 resource_dispatcher_host_->InfoForRequest(request); | |
| 347 | 346 |
| 348 // See if the response contains the X-Google-Accounts-SignIn header. If so, | 347 // See if the response contains the X-Google-Accounts-SignIn header. If so, |
| 349 // then the user has just finished signing in, and the server is allowing the | 348 // then the user has just finished signing in, and the server is allowing the |
| 350 // browser to suggest connecting the user's profile to the account. | 349 // browser to suggest connecting the user's profile to the account. |
| 351 OneClickSigninHelper::ShowInfoBarIfPossible(request, info->child_id(), | 350 OneClickSigninHelper::ShowInfoBarIfPossible(request, info->GetChildID(), |
| 352 info->route_id()); | 351 info->GetRouteID()); |
| 353 #endif | 352 #endif |
| 354 } | 353 } |
| OLD | NEW |