0

Replace ReloadType::ORIGINAL_REQUEST_URL with LoadOriginalRequestURL.

When reloading the current NavigationEntry using the original request's
URL, it is safer to treat it as a new navigation to the URL with
replacement, rather than using any of the state from the
NavigationEntry for a different URL.

Bug: 1427288
Change-Id: Iceae630f17bc8091637d500512f887fa5796070c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4370988
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: Charlie Reis <creis@chromium.org>
Reviewed-by: Nate Chapin <japhet@chromium.org>
Reviewed-by: Chris Bookholt <bookholt@chromium.org>
Reviewed-by: Theresa Sullivan <twellington@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1160920}
This commit is contained in:
Charlie Reis
2023-06-21 23:17:53 +00:00
committed by Chromium LUCI CQ
parent aa535341da
commit 4c53a96c20
18 changed files with 222 additions and 66 deletions

@ -2520,7 +2520,7 @@ public abstract class ChromeActivity<C extends ChromeActivityComponent>
RequestDesktopUtils.setRequestDesktopSiteContentSettingsForUrl(
profile, currentTab.getUrl(), usingDesktopUserAgent);
// Use TabUtils.switchUserAgent() instead of Tab.reload(). Because we need to reload
// with ReloadType::ORIGINAL_REQUEST_URL. See http://crbug/1418587 for details.
// with LoadOriginalRequestURL. See http://crbug/1418587 for details.
TabUtils.switchUserAgent(currentTab, usingDesktopUserAgent,
/* forcedByUser */ false, UseDesktopUserAgentCaller.ON_MENU_OR_KEYBOARD_ACTION);
// TODO(crbug.com/1456560): Remove this IPH when the usage is low.

@ -102,7 +102,7 @@ void TabletModePageBehavior::SetMobileLikeBehaviorEnabled(bool enabled) {
arc::ArcWebContentsData::ArcWebContentsData::
kArcTransitionFlag)) {
entry->SetIsOverridingUserAgent(false);
controller.Reload(content::ReloadType::ORIGINAL_REQUEST_URL, true);
controller.LoadOriginalRequestURL();
}
}
}

@ -1837,7 +1837,7 @@ void ToggleRequestTabletSite(Browser* browser) {
entry->SetIsOverridingUserAgent(false);
else
SetAndroidOsForTabletSite(current_tab);
controller.Reload(content::ReloadType::ORIGINAL_REQUEST_URL, true);
controller.LoadOriginalRequestURL();
}
void SetAndroidOsForTabletSite(content::WebContents* current_tab) {

@ -471,7 +471,7 @@ void NavigationControllerAndroid::SetUseDesktopUserAgentInternal(
if (reload_on_state_change) {
// Reloading the page will send the override down as part of the
// navigation IPC message.
navigation_controller_->Reload(ReloadType::ORIGINAL_REQUEST_URL, true);
navigation_controller_->LoadOriginalRequestURL();
}
}

@ -360,8 +360,6 @@ blink::mojom::NavigationType GetNavigationType(
return blink::mojom::NavigationType::RELOAD;
case ReloadType::BYPASSING_CACHE:
return blink::mojom::NavigationType::RELOAD_BYPASSING_CACHE;
case ReloadType::ORIGINAL_REQUEST_URL:
return blink::mojom::NavigationType::RELOAD_ORIGINAL_REQUEST_URL;
case ReloadType::NONE:
break; // Fall through to rest of function.
}
@ -1319,6 +1317,32 @@ base::WeakPtr<NavigationHandle> NavigationControllerImpl::LoadURLWithParams(
return NavigateWithoutEntry(params);
}
void NavigationControllerImpl::LoadOriginalRequestURL() {
// If the original request URL is not valid, matches the current URL, or
// involves POST data, then simply reload. The POST check avoids issues with
// sending data to the wrong page.
const GURL& last_committed_url = GetLastCommittedEntry()->GetURL();
const GURL& original_request_url =
GetLastCommittedEntry()->GetOriginalRequestURL();
if (!original_request_url.is_valid() ||
original_request_url == last_committed_url ||
GetLastCommittedEntry()->GetHasPostData()) {
Reload(ReloadType::NORMAL, true);
return;
}
// Otherwise, attempt to load the original request URL without any of the
// other data from the current NavigationEntry, replacing the current entry.
// Loading the original URL is useful in cases such as modifying the user
// agent.
std::unique_ptr<NavigationController::LoadURLParams> load_params =
std::make_unique<NavigationController::LoadURLParams>(
original_request_url);
load_params->should_replace_current_entry = true;
load_params->transition_type = ui::PAGE_TRANSITION_RELOAD;
LoadURLWithParams(*load_params.get());
}
bool NavigationControllerImpl::PendingEntryMatchesRequest(
NavigationRequest* request) const {
return pending_entry_ &&
@ -4029,15 +4053,6 @@ NavigationControllerImpl::CreateNavigationRequestFromEntry(
DCHECK(!entry->IsInitialEntryNotForSynchronousAboutBlank());
Referrer dest_referrer = frame_entry->referrer();
if (reload_type == ReloadType::ORIGINAL_REQUEST_URL &&
entry->GetOriginalRequestURL().is_valid() && !entry->GetHasPostData()) {
// We may have been redirected when navigating to the current URL.
// Use the URL the user originally intended to visit as signaled by the
// ReloadType, if it's valid and if a POST wasn't involved; the latter
// case avoids issues with sending data to the wrong page.
dest_url = entry->GetOriginalRequestURL();
dest_referrer = Referrer();
}
if (frame_tree_node->render_manager()->is_attaching_inner_delegate()) {
// Avoid starting any new navigations since this node is now preparing for

@ -123,6 +123,7 @@ class CONTENT_EXPORT NavigationControllerImpl : public NavigationController {
base::WeakPtr<NavigationHandle> LoadURLWithParams(
const LoadURLParams& params) override;
void LoadIfNecessary() override;
void LoadOriginalRequestURL() override;
base::WeakPtr<NavigationHandle> LoadPostCommitErrorPage(
RenderFrameHost* render_frame_host,
const GURL& url,

@ -12157,12 +12157,165 @@ class RenderProcessKilledObserver : public WebContentsObserver {
};
} // namespace
// This tests a race in Reload with ReloadType::ORIGINAL_REQUEST_URL, where a
// cross-origin reload was causing an in-flight replaceState to look like a
// cross-origin navigation, even though it's same document. (The reload should
// not modify the underlying last committed entry.) Not crashing means that
// the test is successful.
IN_PROC_BROWSER_TEST_P(NavigationControllerBrowserTest, ReloadOriginalRequest) {
// Ensure that loading the original request URL results in a simple reload if
// there was no redirect, to avoid clearing state (e.g., navigation API state).
IN_PROC_BROWSER_TEST_P(NavigationControllerBrowserTest,
LoadOriginalRequestURLSameURL) {
// Load a page on origin A.
GURL original_url(embedded_test_server()->GetURL(
"a.com", "/navigation_controller/simple_page_1.html"));
EXPECT_TRUE(NavigateToURL(shell(), original_url));
NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>(
shell()->web_contents()->GetController());
// Update navigation API state.
{
std::string script = "navigation.updateCurrentEntry({ state: {x: 'y'} });";
EXPECT_TRUE(ExecJs(shell(), script));
}
// Navigate to another page and then come back, creating a forward entry.
GURL forward_url(embedded_test_server()->GetURL(
"b.com", "/navigation_controller/simple_page_2.html"));
EXPECT_TRUE(NavigateToURL(shell(), forward_url));
{
TestNavigationObserver observer(shell()->web_contents(), 1);
controller.GoBack();
observer.Wait();
ASSERT_TRUE(controller.CanGoForward());
}
// Load the original request URL, which is the same URL.
TestNavigationObserver nav_observer(shell()->web_contents());
controller.LoadOriginalRequestURL();
nav_observer.Wait();
ASSERT_EQ(original_url, shell()->web_contents()->GetLastCommittedURL());
// The navigation API state should still be present, because the request was
// treated as a reload.
EXPECT_EQ(true,
EvalJs(shell(), "navigation.currentEntry.getState().x == 'y'"));
// The forward entry should still exist.
EXPECT_TRUE(controller.CanGoForward());
}
// Ensure that loading the original request URL after a redirect uses a clean
// slate and doesn't crash (e.g., due to using the wrong process for the
// initiator origin of an about:blank URL, as in https://crbug.com/1427288).
IN_PROC_BROWSER_TEST_P(NavigationControllerBrowserTest,
LoadOriginalRequestURLCrossSite) {
// Load a page on site A.
GURL original_url(embedded_test_server()->GetURL(
"a.com", "/navigation_controller/simple_page_1.html"));
EXPECT_TRUE(NavigateToURL(shell(), original_url));
NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>(
shell()->web_contents()->GetController());
FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
->GetPrimaryFrameTree()
.root();
// Navigate to about:blank, inheriting A's origin.
EXPECT_TRUE(NavigateToURLFromRenderer(shell(), GURL(url::kAboutBlankURL)));
// Redirect to a page on site B.
GURL redirect_url(embedded_test_server()->GetURL(
"b.com", "/navigation_controller/simple_page_1.html"));
{
std::string script = "location.replace('" + redirect_url.spec() + "');";
FrameNavigateParamsCapturer capturer(root);
EXPECT_TRUE(ExecJs(shell(), script));
capturer.Wait();
EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
capturer.transition(),
ui::PageTransitionFromInt(ui::PAGE_TRANSITION_LINK |
ui::PAGE_TRANSITION_CLIENT_REDIRECT)));
EXPECT_TRUE(capturer.did_replace_entry());
}
// There should be a Referrer at this point.
EXPECT_EQ(GURL(url::kAboutBlankURL),
controller.GetLastCommittedEntry()->GetReferrer().url);
// Load the original request URL. This should not crash, which used to happen
// when loading about:blank with A's origin into B's process.
TestNavigationObserver nav_observer(shell()->web_contents());
controller.LoadOriginalRequestURL();
nav_observer.Wait();
EXPECT_EQ(GURL(url::kAboutBlankURL),
shell()->web_contents()->GetLastCommittedURL());
// There should be no Referrer after loading the original URL.
EXPECT_EQ(GURL::EmptyGURL(),
controller.GetLastCommittedEntry()->GetReferrer().url);
}
// Ensure that loading the original request URL does not reuse state from the
// current URL (e.g., in a cross-origin but same-process navigation).
IN_PROC_BROWSER_TEST_P(NavigationControllerBrowserTest,
LoadOriginalRequestURLCrossOriginSameSite) {
// Load a page on origin A.
GURL original_url(embedded_test_server()->GetURL(
"a.foo.com", "/navigation_controller/simple_page_1.html"));
EXPECT_TRUE(NavigateToURL(shell(), original_url));
NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>(
shell()->web_contents()->GetController());
FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
->GetPrimaryFrameTree()
.root();
// Redirect to a page on origin B, within the same site.
GURL redirect_url(embedded_test_server()->GetURL(
"b.foo.com", "/navigation_controller/simple_page_1.html"));
{
std::string script = "location.replace('" + redirect_url.spec() + "');";
FrameNavigateParamsCapturer capturer(root);
EXPECT_TRUE(ExecJs(shell(), script));
capturer.Wait();
EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
capturer.transition(),
ui::PageTransitionFromInt(ui::PAGE_TRANSITION_LINK |
ui::PAGE_TRANSITION_CLIENT_REDIRECT)));
EXPECT_TRUE(capturer.did_replace_entry());
}
// Update navigation API state for the new origin.
{
std::string script = "navigation.updateCurrentEntry({ state: {x: 'y'} });";
EXPECT_TRUE(ExecJs(shell(), script));
}
// Navigate to another page and then come back, creating a forward entry.
GURL forward_url(embedded_test_server()->GetURL(
"b.com", "/navigation_controller/simple_page_2.html"));
EXPECT_TRUE(NavigateToURL(shell(), forward_url));
{
TestNavigationObserver observer(shell()->web_contents(), 1);
controller.GoBack();
observer.Wait();
ASSERT_TRUE(controller.CanGoForward());
}
// Load the original request URL.
TestNavigationObserver nav_observer(shell()->web_contents());
controller.LoadOriginalRequestURL();
nav_observer.Wait();
ASSERT_EQ(original_url, shell()->web_contents()->GetLastCommittedURL());
// The navigation API state for origin B should not be visible to origin A.
EXPECT_EQ(true,
EvalJs(shell(), "navigation.currentEntry.getState() == undefined"));
// The forward entry should still exist.
EXPECT_TRUE(controller.CanGoForward());
}
// This tests a race in LoadOriginalRequestURL, where a cross-origin reload was
// causing an in-flight replaceState to look like a cross-origin navigation,
// even though it's same document. (The reload should not modify the underlying
// last committed entry.) Not crashing means that the test is successful.
IN_PROC_BROWSER_TEST_P(NavigationControllerBrowserTest,
LoadOriginalRequestURLRace) {
// TODO(lukasza): https://crbug.com/1159466: Get tests working for all
// process model modes.
if (AreStrictSiteInstancesEnabled() ||
@ -12178,7 +12331,7 @@ IN_PROC_BROWSER_TEST_P(NavigationControllerBrowserTest, ReloadOriginalRequest) {
.root();
RenderProcessKilledObserver kill_observer(shell()->web_contents());
// Redirect so that we can use Reload with ReloadType::ORIGINAL_REQUEST_URL.
// Redirect so that we can use LoadOriginalRequestURL.
GURL redirect_url(embedded_test_server()->GetURL(
"foo.com", "/navigation_controller/simple_page_1.html"));
{
@ -12198,18 +12351,16 @@ IN_PROC_BROWSER_TEST_P(NavigationControllerBrowserTest, ReloadOriginalRequest) {
{
// We first send a replaceState() to the renderer, which will cause the
// renderer to send back a DidCommitProvisionalLoad. Immediately after,
// we send a Reload request with ReloadType::ORIGINAL_REQUEST_URL (which in
// this case is a different origin) and will also cause the renderer to
// commit the frame. In the end we verify that both navigations committed
// and that the URLs are correct.
// we use LoadOriginalRequestURL (which in this case is a different origin)
// and will also cause the renderer to commit the frame. In the end we
// verify that both navigations committed and that the URLs are correct.
std::string script = "history.replaceState({}, '', 'foo');";
root->render_manager()
->current_frame_host()
->ExecuteJavaScriptWithUserGestureForTests(base::UTF8ToUTF16(script),
base::NullCallback());
EXPECT_FALSE(shell()->web_contents()->IsLoading());
shell()->web_contents()->GetController().Reload(
ReloadType::ORIGINAL_REQUEST_URL, false);
shell()->web_contents()->GetController().LoadOriginalRequestURL();
EXPECT_TRUE(shell()->web_contents()->IsLoading());
EXPECT_EQ(redirect_url, shell()->web_contents()->GetLastCommittedURL());
@ -19608,7 +19759,7 @@ IN_PROC_BROWSER_TEST_P(NavigationControllerBrowserTest,
// Update the entry and load it.
controller.GetLastCommittedEntry()->SetIsOverridingUserAgent(true);
EXPECT_TRUE(controller.GetLastCommittedEntry()->GetIsOverridingUserAgent());
controller.Reload(ReloadType::ORIGINAL_REQUEST_URL, true);
controller.LoadOriginalRequestURL();
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
EXPECT_TRUE(controller.GetLastCommittedEntry()->GetIsOverridingUserAgent());

@ -1390,15 +1390,16 @@ TEST_F(NavigationControllerTest, ReloadOriginalRequestURL) {
EXPECT_EQ(final_url, controller.GetVisibleEntry()->GetURL());
// Reload using the original URL.
controller.Reload(ReloadType::ORIGINAL_REQUEST_URL, false);
controller.LoadOriginalRequestURL();
EXPECT_EQ(0U, navigation_entry_changed_counter_);
EXPECT_EQ(0U, navigation_list_pruned_counter_);
// The reload is pending. The request should point to the original URL.
// The reload is pending as a new pending entry with replacement. The request
// should point to the original URL.
EXPECT_EQ(original_url, navigated_url());
EXPECT_EQ(controller.GetEntryCount(), 1);
EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0);
EXPECT_EQ(controller.GetPendingEntryIndex(), 0);
EXPECT_EQ(controller.GetPendingEntryIndex(), -1);
EXPECT_TRUE(controller.GetLastCommittedEntry());
EXPECT_TRUE(controller.GetPendingEntry());
EXPECT_FALSE(controller.CanGoBack());
@ -1420,7 +1421,7 @@ TEST_F(NavigationControllerTest, ReloadOriginalRequestURL) {
EXPECT_FALSE(controller.GetPendingEntry());
EXPECT_FALSE(controller.CanGoBack());
EXPECT_FALSE(controller.CanGoForward());
EXPECT_EQ(ReloadType::ORIGINAL_REQUEST_URL, main_test_rfh()->reload_type());
EXPECT_EQ(ReloadType::NONE, main_test_rfh()->reload_type());
}
// Test that certain non-persisted NavigationEntryImpl values get reset after
@ -1523,7 +1524,7 @@ TEST_F(NavigationControllerTest, GoBackWithUserAgentOverrideChange) {
// Simulate the behavior of "Request Desktop Site" being checked in
// NavigationControllerAndroid::SetUseDesktopUserAgent.
controller.GetVisibleEntry()->SetIsOverridingUserAgent(true);
controller.Reload(ReloadType::ORIGINAL_REQUEST_URL, true);
controller.LoadOriginalRequestURL();
auto reload =
NavigationSimulator::CreateFromPending(contents()->GetController());
reload->Commit();

@ -340,8 +340,8 @@ IN_PROC_BROWSER_TEST_F(NavigationPolicyContainerBuilderBrowserTest,
// Now reload to original url and ensure that history entry policies stored
// earlier aren't applied to non-local URL (no DCHECK triggered).
TestNavigationObserver observer(tab, /*number_of_navigations=*/1);
tab->GetController().Reload(ReloadType::ORIGINAL_REQUEST_URL, false);
TestNavigationObserver observer(tab, /*expected_number_of_navigations=*/1);
tab->GetController().LoadOriginalRequestURL();
observer.Wait(); // No DCHECK expected.
EXPECT_EQ(PublicUrl(), tab->GetLastCommittedURL());
}

@ -258,7 +258,6 @@ void UpdateLoadFlagsWithCacheFlags(int* load_flags,
bool is_post) {
switch (navigation_type) {
case blink::mojom::NavigationType::RELOAD:
case blink::mojom::NavigationType::RELOAD_ORIGINAL_REQUEST_URL:
*load_flags |= net::LOAD_VALIDATE_CACHE;
break;
case blink::mojom::NavigationType::RELOAD_BYPASSING_CACHE:
@ -654,7 +653,6 @@ blink::mojom::NavigationType ConvertToCrossDocumentType(
return blink::mojom::NavigationType::HISTORY_DIFFERENT_DOCUMENT;
case blink::mojom::NavigationType::RELOAD:
case blink::mojom::NavigationType::RELOAD_BYPASSING_CACHE:
case blink::mojom::NavigationType::RELOAD_ORIGINAL_REQUEST_URL:
case blink::mojom::NavigationType::RESTORE:
case blink::mojom::NavigationType::RESTORE_WITH_POST:
case blink::mojom::NavigationType::HISTORY_DIFFERENT_DOCUMENT:
@ -8061,8 +8059,6 @@ ReloadType NavigationRequest::NavigationTypeToReloadType(
return ReloadType::NORMAL;
if (type == blink::mojom::NavigationType::RELOAD_BYPASSING_CACHE)
return ReloadType::BYPASSING_CACHE;
if (type == blink::mojom::NavigationType::RELOAD_ORIGINAL_REQUEST_URL)
return ReloadType::ORIGINAL_REQUEST_URL;
return ReloadType::NONE;
}

@ -1561,8 +1561,7 @@ IN_PROC_BROWSER_TEST_P(RenderFrameHostManagerTest,
shell()->web_contents()->SetWasDiscarded(true);
// Reload the discarded page, but pretend that it's slow to commit.
TestNavigationManager first_reload(shell()->web_contents(), discarded_url);
shell()->web_contents()->GetController().Reload(
ReloadType::ORIGINAL_REQUEST_URL, false);
shell()->web_contents()->GetController().LoadOriginalRequestURL();
EXPECT_TRUE(first_reload.WaitForRequestStart());
// Before the response is received, simulate user navigating to another URL.
GURL second_url(embedded_test_server()->GetURL("b.com", "/title1.html"));
@ -1732,8 +1731,7 @@ IN_PROC_BROWSER_TEST_P(
// Now reload the original request, but redirect to yet another site.
TestNavigationManager first_reload(shell()->web_contents(), kOriginalURL);
shell()->web_contents()->GetController().Reload(
ReloadType::ORIGINAL_REQUEST_URL, false);
shell()->web_contents()->GetController().LoadOriginalRequestURL();
EXPECT_TRUE(first_reload.WaitForRequestStart());
first_reload.ResumeNavigation();
@ -1767,8 +1765,7 @@ IN_PROC_BROWSER_TEST_P(
CommitNavigationPauser commit_pauser(first_speculative_rfh.get());
first_reload.ResumeNavigation();
commit_pauser.WaitForCommitAndPause();
shell()->web_contents()->GetController().Reload(
ReloadType::ORIGINAL_REQUEST_URL, false);
shell()->web_contents()->GetController().LoadOriginalRequestURL();
EXPECT_TRUE(second_reload.WaitForRequestStart());
RenderFrameHostImplWrapper second_speculative_rfh(

@ -13,8 +13,7 @@ class NavigationTypeUtils {
public:
static bool IsReload(blink::mojom::NavigationType value) {
return value == blink::mojom::NavigationType::RELOAD ||
value == blink::mojom::NavigationType::RELOAD_BYPASSING_CACHE ||
value == blink::mojom::NavigationType::RELOAD_ORIGINAL_REQUEST_URL;
value == blink::mojom::NavigationType::RELOAD_BYPASSING_CACHE;
}
static bool IsSameDocument(blink::mojom::NavigationType value) {

@ -449,6 +449,17 @@ class NavigationController {
// explicitly requested using SetNeedsReload().
virtual void LoadIfNecessary() = 0;
// Reloads the current entry using the original URL used to create it. This is
// used for cases where the user wants to refresh a page using a different
// user agent after following a redirect. It is also used in the case of an
// intervention (e.g., preview) being served on the page and the user
// requesting the page without the intervention.
//
// If the current entry's original URL matches the current URL, is invalid, or
// contains POST data, this will result in a normal reload rather than an
// attempt to load the original URL.
virtual void LoadOriginalRequestURL() = 0;
// Navigates directly to an error page in response to an event on the last
// committed page (e.g., triggered by a subresource), with |error_page_html|
// as the contents and |url| as the URL.

@ -16,13 +16,7 @@ enum class ReloadType {
// Reloads the current entry validating only the main resource.
NORMAL,
// Reloads the current entry bypassing the cache (shift-reload).
BYPASSING_CACHE,
// Reloads the current entry using the original URL used to create it. This
// is used for cases where the user wants to refresh a page using a different
// user agent after following a redirect. It is also used in the case of an
// intervention (i.e., preview) being served on the page and the user
// requesting the page without the intervention.
ORIGINAL_REQUEST_URL
BYPASSING_CACHE
};
} // namespace content

@ -609,7 +609,6 @@ WebFrameLoadType NavigationTypeToLoadType(
bool should_replace_current_entry) {
switch (navigation_type) {
case blink::mojom::NavigationType::RELOAD:
case blink::mojom::NavigationType::RELOAD_ORIGINAL_REQUEST_URL:
return WebFrameLoadType::kReload;
case blink::mojom::NavigationType::RELOAD_BYPASSING_CACHE:
@ -854,9 +853,6 @@ std::unique_ptr<DocumentState> BuildDocumentStateFromParams(
document_state->set_is_overriding_user_agent(
commit_params.is_overriding_user_agent);
document_state->set_must_reset_scroll_and_scale_state(
common_params.navigation_type ==
blink::mojom::NavigationType::RELOAD_ORIGINAL_REQUEST_URL);
document_state->set_request_id(request_id);
// If this is a loadDataWithBaseURL request, save the commit URL so that we

@ -2723,8 +2723,7 @@ TEST_F(RenderViewImplTest, NavigationStartForReload) {
auto common_params = blink::CreateCommonNavigationParams();
common_params->url = GURL(url_string);
common_params->navigation_type =
blink::mojom::NavigationType::RELOAD_ORIGINAL_REQUEST_URL;
common_params->navigation_type = blink::mojom::NavigationType::RELOAD;
common_params->transition = ui::PAGE_TRANSITION_RELOAD;
// The browser navigation_start should not be used because beforeunload will

@ -48,9 +48,6 @@ enum NavigationType {
// Reload the page, bypassing any cache entries.
RELOAD_BYPASSING_CACHE,
// Reload the page using the original request URL.
RELOAD_ORIGINAL_REQUEST_URL,
// The navigation is the result of session restore and should honor the
// page's cache policy while restoring form state. This is set to true if
// restoring a tab/session from the previous session and the previous

@ -792,8 +792,7 @@ void TabImpl::SetDesktopUserAgentEnabled(JNIEnv* env, jboolean enable) {
entry->SetIsOverridingUserAgent(enable);
web_contents_->NotifyPreferencesChanged();
web_contents_->GetController().Reload(
content::ReloadType::ORIGINAL_REQUEST_URL, true);
web_contents_->GetController().LoadOriginalRequestURL();
}
jboolean TabImpl::IsDesktopUserAgentEnabled(JNIEnv* env) {