Commit 092314fb authored by Chris Mumford's avatar Chris Mumford Committed by Commit Bot

Fixed downloading from filesystem scheme with network service.

The download manager was using the NetworkDownloadURLLoaderFactoryGetter
for the filesystem scheme which uses a WrapperSharedURLLoaderFactory
for resource requests. This change adds a
FileSystemDownloadURLLoaderFactoryGetter for the filesystem scheme.

Bug: 849059
Cq-Include-Trybots: luci.chromium.try:linux_mojo
Change-Id: Ia299ad88bac0ff0fa7ae79190e82c5e946d7b053
Reviewed-on: https://chromium-review.googlesource.com/1127148
Commit-Queue: Chris Mumford <cmumford@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Reviewed-by: default avatarMike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577357}
parent 0f9b32a0
......@@ -758,6 +758,8 @@ jumbo_source_set("browser") {
"download/drag_download_util.h",
"download/file_download_url_loader_factory_getter.cc",
"download/file_download_url_loader_factory_getter.h",
"download/file_system_download_url_loader_factory_getter.cc",
"download/file_system_download_url_loader_factory_getter.h",
"download/mhtml_extra_parts_impl.cc",
"download/mhtml_extra_parts_impl.h",
"download/mhtml_generation_manager.cc",
......
......@@ -44,6 +44,7 @@
#include "content/browser/download/download_url_loader_factory_getter_impl.h"
#include "content/browser/download/download_utils.h"
#include "content/browser/download/file_download_url_loader_factory_getter.h"
#include "content/browser/download/file_system_download_url_loader_factory_getter.h"
#include "content/browser/download/network_download_url_loader_factory_getter.h"
#include "content/browser/download/url_downloader.h"
#include "content/browser/download/url_downloader_factory.h"
......@@ -1140,6 +1141,24 @@ void DownloadManagerImpl::BeginResourceDownloadOnChecksComplete(
url_loader_factory_getter =
base::MakeRefCounted<WebUIDownloadURLLoaderFactoryGetter>(
rfh, params->url());
} else if (rfh && params->url().SchemeIsFileSystem()) {
StoragePartitionImpl* storage_partition =
static_cast<StoragePartitionImpl*>(
BrowserContext::GetStoragePartitionForSite(browser_context_,
site_url));
std::string storage_domain;
auto* site_instance = rfh->GetSiteInstance();
if (site_instance) {
std::string partition_name;
bool in_memory;
GetContentClient()->browser()->GetStoragePartitionConfigForSite(
browser_context_, site_url, true, &storage_domain, &partition_name,
&in_memory);
}
url_loader_factory_getter =
base::MakeRefCounted<FileSystemDownloadURLLoaderFactoryGetter>(
params->url(), rfh, /*is_navigation=*/false,
storage_partition->GetFileSystemContext(), storage_domain);
} else {
StoragePartitionImpl* storage_partition =
static_cast<StoragePartitionImpl*>(
......@@ -1210,7 +1229,7 @@ void DownloadManagerImpl::BeginDownloadInternal(
std::move(blob_data_handle),
browser_context_->GetResourceContext(), is_new_download,
weak_factory_.GetWeakPtr()));
}
}
}
} // namespace content
// 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/browser/download/file_system_download_url_loader_factory_getter.h"
#include "base/task_scheduler/post_task.h"
#include "base/task_scheduler/task_traits.h"
#include "components/download/public/common/download_task_runner.h"
#include "content/browser/fileapi/file_system_url_loader_factory.h"
#include "content/browser/url_loader_factory_getter.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "services/network/public/cpp/wrapper_shared_url_loader_factory.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
namespace content {
FileSystemDownloadURLLoaderFactoryGetter::
FileSystemDownloadURLLoaderFactoryGetter(
const GURL& url,
RenderFrameHost* rfh,
bool is_navigation,
scoped_refptr<storage::FileSystemContext> file_system_context,
const std::string& storage_domain)
: rfh_(rfh),
is_navigation_(is_navigation),
file_system_context_(file_system_context),
storage_domain_(storage_domain) {
DCHECK(url.SchemeIs(url::kFileSystemScheme));
DCHECK(rfh);
}
FileSystemDownloadURLLoaderFactoryGetter::
~FileSystemDownloadURLLoaderFactoryGetter() = default;
scoped_refptr<network::SharedURLLoaderFactory>
FileSystemDownloadURLLoaderFactoryGetter::GetURLLoaderFactory() {
DCHECK(download::GetIOTaskRunner()->BelongsToCurrentThread());
std::unique_ptr<network::mojom::URLLoaderFactory> factory =
CreateFileSystemURLLoaderFactory(rfh_, is_navigation_,
file_system_context_, storage_domain_);
network::mojom::URLLoaderFactoryPtrInfo url_loader_factory_ptr_info;
mojo::MakeStrongBinding(std::move(factory),
MakeRequest(&url_loader_factory_ptr_info));
return base::MakeRefCounted<network::WrapperSharedURLLoaderFactory>(
std::move(url_loader_factory_ptr_info));
}
} // namespace content
// 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.
#ifndef CONTENT_BROWSER_DOWNLOAD_FILE_SYSTEM_DOWNLOAD_URL_LOADER_FACTORY_GETTER_H_
#define CONTENT_BROWSER_DOWNLOAD_FILE_SYSTEM_DOWNLOAD_URL_LOADER_FACTORY_GETTER_H_
#include <string>
#include "base/memory/scoped_refptr.h"
#include "components/download/public/common/download_url_loader_factory_getter.h"
#include "url/gurl.h"
namespace storage {
class FileSystemContext;
}
namespace content {
class RenderFrameHost;
// Class for retrieving the URLLoaderFactory for a file URL.
class FileSystemDownloadURLLoaderFactoryGetter
: public download::DownloadURLLoaderFactoryGetter {
public:
FileSystemDownloadURLLoaderFactoryGetter(
const GURL& url,
RenderFrameHost* rfh,
bool is_navigation,
scoped_refptr<storage::FileSystemContext> file_system_context,
const std::string& storage_domain);
// download::DownloadURLLoaderFactoryGetter implementation.
scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override;
protected:
~FileSystemDownloadURLLoaderFactoryGetter() override;
private:
RenderFrameHost* rfh_;
const bool is_navigation_;
scoped_refptr<storage::FileSystemContext> file_system_context_;
const std::string storage_domain_;
DISALLOW_COPY_AND_ASSIGN(FileSystemDownloadURLLoaderFactoryGetter);
};
} // namespace content
#endif // CONTENT_BROWSER_DOWNLOAD_FILE_SYSTEM_DOWNLOAD_URL_LOADER_FACTORY_GETTER_H_
......@@ -161,12 +161,14 @@
-DnsProbeBrowserTest.NoInternetProbeResultWithSlowBrokenCorrections
# crbug.com/776589 Intercepting requests with net::URLRequestFilter.
-DownloadExtensionTest.DownloadExtensionTest_Download_FileSystemURL
-PolicyTest.CertificateTransparencyEnforcementDisabledForUrls/0
-PolicyTest.CertificateTransparencyEnforcementDisabledForUrls/1
-PolicyTest.ExtensionInstallSources
-PolicyTest.ForceGoogleSafeSearch
# crbug.com/859594 Migrate storage::FileWriterDelegate to use SimpleURLLoader
-SBNavigationObserverBrowserTest.DownloadViaHTML5FileApi
# https://bugs.chromium.org/p/chromium/issues/detail?id=789670
-DiceBrowserTest.Reauth
-DiceBrowserTest.Signin
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment