// Copyright 2018 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CONTENT_RENDERER_NAVIGATION_CLIENT_H_ #define CONTENT_RENDERER_NAVIGATION_CLIENT_H_ #include "content/common/frame.mojom.h" #include "content/common/navigation_client.mojom.h" #include "content/public/common/alternative_error_page_override_info.mojom.h" #include "mojo/public/cpp/bindings/associated_receiver.h" #include "mojo/public/cpp/bindings/pending_associated_receiver.h" #include "third_party/blink/public/common/permissions_policy/permissions_policy.h" #include "third_party/blink/public/mojom/back_forward_cache_not_restored_reasons.mojom.h" namespace content { class RenderFrameImpl; class NavigationClient : mojom::NavigationClient { public: explicit NavigationClient(RenderFrameImpl* render_frame); ~NavigationClient() override; // mojom::NavigationClient implementation: void CommitNavigation( blink::mojom::CommonNavigationParamsPtr common_params, blink::mojom::CommitNavigationParamsPtr commit_params, network::mojom::URLResponseHeadPtr response_head, mojo::ScopedDataPipeConsumerHandle response_body, network::mojom::URLLoaderClientEndpointsPtr url_loader_client_endpoints, std::unique_ptr subresource_loaders, absl::optional> subresource_overrides, blink::mojom::ControllerServiceWorkerInfoPtr controller_service_worker_info, blink::mojom::ServiceWorkerContainerInfoForClientPtr container_info, mojo::PendingRemote prefetch_loader_factory, const blink::DocumentToken& document_token, const base::UnguessableToken& devtools_navigation_token, const absl::optional& permissions_policy, blink::mojom::PolicyContainerPtr policy_container, mojo::PendingRemote code_cache_host, mojom::CookieManagerInfoPtr cookie_manager_info, mojom::StorageInfoPtr storage_info, blink::mojom::BackForwardCacheNotRestoredReasonsPtr not_restored_reasons, CommitNavigationCallback callback) override; void CommitFailedNavigation( blink::mojom::CommonNavigationParamsPtr common_params, blink::mojom::CommitNavigationParamsPtr commit_params, bool has_stale_copy_in_cache, int error_code, int extended_error_code, const net::ResolveErrorInfo& resolve_error_info, const absl::optional& error_page_content, std::unique_ptr subresource_loaders, const blink::DocumentToken& document_token, blink::mojom::PolicyContainerPtr policy_container, mojom::AlternativeErrorPageOverrideInfoPtr alternative_error_page_info, CommitFailedNavigationCallback callback) override; void Bind(mojo::PendingAssociatedReceiver receiver); // See NavigationState::was_initiated_in_this_frame for details. bool was_initiated_in_this_frame() const { return was_initiated_in_this_frame_; } // Sets up a NavigationClient for a renderer-initiated navigation initiated // in this frame. This includes setting `was_initiated_in_this_frame_` to // true and setting up a task to send a navigation-cancellation-window-ended // notification to the browser. void SetUpRendererInitiatedNavigation( mojo::PendingRemote renderer_cancellation_listener_remote); private: // OnDroppedNavigation is bound from BeginNavigation till CommitNavigation. // During this period, it is called when the interface pipe is closed from the // browser side, leading to the ongoing navigation cancellation. void OnDroppedNavigation(); void SetDisconnectionHandler(); void ResetDisconnectionHandler(); // The window of time in which the renderer can cancel this navigation had // ended, so notify the browser about it. void NotifyNavigationCancellationWindowEnded(); mojo::AssociatedReceiver navigation_client_receiver_{ this}; mojo::Remote renderer_cancellation_listener_remote_; RenderFrameImpl* render_frame_; // See NavigationState::was_initiated_in_this_frame for details. bool was_initiated_in_this_frame_ = false; base::WeakPtrFactory weak_ptr_factory_{this}; }; } // namespace content #endif // CONTENT_RENDERER_NAVIGATION_CLIENT_H_