Commit a62f5e7e authored by spdonghao's avatar spdonghao Committed by Chromium LUCI CQ

Fix the transition type.

This transitionType set in willHandleLoadUrlWithPostDataFromStartSurface
in ReturnToChromeExperimentsUtil was from "Experiment: Show the omnibox
on the tab switcher."[1] and were supposed to be FROM_ADDRESS_BAR then.
However this is not accurate anymore for now. It's not guaranteed to be
from address bar.

[1] https://crrev.com/c/1592791

Bug: 1134187
Change-Id: Iab1154fa8395cace3e5a28ca53efbceb11a646ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2593770
Commit-Queue: Hao Dong <spdonghao@chromium.org>
Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Reviewed-by: default avatarFilip Gorski <fgorski@chromium.org>
Reviewed-by: default avatarXi Han <hanxi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841651}
parent 9cb18c14
......@@ -147,16 +147,16 @@ public final class ReturnToChromeExperimentsUtil {
*/
public static boolean willHandleLoadUrlFromStartSurface(String url,
@PageTransition int transition, @Nullable Boolean incognito, @Nullable Tab parentTab) {
LoadUrlParams params = new LoadUrlParams(url, transition);
return willHandleLoadUrlWithPostDataFromStartSurface(
url, transition, null, null, incognito, parentTab);
params, null, null, incognito, parentTab);
}
/**
* Check if we should handle the navigation. If so, create a new tab and load the URL with POST
* data.
*
* @param url The URL to load.
* @param transition The page transition type.
* @param params The LoadUrlParams to load.
* @param postDataType postData type.
* @param postData POST data to include in the tab URL's request body, ex. bitmap when
* image search.
......@@ -165,9 +165,10 @@ public final class ReturnToChromeExperimentsUtil {
* @param parentTab The parent tab used to create a new tab if needed.
* @return true if we have handled the navigation, false otherwise.
*/
public static boolean willHandleLoadUrlWithPostDataFromStartSurface(String url,
@PageTransition int transition, @Nullable String postDataType,
@Nullable byte[] postData, @Nullable Boolean incognito, @Nullable Tab parentTab) {
public static boolean willHandleLoadUrlWithPostDataFromStartSurface(LoadUrlParams params,
@Nullable String postDataType, @Nullable byte[] postData, @Nullable Boolean incognito,
@Nullable Tab parentTab) {
String url = params.getUrl();
ChromeActivity chromeActivity = getActivityPresentingOverviewWithOmnibox(url);
if (chromeActivity == null) return false;
......@@ -179,9 +180,6 @@ public final class ReturnToChromeExperimentsUtil {
incognitoParam = incognito;
}
LoadUrlParams params = new LoadUrlParams(url);
// TODO(https://crbug.com/1134187): This may no longer accurate.
params.setTransitionType(transition | PageTransition.FROM_ADDRESS_BAR);
if (!TextUtils.isEmpty(postDataType) && postData != null && postData.length != 0) {
params.setVerbatimHeaders("Content-Type: " + postDataType);
params.setPostData(ResourceRequestBody.createFromBytes(postData));
......@@ -190,14 +188,15 @@ public final class ReturnToChromeExperimentsUtil {
chromeActivity.getTabCreator(incognitoParam)
.createNewTab(params, TabLaunchType.FROM_START_SURFACE, parentTab);
if (transition == PageTransition.AUTO_BOOKMARK) {
if (params.getTransitionType() == PageTransition.AUTO_BOOKMARK) {
RecordUserAction.record("Suggestions.Tile.Tapped.GridTabSwitcher");
} else {
RecordUserAction.record("MobileOmniboxUse.GridTabSwitcher");
// These are duplicated here but would have been recorded by LocationBarLayout#loadUrl.
RecordUserAction.record("MobileOmniboxUse");
LocaleManager.getInstance().recordLocaleBasedSearchMetrics(false, url, transition);
LocaleManager.getInstance().recordLocaleBasedSearchMetrics(
false, url, params.getTransitionType());
}
return true;
......
......@@ -137,6 +137,7 @@ import org.chromium.content_public.browser.NavigationHandle;
import org.chromium.content_public.browser.WebContents;
import org.chromium.net.NetError;
import org.chromium.ui.base.DeviceFormFactor;
import org.chromium.ui.base.PageTransition;
import org.chromium.ui.base.WindowAndroid;
import org.chromium.ui.modaldialog.ModalDialogManager;
import org.chromium.ui.util.TokenHolder;
......@@ -463,8 +464,8 @@ public class ToolbarManager implements UrlFocusChangeListener, ThemeColorObserve
OverrideUrlLoadingDelegate overrideUrlLoadingDelegate =
(url, transition, postDataType, postData, incognito)
-> ReturnToChromeExperimentsUtil.willHandleLoadUrlWithPostDataFromStartSurface(
url, transition, postDataType, postData, incognito,
startSurfaceParentTabSupplier.get());
new LoadUrlParams(url, transition | PageTransition.FROM_ADDRESS_BAR),
postDataType, postData, incognito, startSurfaceParentTabSupplier.get());
LocationBarCoordinator locationBarCoordinator = new LocationBarCoordinator(
mActivity.findViewById(R.id.location_bar), toolbarLayout, profileSupplier,
mLocationBarModel, mActionModeController.getActionModeCallback(),
......
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