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