Commit 9807c025 authored by Yu Su's avatar Yu Su Committed by Commit Bot

lens shopping experiment - fallback to search with lens when lens feature is...

lens shopping experiment - fallback to search with lens when lens feature is supported but AGSA is below shopping supported version


Bug: 158099013
Change-Id: I29144114249ec199ca03dcc8686fa55afa99bb22
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2268300
Commit-Queue: Yu Su <yusuyoutube@google.com>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782765}
parent 0028790a
...@@ -1016,9 +1016,12 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator { ...@@ -1016,9 +1016,12 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
}); });
} }
// In Lens Shopping Menu Item experiment, fallback to search image with google lens // In Lens Shopping Menu Item experiment, fallback to Search image with Google Lens
// When the url is not in domain allowlist. // When the url is not in domain allowlist and AGSA version is equal to or greater than the
if (LensUtils.enableGoogleLensShoppingFeature()) { // minimum shopping supported version.
if (LensUtils.enableGoogleLensShoppingFeature()
&& !GSAState.getInstance(context).isAgsaVersionBelowMinimum(
versionName, LensUtils.getMinimumAgsaVersionForLensShoppingSupport())) {
if (LensUtils.isInShoppingAllowlist(pageUrl)) { if (LensUtils.isInShoppingAllowlist(pageUrl)) {
// Hide Search With Google Lens menu item when experiment only with Lens Shopping // Hide Search With Google Lens menu item when experiment only with Lens Shopping
// menu items. // menu items.
......
...@@ -152,33 +152,45 @@ public class LensUtils { ...@@ -152,33 +152,45 @@ public class LensUtils {
* @return The minimum version name string or an empty string if not available. * @return The minimum version name string or an empty string if not available.
*/ */
public static String getMinimumAgsaVersionForLensSupport() { public static String getMinimumAgsaVersionForLensSupport() {
// Shopping feature AGSA version takes priority over Search with Google Lens if (ChromeFeatureList.isEnabled(ChromeFeatureList.CONTEXT_MENU_SEARCH_WITH_GOOGLE_LENS)) {
if (ChromeFeatureList.isEnabled(ChromeFeatureList.CONTEXT_MENU_SHOP_WITH_GOOGLE_LENS)) {
final String serverProvidedMinAgsaVersion = final String serverProvidedMinAgsaVersion =
ChromeFeatureList.getFieldTrialParamByFeature( ChromeFeatureList.getFieldTrialParamByFeature(
ChromeFeatureList.CONTEXT_MENU_SHOP_WITH_GOOGLE_LENS, ChromeFeatureList.CONTEXT_MENU_SEARCH_WITH_GOOGLE_LENS,
MIN_AGSA_VERSION_FEATURE_PARAM_NAME); MIN_AGSA_VERSION_FEATURE_PARAM_NAME);
if (TextUtils.isEmpty(serverProvidedMinAgsaVersion)) { if (TextUtils.isEmpty(serverProvidedMinAgsaVersion)) {
// Falls into this block if the user enabled the feature using chrome://flags // Falls into this block if the user enabled the feature using chrome://flags
// and the param was not set by the server. // and the param was not set by the server.
return MIN_AGSA_VERSION_NAME_FOR_LENS_CHROME_SHOPPING_INTENT; return MIN_AGSA_VERSION_NAME_FOR_LENS_POSTCAPTURE;
} }
return serverProvidedMinAgsaVersion; return serverProvidedMinAgsaVersion;
} }
// The feature is disabled so no need to return a minimum version.
return "";
}
if (ChromeFeatureList.isEnabled(ChromeFeatureList.CONTEXT_MENU_SEARCH_WITH_GOOGLE_LENS)) { /**
* Gets the minimum AGSA version required to support the Lens shopping context menu
* integration on this device. Takes the value from a server provided value if a
* field trial is active but otherwise will take the value from a client side
* default (unless the lens feature is not enabled at all, in which case return
* an empty string).
*
* @return The minimum version name string or an empty string if not available.
*/
public static String getMinimumAgsaVersionForLensShoppingSupport() {
// Shopping feature AGSA version takes priority over Search with Google Lens
if (ChromeFeatureList.isEnabled(ChromeFeatureList.CONTEXT_MENU_SHOP_WITH_GOOGLE_LENS)) {
final String serverProvidedMinAgsaVersion = final String serverProvidedMinAgsaVersion =
ChromeFeatureList.getFieldTrialParamByFeature( ChromeFeatureList.getFieldTrialParamByFeature(
ChromeFeatureList.CONTEXT_MENU_SEARCH_WITH_GOOGLE_LENS, ChromeFeatureList.CONTEXT_MENU_SHOP_WITH_GOOGLE_LENS,
MIN_AGSA_VERSION_FEATURE_PARAM_NAME); MIN_AGSA_VERSION_FEATURE_PARAM_NAME);
if (TextUtils.isEmpty(serverProvidedMinAgsaVersion)) { if (TextUtils.isEmpty(serverProvidedMinAgsaVersion)) {
// Falls into this block if the user enabled the feature using chrome://flags // Falls into this block if the user enabled the feature using chrome://flags
// and the param was not set by the server. // and the param was not set by the server.
return MIN_AGSA_VERSION_NAME_FOR_LENS_POSTCAPTURE; return MIN_AGSA_VERSION_NAME_FOR_LENS_CHROME_SHOPPING_INTENT;
} }
return serverProvidedMinAgsaVersion; return serverProvidedMinAgsaVersion;
} }
// The feature is disabled so no need to return a minimum version.
return ""; return "";
} }
......
...@@ -349,15 +349,15 @@ const char kContextMenuShopWithGoogleLensName[] = ...@@ -349,15 +349,15 @@ const char kContextMenuShopWithGoogleLensName[] =
"Google Lens powered image search for shoppable images in the context " "Google Lens powered image search for shoppable images in the context "
"menu."; "menu.";
const char kContextMenuShopWithGoogleLensDescription[] = const char kContextMenuShopWithGoogleLensDescription[] =
"Replaces default image search with a Shopping intent to Google Lens when " "Enable a menu item for a Shopping intent into Google Lens when supported. "
"supported"; "By default replaces the Search with Google Lens option.";
const char kContextMenuSearchAndShopWithGoogleLensName[] = const char kContextMenuSearchAndShopWithGoogleLensName[] =
"Google Lens powered image search and shopping in the context menu."; "Additional menu item for Google Lens image search for shoppable images in "
"the context menu.";
const char kContextMenuSearchAndShopWithGoogleLensDescription[] = const char kContextMenuSearchAndShopWithGoogleLensDescription[] =
"Replaces default image search with an intent to Google Lens when " "Display an additional menu item for a Shopping intent to Google Lens "
"supported. Also display an additional menu item for a Shopping intent to " "below Search with Google Lens when Lens shopping feature is enabled";
"Google Lens when supported";
const char kOmniboxContextMenuShowFullUrlsName[] = const char kOmniboxContextMenuShowFullUrlsName[] =
"Context menu show full URLs"; "Context menu show full URLs";
......
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