Commit 2a8efe44 authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Commit Bot

Return to a tab's normal version site when exiting tablet mode.

For a tab that is requesting its mobile version site, and is not
originated from ARC context, return to its normal version site when
exiting tablet mode.

Bug: 953577
Change-Id: Ifa1f3b694ae5b237b80ea912f7e1b981b7d0debb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1637181
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664799}
parent 61fb2b60
......@@ -9,11 +9,14 @@
#include "ash/public/cpp/tablet_mode.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "base/bind.h"
#include "chrome/browser/chromeos/arc/arc_web_contents_data.h"
#include "chrome/browser/ui/ash/tablet_mode_client_observer.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_tab_strip_tracker.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/service_manager_connection.h"
#include "services/service_manager/public/cpp/connector.h"
......@@ -142,6 +145,20 @@ void TabletModeClient::SetMobileLikeBehaviorEnabled(bool enabled) {
DCHECK(web_contents);
web_contents->NotifyPreferencesChanged();
// For a tab that is requesting its mobile version site (via
// chrome::ToggleRequestTabletSite()), and is not originated from ARC
// context, return to its normal version site when exiting tablet mode.
content::NavigationController& controller =
web_contents->GetController();
content::NavigationEntry* entry = controller.GetLastCommittedEntry();
if (entry && entry->GetIsOverridingUserAgent() &&
!web_contents->GetUserData(
arc::ArcWebContentsData::ArcWebContentsData::
kArcTransitionFlag)) {
entry->SetIsOverridingUserAgent(false);
controller.Reload(content::ReloadType::ORIGINAL_REQUEST_URL, true);
}
}
}
tab_strip_tracker_ = nullptr;
......
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