Chromium Code Reviews| Index: content/browser/loader/navigation_resource_handler.cc |
| diff --git a/content/browser/loader/navigation_resource_handler.cc b/content/browser/loader/navigation_resource_handler.cc |
| index 6e1694be6cdabb8555bb05bcc77362db99c4bdef..34496f3a5c79c92d4aadeffeec2dd11cc08b9103 100644 |
| --- a/content/browser/loader/navigation_resource_handler.cc |
| +++ b/content/browser/loader/navigation_resource_handler.cc |
| @@ -1,36 +1,43 @@ |
| // Copyright 2014 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| #include "content/browser/loader/navigation_resource_handler.h" |
| +#include <memory> |
| + |
| #include "base/logging.h" |
| #include "content/browser/devtools/devtools_netlog_observer.h" |
| #include "content/browser/loader/navigation_url_loader_impl_core.h" |
| +#include "content/browser/loader/resource_dispatcher_host_impl.h" |
| #include "content/browser/loader/resource_request_info_impl.h" |
| #include "content/browser/resource_context_impl.h" |
| #include "content/browser/streams/stream.h" |
| #include "content/browser/streams/stream_context.h" |
| +#include "content/public/browser/navigation_data.h" |
| #include "content/public/browser/resource_controller.h" |
| +#include "content/public/browser/resource_dispatcher_host_delegate.h" |
| #include "content/public/browser/stream_handle.h" |
| #include "content/public/common/resource_response.h" |
| #include "net/base/net_errors.h" |
| #include "net/url_request/url_request.h" |
| namespace content { |
| NavigationResourceHandler::NavigationResourceHandler( |
| net::URLRequest* request, |
| - NavigationURLLoaderImplCore* core) |
| + NavigationURLLoaderImplCore* core, |
| + ResourceDispatcherHostImpl* resource_dispatcher_host) |
| : ResourceHandler(request), |
| - core_(core) { |
| + core_(core), |
| + resource_dispatcher_host_(resource_dispatcher_host) { |
| core_->set_resource_handler(this); |
| writer_.set_immediate_mode(true); |
| } |
| NavigationResourceHandler::~NavigationResourceHandler() { |
| if (core_) { |
| core_->NotifyRequestFailed(false, net::ERR_ABORTED); |
| DetachFromCore(); |
| } |
| } |
| @@ -85,22 +92,35 @@ bool NavigationResourceHandler::OnResponseStarted(ResourceResponse* response, |
| // dispatched at the navigation layer. |
| if (info->IsDownload() || info->is_stream()) |
| return true; |
| StreamContext* stream_context = |
| GetStreamContextForResourceContext(info->GetContext()); |
| writer_.InitializeStream(stream_context->registry(), |
| request()->url().GetOrigin()); |
| DevToolsNetLogObserver::PopulateResponseInfo(request(), response); |
| - core_->NotifyResponseStarted(response, writer_.stream()->CreateHandle()); |
| + |
| + // Ask the embedder for a NavigationData instance. |
| + std::unique_ptr<NavigationData> navigation_data; |
| + std::unique_ptr<NavigationData> clone_data; |
|
nasko
2016/05/02 22:02:49
nit: cloned_data
RyanSturm
2016/05/02 23:02:56
Done.
|
| + if (resource_dispatcher_host_ && resource_dispatcher_host_->delegate()) { |
| + navigation_data = |
| + resource_dispatcher_host_->delegate()->GetNavigationData(request()); |
| + if (navigation_data) |
| + clone_data = navigation_data->Clone(); |
| + } |
| + |
| + core_->NotifyResponseStarted(response, writer_.stream()->CreateHandle(), |
| + std::move(clone_data)); |
| *defer = true; |
| + |
| return true; |
| } |
| bool NavigationResourceHandler::OnWillStart(const GURL& url, bool* defer) { |
| return true; |
| } |
| bool NavigationResourceHandler::OnBeforeNetworkStart(const GURL& url, |
| bool* defer) { |
| return true; |