#include "content/browser/renderer_host/navigator.h"
#include <utility>
#include "base/check_op.h"
#include "base/debug/dump_without_crashing.h"
#include "base/metrics/histogram_macros.h"
#include "base/notreached.h"
#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "base/time/time.h"
#include "base/types/optional_util.h"
#include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/interest_group/interest_group_features.h"
#include "content/browser/process_lock.h"
#include "content/browser/renderer_host/debug_urls.h"
#include "content/browser/renderer_host/frame_tree.h"
#include "content/browser/renderer_host/frame_tree_node.h"
#include "content/browser/renderer_host/navigation_controller_impl.h"
#include "content/browser/renderer_host/navigation_entry_impl.h"
#include "content/browser/renderer_host/navigation_request.h"
#include "content/browser/renderer_host/navigation_request_info.h"
#include "content/browser/renderer_host/navigation_transitions/navigation_transition_utils.h"
#include "content/browser/renderer_host/navigator_delegate.h"
#include "content/browser/renderer_host/render_frame_host_delegate.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/site_info.h"
#include "content/browser/site_instance_impl.h"
#include "content/browser/web_package/prefetched_signed_exchange_cache.h"
#include "content/browser/webui/web_ui_controller_factory_registry.h"
#include "content/browser/webui/web_ui_impl.h"
#include "content/common/features.h"
#include "content/common/navigation_params_utils.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/global_request_id.h"
#include "content/public/browser/invalidate_type.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/page_navigator.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/restore_type.h"
#include "content/public/common/bindings_policy.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/url_utils.h"
#include "net/base/net_errors.h"
#include "net/base/schemeful_site.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_source_id.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "third_party/blink/public/common/loader/inter_process_time_ticks_converter.h"
#include "third_party/blink/public/common/navigation/navigation_policy.h"
#include "third_party/blink/public/mojom/navigation/navigation_params.mojom.h"
#include "url/gurl.h"
#include "url/url_util.h"
namespace content {
namespace {
WebFeature;
CrossOriginOpenerPolicyValue;
CrossOriginEmbedderPolicyValue;
std::optional<WebFeature> FeatureCoop(CrossOriginOpenerPolicyValue value) { … }
std::optional<WebFeature> FeatureCoopRO(CrossOriginOpenerPolicyValue value) { … }
std::optional<WebFeature> FeatureCoep(CrossOriginEmbedderPolicyValue value) { … }
std::optional<WebFeature> FeatureCoepRO(CrossOriginEmbedderPolicyValue value) { … }
ukm::SourceId GetPageUkmSourceId(RenderFrameHost& rfh) { … }
void RecordWebPlatformSecurityMetrics(RenderFrameHostImpl* rfh,
bool has_embedding_control,
bool is_error_page) { … }
void RecordMetrics(RenderFrameHostImpl& rfh,
const std::vector<blink::mojom::WebFeature>& web_features) { … }
bool HasEmbeddingControl(NavigationRequest* navigation_request) { … }
}
struct Navigator::NavigationMetricsData { … };
Navigator::Navigator(
BrowserContext* browser_context,
FrameTree& frame_tree,
NavigatorDelegate* delegate,
NavigationControllerDelegate* navigation_controller_delegate)
: … { … }
Navigator::~Navigator() = default;
bool Navigator::CheckWebUIRendererDoesNotDisplayNormalURL(
RenderFrameHostImpl* render_frame_host,
const UrlInfo& url_info,
bool is_renderer_initiated_check) { … }
bool Navigator::ShouldIgnoreIncomingRendererRequest(
const NavigationRequest* ongoing_navigation_request,
bool has_user_gesture) { … }
NavigatorDelegate* Navigator::GetDelegate() { … }
bool Navigator::StartHistoryNavigationInNewSubframe(
RenderFrameHostImpl* render_frame_host,
mojo::PendingAssociatedRemote<mojom::NavigationClient>* navigation_client,
blink::LocalFrameToken initiator_frame_token,
int initiator_process_id) { … }
void Navigator::DidNavigate(
RenderFrameHostImpl* render_frame_host,
const mojom::DidCommitProvisionalLoadParams& params,
std::unique_ptr<NavigationRequest> navigation_request,
bool was_within_same_document) { … }
void Navigator::Navigate(std::unique_ptr<NavigationRequest> request,
ReloadType reload_type) { … }
void Navigator::RequestOpenURL(
RenderFrameHostImpl* render_frame_host,
const GURL& url,
const blink::LocalFrameToken* initiator_frame_token,
int initiator_process_id,
const std::optional<url::Origin>& initiator_origin,
const std::optional<GURL>& initiator_base_url,
const scoped_refptr<network::ResourceRequestBody>& post_body,
const std::string& extra_headers,
const Referrer& referrer,
WindowOpenDisposition disposition,
bool should_replace_current_entry,
bool user_gesture,
blink::mojom::TriggeringEventInfo triggering_event_info,
const std::string& href_translate,
scoped_refptr<network::SharedURLLoaderFactory> blob_url_loader_factory,
const std::optional<blink::Impression>& impression,
bool has_rel_opener) { … }
void Navigator::NavigateFromFrameProxy(
RenderFrameHostImpl* render_frame_host,
const GURL& url,
const blink::LocalFrameToken* initiator_frame_token,
int initiator_process_id,
const url::Origin& initiator_origin,
const std::optional<GURL>& initiator_base_url,
SiteInstance* source_site_instance,
const Referrer& referrer,
ui::PageTransition page_transition,
bool should_replace_current_entry,
blink::NavigationDownloadPolicy download_policy,
const std::string& method,
scoped_refptr<network::ResourceRequestBody> post_body,
const std::string& extra_headers,
scoped_refptr<network::SharedURLLoaderFactory> blob_url_loader_factory,
network::mojom::SourceLocationPtr source_location,
bool has_user_gesture,
bool is_form_submission,
const std::optional<blink::Impression>& impression,
blink::mojom::NavigationInitiatorActivationAndAdStatus
initiator_activation_and_ad_status,
base::TimeTicks navigation_start_time,
bool is_embedder_initiated_fenced_frame_navigation,
bool is_unfenced_top_navigation,
bool force_new_browsing_instance,
bool is_container_initiated,
bool has_rel_opener,
net::StorageAccessApiStatus storage_access_api_status,
std::optional<std::u16string> embedder_shared_storage_context) { … }
void Navigator::BeforeUnloadCompleted(FrameTreeNode* frame_tree_node,
bool proceed,
const base::TimeTicks& proceed_time) { … }
void Navigator::OnBeginNavigation(
FrameTreeNode* frame_tree_node,
blink::mojom::CommonNavigationParamsPtr common_params,
blink::mojom::BeginNavigationParamsPtr begin_params,
scoped_refptr<network::SharedURLLoaderFactory> blob_url_loader_factory,
mojo::PendingAssociatedRemote<mojom::NavigationClient> navigation_client,
scoped_refptr<PrefetchedSignedExchangeCache>
prefetched_signed_exchange_cache,
int initiator_process_id,
mojo::PendingReceiver<mojom::NavigationRendererCancellationListener>
renderer_cancellation_listener) { … }
void Navigator::RestartNavigationAsCrossDocument(
std::unique_ptr<NavigationRequest> navigation_request) { … }
void Navigator::CancelNavigation(FrameTreeNode* frame_tree_node,
NavigationDiscardReason reason) { … }
void Navigator::LogCommitNavigationSent() { … }
void Navigator::LogBeforeUnloadTime(
base::TimeTicks renderer_before_unload_start_time,
base::TimeTicks renderer_before_unload_end_time,
base::TimeTicks before_unload_sent_time,
bool for_legacy) { … }
void Navigator::LogRendererInitiatedBeforeUnloadTime(
base::TimeTicks renderer_before_unload_start_time,
base::TimeTicks renderer_before_unload_end_time) { … }
void Navigator::RecordNavigationMetrics(
const LoadCommittedDetails& details,
const mojom::DidCommitProvisionalLoadParams& params,
SiteInstance* site_instance,
const GURL& original_request_url) { … }
NavigationEntryImpl*
Navigator::GetNavigationEntryForRendererInitiatedNavigation(
const blink::mojom::CommonNavigationParams& common_params,
FrameTreeNode* frame_tree_node,
bool override_user_agent) { … }
}