Chromium Code Reviews| Index: content/browser/download/download_request_handle.cc |
| diff --git a/content/browser/download/download_request_handle.cc b/content/browser/download/download_request_handle.cc |
| index 32c5b987799d510d79fb6e12c4327784498fdd86..5f9a14a2de0b7e613f75ec5e11c70f4a971f9036 100644 |
| --- a/content/browser/download/download_request_handle.cc |
| +++ b/content/browser/download/download_request_handle.cc |
| @@ -5,11 +5,15 @@ |
| #include "content/browser/download/download_request_handle.h" |
| #include "base/bind.h" |
| +#include "base/command_line.h" |
| #include "base/strings/stringprintf.h" |
| +#include "content/browser/frame_host/navigator.h" |
| +#include "content/browser/frame_host/render_frame_host_impl.h" |
| #include "content/browser/renderer_host/render_view_host_impl.h" |
| #include "content/browser/web_contents/web_contents_impl.h" |
| #include "content/public/browser/browser_context.h" |
| #include "content/public/browser/browser_thread.h" |
| +#include "content/public/common/content_switches.h" |
| namespace content { |
| @@ -19,22 +23,38 @@ DownloadRequestHandle::~DownloadRequestHandle() { |
| DownloadRequestHandle::DownloadRequestHandle() |
| : child_id_(-1), |
| render_view_id_(-1), |
| - request_id_(-1) { |
| + request_id_(-1), |
| + frame_tree_node_id_(-1) { |
| } |
| DownloadRequestHandle::DownloadRequestHandle( |
| const base::WeakPtr<DownloadResourceHandler>& handler, |
| int child_id, |
| int render_view_id, |
| - int request_id) |
| + int request_id, |
| + int64 frame_tree_node_id) |
| : handler_(handler), |
| child_id_(child_id), |
| render_view_id_(render_view_id), |
| - request_id_(request_id) { |
| + request_id_(request_id), |
| + frame_tree_node_id_(frame_tree_node_id) { |
| DCHECK(handler_.get()); |
| } |
| WebContents* DownloadRequestHandle::GetWebContents() const { |
| + // PlzNavigate: if a FrameTreeNodeID was provided, use it to return the |
| + // WebContents. |
| + // TODO(davidben): This logic should be abstracted within the ResourceLoader |
| + // stack. https://crbug.com/376003 |
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableBrowserSideNavigation)) { |
| + FrameTreeNode* frame_tree_node = |
| + FrameTreeNode::GloballyFindByID(frame_tree_node_id_); |
| + if (frame_tree_node) { |
| + return WebContentsImpl::FromFrameTreeNode(frame_tree_node); |
| + } |
| + } |
| + |
| RenderViewHostImpl* render_view_host = |
| RenderViewHostImpl::FromID(child_id_, render_view_id_); |
| if (!render_view_host) |
| @@ -44,6 +64,22 @@ WebContents* DownloadRequestHandle::GetWebContents() const { |
| } |
| DownloadManager* DownloadRequestHandle::GetDownloadManager() const { |
| + // PlzNavigate: if a FrameTreeNodeID was provided, use it to return the |
| + // DownloadManager. |
| + // TODO(davidben): This logic should be abstracted within the ResourceLoader |
| + // stack. https://crbug.com/376003 |
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableBrowserSideNavigation)) { |
| + FrameTreeNode* frame_tree_node = |
| + FrameTreeNode::GloballyFindByID(frame_tree_node_id_); |
| + if (frame_tree_node) { |
|
nasko
2015/05/22 16:48:06
nit: Why not follow the style of this method by ch
clamy
2015/05/26 10:43:11
Because when we resume a download we don't have ac
|
| + BrowserContext* context = |
| + frame_tree_node->navigator()->GetController()->GetBrowserContext(); |
| + if (context) |
| + return BrowserContext::GetDownloadManager(context); |
| + } |
| + } |
| + |
| RenderViewHostImpl* rvh = RenderViewHostImpl::FromID( |
| child_id_, render_view_id_); |
| if (rvh == NULL) |