DeviceUtilsImpl has two methods to append/remove the user agent switch:
addDeviceSpecificUserAgentSwitch
- Called on startup
- Uses DeviceFormFactor.isTablet() to determine if the current
display is tablet-sized
updateDeviceSpecificUserAgentSwitch
- Called on display changes
- Accepts as an argument whether the current display is tablet-sized;
the value is actually computed in ChromeActivity using
DisplayUtil.getCurrentSmallestScreenWidth(Context)
Unfortunately two methods inconsistently determine whether the current
display is tablet-sized, for two reasons:
1. When free-form windows are enabled, DeviceFormFactor.isTablet()
checks the current *window* size, not the *display* size. This ended
up with the user agent switch value depending on the initial window
size.
2. When multiple displays are available and multiple Chrome windows are
in different displays, DisplayUtil.getCurrentSmallestScreenWidth()
may return different results per display.
This patch fixes the first issue by:
- merging the two methods into one for consistency
- updating the method to get the display size, not the window size, when
free-form windows are enabled.
Bug: 375056831
Change-Id: Id280c1b35eb04b533360a4599eafa25369f7555d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6176859
Reviewed-by: Shu Yang <shuyng@google.com>
Reviewed-by: Yaron Friedman <yfriedman@chromium.org>
Reviewed-by: Bo Liu <boliu@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Shuhei Takahashi <nya@chromium.org>
Reviewed-by: Luke Halliwell <halliwell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1410081}