Commit e1a0219c authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Allow non-content code use FileURLLoaderFactory

This CL exposes a method that allows the creation of FileURLLoaderFactory
instances. through the content/browser public API.

This is a preparation for CL https://crrev.com/c/1066370.

BUG=773295,844928

Change-Id: I89c9cd2e82ee54f4dae1c121d5e0f7b5c0597fb1
Reviewed-on: https://chromium-review.googlesource.com/1156885
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579818}
parent f6a95019
...@@ -684,4 +684,12 @@ void CreateFileURLLoader( ...@@ -684,4 +684,12 @@ void CreateFileURLLoader(
std::move(extra_response_headers))); std::move(extra_response_headers)));
} }
std::unique_ptr<network::mojom::URLLoaderFactory> CreateFileURLLoaderFactory(
const base::FilePath& profile_path) {
return std::make_unique<content::FileURLLoaderFactory>(
profile_path, base::CreateSequencedTaskRunnerWithTraits(
{base::MayBlock(), base::TaskPriority::BEST_EFFORT,
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}));
}
} // namespace content } // namespace content
...@@ -13,6 +13,12 @@ ...@@ -13,6 +13,12 @@
#include "net/http/http_response_headers.h" #include "net/http/http_response_headers.h"
#include "services/network/public/mojom/url_loader.mojom.h" #include "services/network/public/mojom/url_loader.mojom.h"
namespace network {
namespace mojom {
class URLLoaderFactory;
}
} // namespace network
namespace content { namespace content {
class CONTENT_EXPORT FileURLLoaderObserver class CONTENT_EXPORT FileURLLoaderObserver
...@@ -47,6 +53,15 @@ CONTENT_EXPORT void CreateFileURLLoader( ...@@ -47,6 +53,15 @@ CONTENT_EXPORT void CreateFileURLLoader(
std::unique_ptr<FileURLLoaderObserver> observer, std::unique_ptr<FileURLLoaderObserver> observer,
scoped_refptr<net::HttpResponseHeaders> extra_response_headers = nullptr); scoped_refptr<net::HttpResponseHeaders> extra_response_headers = nullptr);
// Helper to create a FileURLLoaderFactory instance. This exposes the ability
// to load file:// URLs through SimpleURLLoader to non-content classes.
//
// When non-empty, |profile_path| is used to whitelist specific directories on
// ChromeOS and Android. It is checked by
// ContentBrowserClient::IsFileAccessAllowed.
CONTENT_EXPORT std::unique_ptr<network::mojom::URLLoaderFactory>
CreateFileURLLoaderFactory(const base::FilePath& profile_path);
} // namespace content } // namespace content
#endif // CONTENT_PUBLIC_BROWSER_FILE_URL_LOADER_H_ #endif // CONTENT_PUBLIC_BROWSER_FILE_URL_LOADER_H_
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