Commit 30ed0a82 authored by arthursonzogni's avatar arthursonzogni Committed by Commit Bot

Remove unused function [3/n]

Remove all the uncalled function from the TestRenderFrameHost and the
NavigationSimulator.

There was this comment on:
https://chromium-review.googlesource.com/c/chromium/src/+/2529096/11/content/test/test_render_frame_host.cc#334
removing unused function ensure they won't be called.

Bug: 1146469
Change-Id: I8acb24089203a10d3acaac2d2366179d86f1e9aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2537632Reviewed-by: default avatarCamille Lamy <clamy@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827253}
parent 7ae838d7
......@@ -255,9 +255,6 @@ class NavigationSimulator {
// Sets whether this navigation originated as the result of a form submission.
virtual void SetIsFormSubmission(bool is_form_submission) = 0;
// Sets whether this navigation originated as the result of a link click.
virtual void SetWasInitiatedByLinkClick(bool was_initiated_by_link_click) = 0;
// The following parameters can change during redirects. They should be
// specified before calling |Start| if they need to apply to the navigation to
// the original url. Otherwise, they should be specified before calling
......@@ -275,18 +272,6 @@ class NavigationSimulator {
virtual void SetIsSignedExchangeInnerResponse(
bool is_signed_exchange_inner_response) = 0;
// Sets the InterfaceProvider interface receiver to pass in as an argument to
// DidCommitProvisionalLoad for cross-document navigations. If not called,
// a stub will be passed in (which will never receive any interface
// receivers).
//
// This interface connection would normally be created by the RenderFrame,
// with the client end bound to |remote_interfaces_| to allow the new document
// to access services exposed by the RenderFrameHost.
virtual void SetInterfaceProviderReceiver(
mojo::PendingReceiver<service_manager::mojom::InterfaceProvider>
receiver) = 0;
// Provides the contents mime type to be set at commit. It should be
// specified before calling |ReadyToCommit| or |Commit|.
virtual void SetContentsMimeType(const std::string& contents_mime_type) = 0;
......@@ -343,9 +328,6 @@ class NavigationSimulator {
// Simulate the ongoing load stopping successfully.
virtual void StopLoading() = 0;
// Simulates the ongoing load stopping due to |error_code|.
virtual void FailLoading(const GURL& url, int error_code) = 0;
private:
// This interface should only be implemented inside content.
friend class NavigationSimulatorImpl;
......
......@@ -887,13 +887,6 @@ void NavigationSimulatorImpl::SetIsFormSubmission(bool is_form_submission) {
is_form_submission_ = is_form_submission;
}
void NavigationSimulatorImpl::SetWasInitiatedByLinkClick(
bool was_initiated_by_link_click) {
CHECK_EQ(INITIALIZATION, state_) << "The form submission parameter cannot "
"be set after the navigation has started";
was_initiated_by_link_click_ = was_initiated_by_link_click;
}
void NavigationSimulatorImpl::SetReferrer(blink::mojom::ReferrerPtr referrer) {
CHECK_LE(state_, STARTED) << "The referrer cannot be set after the "
"navigation has committed or has failed";
......@@ -921,14 +914,6 @@ void NavigationSimulatorImpl::SetIsSignedExchangeInnerResponse(
is_signed_exchange_inner_response_ = is_signed_exchange_inner_response;
}
void NavigationSimulatorImpl::SetInterfaceProviderReceiver(
mojo::PendingReceiver<service_manager::mojom::InterfaceProvider> receiver) {
CHECK_LE(state_, STARTED) << "The InterfaceProvider cannot be set "
"after the navigation has committed or failed";
CHECK(receiver.is_valid());
interface_provider_receiver_ = std::move(receiver);
}
void NavigationSimulatorImpl::SetContentsMimeType(
const std::string& contents_mime_type) {
CHECK_LE(state_, STARTED) << "The contents mime type cannot be set after the "
......@@ -1165,7 +1150,8 @@ bool NavigationSimulatorImpl::SimulateRendererInitiatedStart() {
blink::mojom::RequestContextType::HYPERLINK,
network::mojom::RequestDestination::kDocument,
blink::WebMixedContentContextType::kBlockable, is_form_submission_,
was_initiated_by_link_click_, GURL() /* searchable_form_url */,
false /* was_initiated_by_link_click */,
GURL() /* searchable_form_url */,
std::string() /* searchable_form_encoding */,
GURL() /* client_side_redirect_url */,
base::nullopt /* detools_initiator_info */,
......@@ -1258,39 +1244,6 @@ bool NavigationSimulatorImpl::IsDeferred() {
return !throttle_checks_complete_closure_.is_null();
}
bool NavigationSimulatorImpl::CheckIfSameDocument() {
// This approach to determining whether a navigation is to be treated as
// same document is not robust, as it will not handle pushState type
// navigation. Do not use elsewhere!
// First we need a valid document that is not an error page.
if (!render_frame_host_->GetLastCommittedURL().is_valid() ||
render_frame_host_->last_commit_was_error_page()) {
return false;
}
// Exclude reloads.
if (ui::PageTransitionCoreTypeIs(transition_, ui::PAGE_TRANSITION_RELOAD)) {
return false;
}
// A browser-initiated navigation to the exact same url in the address bar is
// not a same document navigation.
if (browser_initiated_ &&
render_frame_host_->GetLastCommittedURL() == navigation_url_) {
return false;
}
// Finally, the navigation url and the last committed url should match,
// except for the fragment.
GURL url_copy(navigation_url_);
url::Replacements<char> replacements;
replacements.ClearRef();
return url_copy.ReplaceComponents(replacements) ==
render_frame_host_->GetLastCommittedURL().ReplaceComponents(
replacements);
}
bool NavigationSimulatorImpl::DidCreateNewEntry() {
if (did_create_new_entry_.has_value())
return did_create_new_entry_.value();
......@@ -1407,11 +1360,6 @@ void NavigationSimulatorImpl::StopLoading() {
render_frame_host_->SimulateLoadingCompleted(loading_scenario_);
}
void NavigationSimulatorImpl::FailLoading(const GURL& url, int error_code) {
CHECK(render_frame_host_);
render_frame_host_->DidFailLoadWithError(url, error_code);
}
void NavigationSimulatorImpl::
SimulateUnloadCompletionCallbackForPreviousFrameIfNeeded(
RenderFrameHostImpl* previous_rfh) {
......
......@@ -84,15 +84,11 @@ class NavigationSimulatorImpl : public NavigationSimulator,
void SetReloadType(ReloadType reload_type) override;
void SetMethod(const std::string& method) override;
void SetIsFormSubmission(bool is_form_submission) override;
void SetWasInitiatedByLinkClick(bool was_initiated_by_link_click) override;
void SetReferrer(blink::mojom::ReferrerPtr referrer) override;
void SetSocketAddress(const net::IPEndPoint& remote_endpoint) override;
void SetWasFetchedViaCache(bool was_fetched_via_cache) override;
void SetIsSignedExchangeInnerResponse(
bool is_signed_exchange_inner_response) override;
void SetInterfaceProviderReceiver(
mojo::PendingReceiver<service_manager::mojom::InterfaceProvider> receiver)
override;
void SetContentsMimeType(const std::string& contents_mime_type) override;
void SetResponseHeaders(
scoped_refptr<net::HttpResponseHeaders> response_headers) override;
......@@ -107,7 +103,6 @@ class NavigationSimulatorImpl : public NavigationSimulator,
void SetKeepLoading(bool keep_loading) override;
void StopLoading() override;
void FailLoading(const GURL& url, int error_code) override;
// Additional utilities usable only inside content/.
......@@ -230,10 +225,6 @@ class NavigationSimulatorImpl : public NavigationSimulator,
// NavigationRequest.
void PrepareCompleteCallbackOnRequest();
// Check if the navigation corresponds to a same-document navigation.
// Only use on renderer-initiated navigations.
bool CheckIfSameDocument();
// Infers from internal parameters whether the navigation created a new
// entry.
bool DidCreateNewEntry();
......@@ -288,7 +279,6 @@ class NavigationSimulatorImpl : public NavigationSimulator,
bool is_signed_exchange_inner_response_ = false;
std::string initial_method_;
bool is_form_submission_ = false;
bool was_initiated_by_link_click_ = false;
bool browser_initiated_;
bool same_document_ = false;
TestRenderFrameHost::LoadingScenario loading_scenario_ =
......
......@@ -181,51 +181,6 @@ void TestRenderFrameHost::SimulateRedirect(const GURL& new_url) {
url_loader->SimulateServerRedirect(new_url);
}
void TestRenderFrameHost::SimulateNavigationCommit(const GURL& url) {
if (frame_tree_node_->navigation_request())
PrepareForCommit();
bool is_auto_subframe =
GetParent() && !frame_tree_node()->has_committed_real_load();
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.nav_entry_id = 0;
params.url = url;
params.origin = url::Origin::Create(url);
if (!GetParent())
params.transition = ui::PAGE_TRANSITION_LINK;
else if (is_auto_subframe)
params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME;
else
params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME;
params.should_update_history = true;
params.did_create_new_entry = !is_auto_subframe;
params.gesture = NavigationGestureUser;
params.contents_mime_type = "text/html";
params.method = "GET";
params.http_status_code = 200;
params.history_list_was_cleared = simulate_history_list_was_cleared_;
params.original_request_url = url;
url::Replacements<char> replacements;
replacements.ClearRef();
// This approach to determining whether a navigation is to be treated as
// same document is not robust, as it will not handle pushState type
// navigation. Do not use elsewhere!
bool was_within_same_document =
(GetLastCommittedURL().is_valid() && !last_commit_was_error_page_ &&
url.ReplaceComponents(replacements) ==
GetLastCommittedURL().ReplaceComponents(replacements));
params.page_state =
blink::PageState::CreateForTesting(url, false, nullptr, nullptr);
if (!was_within_same_document)
params.embedding_token = base::UnguessableToken::Create();
SendNavigateWithParams(&params, was_within_same_document);
}
void TestRenderFrameHost::SimulateBeforeUnloadCompleted(bool proceed) {
base::TimeTicks now = base::TimeTicks::Now();
ProcessBeforeUnloadCompleted(
......
......@@ -116,10 +116,6 @@ class TestRenderFrameHost : public RenderFrameHostImpl,
// DEPRECATED: use NavigationSimulator instead.
void SimulateRedirect(const GURL& new_url);
// Simulates a navigation to |url| committing in the RenderFrameHost.
// DEPRECATED: use NavigationSimulator instead.
void SimulateNavigationCommit(const GURL& url);
// This method simulates receiving a BeginNavigation IPC.
// DEPRECATED: use NavigationSimulator instead.
void SendRendererInitiatedNavigationRequest(const GURL& url,
......@@ -176,10 +172,6 @@ class TestRenderFrameHost : public RenderFrameHostImpl,
// Creates a WebBluetooth Service with a dummy InterfaceRequest.
WebBluetoothServiceImpl* CreateWebBluetoothServiceForTesting();
bool last_commit_was_error_page() const {
return last_commit_was_error_page_;
}
// Returns a PendingReceiver<InterfaceProvider> that is safe to bind to an
// implementation, but will never receive any interface receivers.
static mojo::PendingReceiver<service_manager::mojom::InterfaceProvider>
......
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