blob: 2c2a29228dc6f1c8a6523d620800957b5ada85e9 [file] [log] [blame]
// Copyright 2018 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/public/browser/download_request_utils.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
namespace content {
// static
std::unique_ptr<download::DownloadUrlParameters>
DownloadRequestUtils::CreateDownloadForWebContentsMainFrame(
WebContents* web_contents,
const GURL& url,
const net::NetworkTrafficAnnotationTag& traffic_annotation) {
RenderFrameHost* render_frame_host = web_contents->GetMainFrame();
StoragePartition* storage_partition = BrowserContext::GetStoragePartition(
web_contents->GetBrowserContext(), render_frame_host->GetSiteInstance());
return std::unique_ptr<download::DownloadUrlParameters>(
new download::DownloadUrlParameters(
url, render_frame_host->GetProcess()->GetID(),
render_frame_host->GetRenderViewHost()->GetRoutingID(),
render_frame_host->GetRoutingID(),
storage_partition->GetURLRequestContext(), traffic_annotation));
}
} // namespace content