| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/loader/navigation_resource_handler.h" | 5 #include "content/browser/loader/navigation_resource_handler.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "content/browser/loader/navigation_url_loader_impl_core.h" | 11 #include "content/browser/loader/navigation_url_loader_impl_core.h" |
| 12 #include "content/browser/loader/netlog_observer.h" | 12 #include "content/browser/loader/netlog_observer.h" |
| 13 #include "content/browser/loader/resource_controller.h" | 13 #include "content/browser/loader/resource_controller.h" |
| 14 #include "content/browser/loader/resource_loader.h" | 14 #include "content/browser/loader/resource_loader.h" |
| 15 #include "content/browser/loader/resource_request_info_impl.h" | 15 #include "content/browser/loader/resource_request_info_impl.h" |
| 16 #include "content/browser/resource_context_impl.h" | 16 #include "content/browser/resource_context_impl.h" |
| 17 #include "content/browser/streams/stream.h" | 17 #include "content/browser/streams/stream.h" |
| 18 #include "content/browser/streams/stream_context.h" | 18 #include "content/browser/streams/stream_context.h" |
| 19 #include "content/public/browser/navigation_data.h" | 19 #include "content/public/browser/navigation_data.h" |
| 20 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 20 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
| 21 #include "content/public/browser/ssl_status.h" | 21 #include "content/public/browser/ssl_status.h" |
| 22 #include "content/public/browser/stream_handle.h" | 22 #include "content/public/browser/stream_handle.h" |
| 23 #include "content/public/common/resource_response.h" | 23 #include "content/public/common/resource_response.h" |
| 24 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
| 25 #include "net/url_request/url_request.h" | 25 #include "net/url_request/url_request.h" |
| 26 | 26 |
| 27 namespace content { | 27 namespace content { |
| 28 | 28 |
| 29 void NavigationResourceHandler::GetSSLStatusForRequest( | 29 void NavigationResourceHandler::GetSSLStatusForRequest( |
| 30 const GURL& url, | |
| 31 const net::SSLInfo& ssl_info, | 30 const net::SSLInfo& ssl_info, |
| 32 int child_id, | |
| 33 SSLStatus* ssl_status) { | 31 SSLStatus* ssl_status) { |
| 34 DCHECK(ssl_info.cert); | 32 DCHECK(ssl_info.cert); |
| 35 *ssl_status = SSLStatus(ssl_info); | 33 *ssl_status = SSLStatus(ssl_info); |
| 36 } | 34 } |
| 37 | 35 |
| 38 NavigationResourceHandler::NavigationResourceHandler( | 36 NavigationResourceHandler::NavigationResourceHandler( |
| 39 net::URLRequest* request, | 37 net::URLRequest* request, |
| 40 NavigationURLLoaderImplCore* core, | 38 NavigationURLLoaderImplCore* core, |
| 41 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate) | 39 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate) |
| 42 : ResourceHandler(request), | 40 : ResourceHandler(request), |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 // Ask the embedder for a NavigationData instance. | 117 // Ask the embedder for a NavigationData instance. |
| 120 NavigationData* navigation_data = | 118 NavigationData* navigation_data = |
| 121 resource_dispatcher_host_delegate_->GetNavigationData(request()); | 119 resource_dispatcher_host_delegate_->GetNavigationData(request()); |
| 122 | 120 |
| 123 // Clone the embedder's NavigationData before moving it to the UI thread. | 121 // Clone the embedder's NavigationData before moving it to the UI thread. |
| 124 if (navigation_data) | 122 if (navigation_data) |
| 125 cloned_data = navigation_data->Clone(); | 123 cloned_data = navigation_data->Clone(); |
| 126 } | 124 } |
| 127 | 125 |
| 128 SSLStatus ssl_status; | 126 SSLStatus ssl_status; |
| 129 if (request()->ssl_info().cert.get()) { | 127 if (request()->ssl_info().cert.get()) |
| 130 GetSSLStatusForRequest(request()->url(), request()->ssl_info(), | 128 GetSSLStatusForRequest(request()->ssl_info(), &ssl_status); |
| 131 info->GetChildID(), &ssl_status); | |
| 132 } | |
| 133 | 129 |
| 134 core_->NotifyResponseStarted(response, writer_.stream()->CreateHandle(), | 130 core_->NotifyResponseStarted(response, writer_.stream()->CreateHandle(), |
| 135 ssl_status, std::move(cloned_data), | 131 ssl_status, std::move(cloned_data), |
| 136 info->GetGlobalRequestID(), info->IsDownload(), | 132 info->GetGlobalRequestID(), info->IsDownload(), |
| 137 info->is_stream()); | 133 info->is_stream()); |
| 138 // Don't defer stream based requests. This includes requests initiated via | 134 // Don't defer stream based requests. This includes requests initiated via |
| 139 // mime type sniffing, etc. | 135 // mime type sniffing, etc. |
| 140 // TODO(ananta) | 136 // TODO(ananta) |
| 141 // Make sure that the requests go through the throttle checks. Currently this | 137 // Make sure that the requests go through the throttle checks. Currently this |
| 142 // does not work as the InterceptingResourceHandler is above us and hence it | 138 // does not work as the InterceptingResourceHandler is above us and hence it |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 NOTREACHED(); | 199 NOTREACHED(); |
| 204 } | 200 } |
| 205 | 201 |
| 206 void NavigationResourceHandler::DetachFromCore() { | 202 void NavigationResourceHandler::DetachFromCore() { |
| 207 DCHECK(core_); | 203 DCHECK(core_); |
| 208 core_->set_resource_handler(nullptr); | 204 core_->set_resource_handler(nullptr); |
| 209 core_ = nullptr; | 205 core_ = nullptr; |
| 210 } | 206 } |
| 211 | 207 |
| 212 } // namespace content | 208 } // namespace content |
| OLD | NEW |