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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 render_view_id); | 83 render_view_id); |
84 if (!rvh) | 84 if (!rvh) |
85 return; | 85 return; |
86 | 86 |
87 content::NotificationService::current()->Notify( | 87 content::NotificationService::current()->Notify( |
88 chrome::NOTIFICATION_DOWNLOAD_INITIATED, | 88 chrome::NOTIFICATION_DOWNLOAD_INITIATED, |
89 content::Source<RenderViewHost>(rvh), | 89 content::Source<RenderViewHost>(rvh), |
90 content::NotificationService::NoDetails()); | 90 content::NotificationService::NoDetails()); |
91 } | 91 } |
92 | 92 |
93 // The network stack returns actual connect times, while the renderer process | |
94 // expects times that the request was blocked in each phase of setting up | |
95 // a connection. Due to preconnect and late binding, it is possible for a | |
96 // connection attempt to start before a request has been started, so this | |
97 // function is needed to convert times from the network stack to times the | |
98 // renderer process expects. | |
99 void FixupLoadTimingInfo(net::LoadTimingInfo* load_timing_info) { | |
100 // If there are no times, do nothing. | |
101 if (load_timing_info->request_start.is_null()) | |
102 return; | |
103 | |
104 // Starting the request and resolving the proxy are the only phases of the | |
105 // request that occur before it blocks on starting a connection. | |
106 base::TimeTicks block_on_connect_start = load_timing_info->request_start; | |
107 if (!load_timing_info->proxy_resolve_end.is_null()) | |
108 block_on_connect_start = load_timing_info->proxy_resolve_end; | |
109 | |
110 net::LoadTimingInfo::ConnectTiming* connect_timing = | |
111 &load_timing_info->connect_timing; | |
112 if (!connect_timing->dns_start.is_null()) { | |
113 DCHECK(!connect_timing->dns_end.is_null()); | |
114 if (connect_timing->dns_start < block_on_connect_start) | |
115 connect_timing->dns_start = block_on_connect_start; | |
116 if (connect_timing->dns_end < block_on_connect_start) | |
117 connect_timing->dns_end = block_on_connect_start; | |
118 } | |
119 | |
120 if (!connect_timing->connect_start.is_null()) { | |
121 DCHECK(!connect_timing->connect_end.is_null()); | |
122 if (connect_timing->connect_start < block_on_connect_start) | |
123 connect_timing->connect_start = block_on_connect_start; | |
124 if (connect_timing->connect_end < block_on_connect_start) | |
125 connect_timing->connect_end = block_on_connect_start; | |
126 } | |
127 | |
128 if (!connect_timing->ssl_start.is_null()) { | |
129 DCHECK(!connect_timing->ssl_end.is_null()); | |
130 if (connect_timing->ssl_start < block_on_connect_start) | |
131 connect_timing->ssl_start = block_on_connect_start; | |
132 if (connect_timing->ssl_end < block_on_connect_start) | |
133 connect_timing->ssl_end = block_on_connect_start; | |
134 } | |
135 } | |
136 | |
137 // Goes through the extension's file browser handlers and checks if there is one | 93 // Goes through the extension's file browser handlers and checks if there is one |
138 // that can handle the |mime_type|. | 94 // that can handle the |mime_type|. |
139 // |extension| must not be NULL. | 95 // |extension| must not be NULL. |
140 bool ExtensionCanHandleMimeType(const Extension* extension, | 96 bool ExtensionCanHandleMimeType(const Extension* extension, |
141 const std::string& mime_type) { | 97 const std::string& mime_type) { |
142 MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); | 98 MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); |
143 if (!handler) | 99 if (!handler) |
144 return false; | 100 return false; |
145 | 101 |
146 return handler->CanHandleMIMEType(mime_type); | 102 return handler->CanHandleMIMEType(mime_type); |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 target_id)); | 481 target_id)); |
526 #endif | 482 #endif |
527 } | 483 } |
528 | 484 |
529 void ChromeResourceDispatcherHostDelegate::OnResponseStarted( | 485 void ChromeResourceDispatcherHostDelegate::OnResponseStarted( |
530 net::URLRequest* request, | 486 net::URLRequest* request, |
531 content::ResourceContext* resource_context, | 487 content::ResourceContext* resource_context, |
532 content::ResourceResponse* response, | 488 content::ResourceResponse* response, |
533 IPC::Sender* sender) { | 489 IPC::Sender* sender) { |
534 // TODO(mmenke): Figure out if LOAD_ENABLE_LOAD_TIMING is safe to remove. | 490 // TODO(mmenke): Figure out if LOAD_ENABLE_LOAD_TIMING is safe to remove. |
535 if (request->load_flags() & net::LOAD_ENABLE_LOAD_TIMING) { | 491 if (request->load_flags() & net::LOAD_ENABLE_LOAD_TIMING) |
536 request->GetLoadTimingInfo(&response->head.load_timing); | 492 request->GetLoadTimingInfo(&response->head.load_timing); |
537 FixupLoadTimingInfo(&response->head.load_timing); | |
538 } | |
539 | 493 |
540 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 494 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
541 | 495 |
542 if (request->url().SchemeIsSecure()) { | 496 if (request->url().SchemeIsSecure()) { |
543 const net::URLRequestContext* context = request->context(); | 497 const net::URLRequestContext* context = request->context(); |
544 net::TransportSecurityState* state = context->transport_security_state(); | 498 net::TransportSecurityState* state = context->transport_security_state(); |
545 if (state) { | 499 if (state) { |
546 net::TransportSecurityState::DomainState domain_state; | 500 net::TransportSecurityState::DomainState domain_state; |
547 bool has_sni = net::SSLConfigService::IsSNIAvailable( | 501 bool has_sni = net::SSLConfigService::IsSNIAvailable( |
548 context->ssl_config_service()); | 502 context->ssl_config_service()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 | 542 |
589 prerender::URLRequestResponseStarted(request); | 543 prerender::URLRequestResponseStarted(request); |
590 } | 544 } |
591 | 545 |
592 void ChromeResourceDispatcherHostDelegate::OnRequestRedirected( | 546 void ChromeResourceDispatcherHostDelegate::OnRequestRedirected( |
593 const GURL& redirect_url, | 547 const GURL& redirect_url, |
594 net::URLRequest* request, | 548 net::URLRequest* request, |
595 content::ResourceContext* resource_context, | 549 content::ResourceContext* resource_context, |
596 content::ResourceResponse* response) { | 550 content::ResourceResponse* response) { |
597 // TODO(mmenke): Figure out if LOAD_ENABLE_LOAD_TIMING is safe to remove. | 551 // TODO(mmenke): Figure out if LOAD_ENABLE_LOAD_TIMING is safe to remove. |
598 if (request->load_flags() & net::LOAD_ENABLE_LOAD_TIMING) { | 552 if (request->load_flags() & net::LOAD_ENABLE_LOAD_TIMING) |
599 request->GetLoadTimingInfo(&response->head.load_timing); | 553 request->GetLoadTimingInfo(&response->head.load_timing); |
600 FixupLoadTimingInfo(&response->head.load_timing); | |
601 } | |
602 | 554 |
603 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | 555 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
604 | 556 |
605 #if defined(ENABLE_ONE_CLICK_SIGNIN) | 557 #if defined(ENABLE_ONE_CLICK_SIGNIN) |
606 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 558 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
607 | 559 |
608 // See if the response contains the Google-Accounts-SignIn header. If so, | 560 // See if the response contains the Google-Accounts-SignIn header. If so, |
609 // then the user has just finished signing in, and the server is allowing the | 561 // then the user has just finished signing in, and the server is allowing the |
610 // browser to suggest connecting the user's profile to the account. | 562 // browser to suggest connecting the user's profile to the account. |
611 OneClickSigninHelper::ShowInfoBarIfPossible(request, io_data, | 563 OneClickSigninHelper::ShowInfoBarIfPossible(request, io_data, |
(...skipping 10 matching lines...) Expand all Loading... |
622 int child_id, route_id; | 574 int child_id, route_id; |
623 if (!prerender::PrerenderManager::DoesURLHaveValidScheme(redirect_url) && | 575 if (!prerender::PrerenderManager::DoesURLHaveValidScheme(redirect_url) && |
624 ResourceRequestInfo::ForRequest(request)->GetAssociatedRenderView( | 576 ResourceRequestInfo::ForRequest(request)->GetAssociatedRenderView( |
625 &child_id, &route_id) && | 577 &child_id, &route_id) && |
626 prerender_tracker_->IsPrerenderingOnIOThread(child_id, route_id)) { | 578 prerender_tracker_->IsPrerenderingOnIOThread(child_id, route_id)) { |
627 prerender_tracker_->TryCancel( | 579 prerender_tracker_->TryCancel( |
628 child_id, route_id, prerender::FINAL_STATUS_UNSUPPORTED_SCHEME); | 580 child_id, route_id, prerender::FINAL_STATUS_UNSUPPORTED_SCHEME); |
629 request->Cancel(); | 581 request->Cancel(); |
630 } | 582 } |
631 } | 583 } |
OLD | NEW |