#include "content/public/browser/web_ui_url_loader_factory.h"
#include <optional>
#include <string_view>
#include <utility>
#include <vector>
#include "base/containers/span.h"
#include "base/debug/crash_logging.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/memory/ref_counted_memory.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/safe_conversions.h"
#include "base/ranges/algorithm.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/timer/elapsed_timer.h"
#include "base/trace_event/trace_event.h"
#include "content/browser/bad_message.h"
#include "content/browser/blob_storage/blob_internals_url_loader.h"
#include "content/browser/blob_storage/chrome_blob_storage_context.h"
#include "content/browser/renderer_host/frame_tree_node.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/webui/network_error_url_loader.h"
#include "content/browser/webui/url_data_manager_backend.h"
#include "content/browser/webui/url_data_source_impl.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/url_data_source.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
#include "mojo/public/cpp/bindings/message.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/http/http_byte_range.h"
#include "net/http/http_util.h"
#include "services/network/public/cpp/parsed_headers.h"
#include "services/network/public/cpp/self_deleting_url_loader_factory.h"
#include "services/network/public/mojom/network_service.mojom.h"
#include "ui/base/template_expressions.h"
namespace content {
namespace {
class WebUIURLLoaderFactory;
void CallOnError(
mojo::PendingRemote<network::mojom::URLLoaderClient> client_remote,
int error_code) { … }
void ReadData(
network::mojom::URLResponseHeadPtr headers,
const ui::TemplateReplacements* replacements,
bool replace_in_js,
scoped_refptr<URLDataSourceImpl> data_source,
mojo::PendingRemote<network::mojom::URLLoaderClient> client_remote,
std::optional<net::HttpByteRange> requested_range,
base::ElapsedTimer url_request_elapsed_timer,
scoped_refptr<base::RefCountedMemory> bytes) { … }
void DataAvailable(
network::mojom::URLResponseHeadPtr headers,
const ui::TemplateReplacements* replacements,
bool replace_in_js,
scoped_refptr<URLDataSourceImpl> source,
mojo::PendingRemote<network::mojom::URLLoaderClient> client_remote,
std::optional<net::HttpByteRange> requested_range,
base::ElapsedTimer url_request_elapsed_timer,
scoped_refptr<base::RefCountedMemory> bytes) { … }
void StartURLLoader(
const network::ResourceRequest& request,
int frame_tree_node_id,
mojo::PendingRemote<network::mojom::URLLoaderClient> client_remote,
BrowserContext* browser_context) { … }
class WebUIURLLoaderFactory : public network::SelfDeletingURLLoaderFactory { … };
}
mojo::PendingRemote<network::mojom::URLLoaderFactory>
CreateWebUIURLLoaderFactory(RenderFrameHost* render_frame_host,
const std::string& scheme,
base::flat_set<std::string> allowed_hosts) { … }
mojo::PendingRemote<network::mojom::URLLoaderFactory>
CreateWebUIServiceWorkerLoaderFactory(
BrowserContext* browser_context,
const std::string& scheme,
base::flat_set<std::string> allowed_hosts) { … }
}