#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "extensions/browser/api/web_request/web_request_info.h"
#include <cstdint>
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include "base/check_op.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/values.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/websocket_handshake_request_info.h"
#include "extensions/browser/api/web_request/upload_data_presenter.h"
#include "extensions/browser/api/web_request/web_request_api_constants.h"
#include "extensions/browser/extension_api_frame_id_map.h"
#include "extensions/browser/extension_navigation_ui_data.h"
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/buildflags/buildflags.h"
#include "extensions/common/extension_id.h"
#include "net/base/ip_endpoint.h"
#include "net/base/upload_bytes_element_reader.h"
#include "net/base/upload_data_stream.h"
#include "net/base/upload_file_element_reader.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "services/network/url_loader.h"
#if BUILDFLAG(ENABLE_GUEST_VIEW)
#include "extensions/browser/guest_view/web_view/web_view_renderer_state.h"
#endif
keys;
namespace extensions {
namespace {
class UploadDataSource { … };
class BytesUploadDataSource : public UploadDataSource { … };
class FileUploadDataSource : public UploadDataSource { … };
bool CreateUploadDataSourcesFromResourceRequest(
const network::ResourceRequest& request,
std::vector<std::unique_ptr<UploadDataSource>>* data_sources) { … }
std::optional<base::Value::Dict> CreateRequestBodyData(
const std::string& method,
const net::HttpRequestHeaders& request_headers,
const std::vector<std::unique_ptr<UploadDataSource>>& data_sources) { … }
}
WebRequestInfoInitParams::WebRequestInfoInitParams() = default;
WebRequestInfoInitParams::WebRequestInfoInitParams(
uint64_t request_id,
int render_process_id,
int frame_routing_id,
std::unique_ptr<ExtensionNavigationUIData> navigation_ui_data,
const network::ResourceRequest& request,
bool is_download,
bool is_async,
bool is_service_worker_script,
std::optional<int64_t> navigation_id)
: … { … }
WebRequestInfoInitParams::WebRequestInfoInitParams(
WebRequestInfoInitParams&& other) = default;
WebRequestInfoInitParams& WebRequestInfoInitParams::operator=(
WebRequestInfoInitParams&& other) = default;
WebRequestInfoInitParams::~WebRequestInfoInitParams() = default;
void WebRequestInfoInitParams::InitializeWebViewAndFrameData(
const ExtensionNavigationUIData* navigation_ui_data) { … }
WebRequestInfo::WebRequestInfo(WebRequestInfoInitParams params)
: … { … }
WebRequestInfo::~WebRequestInfo() = default;
void WebRequestInfo::AddResponseInfoFromResourceResponse(
const network::mojom::URLResponseHead& response) { … }
void WebRequestInfo::EraseDNRActionsForExtension(
const ExtensionId& extension_id) { … }
void WebRequestInfo::EraseOutprioritizedDNRActions() { … }
bool WebRequestInfo::ShouldRecordMatchedAllowRuleInOnHeadersReceived(
const declarative_net_request::RequestAction& allow_action) const { … }
}