Remove shop similar products and search similar products from code.
We've decided to keep "Shop Image with Google Lens" and deprecate other text variants for the Lens Context Menu Shopping experiment. - remove finch param variants - remove requiresConfirmation from the intent generation. - will deprecate the requiresConfirmation from LensIntentParams and LensController API once we remove the internal dependencies. Change-Id: Ifb3166871fe5dd4ec54994c33f286a9905369ed7 Bug: b/182675578 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2921280 Commit-Queue: Yu Su <yusuyoutube@google.com> Reviewed-by: Ben Goldberger <benwgold@google.com> Reviewed-by: David Trainor <dtrainor@chromium.org> Reviewed-by: Sinan Sahin <sinansahin@google.com> Cr-Commit-Position: refs/heads/master@{#890891}
This commit is contained in:
chrome
android
java
src
org
chromium
chrome
browser
javatests
src
org
chromium
chrome
browser
browser
about_flags.cc
lens
java
src
org
chromium
chrome
preferences
android
java
src
org
chromium
chrome
browser
preferences
ui
android
strings
testing/variations
@ -38,8 +38,7 @@ class ChromeContextMenuItem {
|
||||
Item.DIRECT_SHARE_LINK, Item.READ_LATER, Item.LOAD_ORIGINAL_IMAGE, Item.SAVE_IMAGE,
|
||||
Item.OPEN_IMAGE, Item.OPEN_IMAGE_IN_NEW_TAB, Item.OPEN_IMAGE_IN_EPHEMERAL_TAB,
|
||||
Item.COPY_IMAGE, Item.SEARCH_BY_IMAGE, Item.SEARCH_WITH_GOOGLE_LENS,
|
||||
Item.SHOP_SIMILAR_PRODUCTS, Item.SHOP_IMAGE_WITH_GOOGLE_LENS,
|
||||
Item.SEARCH_SIMILAR_PRODUCTS, Item.SHARE_IMAGE, Item.DIRECT_SHARE_IMAGE, Item.CALL,
|
||||
Item.SHOP_IMAGE_WITH_GOOGLE_LENS, Item.SHARE_IMAGE, Item.DIRECT_SHARE_IMAGE, Item.CALL,
|
||||
Item.SEND_MESSAGE, Item.ADD_TO_CONTACTS, Item.COPY, Item.SAVE_VIDEO,
|
||||
Item.OPEN_IN_CHROME, Item.OPEN_IN_NEW_TAB_IN_GROUP, Item.SHARE_HIGHLIGHT,
|
||||
Item.REMOVE_HIGHLIGHT, Item.LEARN_MORE})
|
||||
@ -73,26 +72,24 @@ class ChromeContextMenuItem {
|
||||
int COPY_IMAGE = 20;
|
||||
int SEARCH_BY_IMAGE = 21;
|
||||
int SEARCH_WITH_GOOGLE_LENS = 22;
|
||||
int SHOP_SIMILAR_PRODUCTS = 23;
|
||||
int SHOP_IMAGE_WITH_GOOGLE_LENS = 24;
|
||||
int SEARCH_SIMILAR_PRODUCTS = 25;
|
||||
int SHARE_IMAGE = 26;
|
||||
int DIRECT_SHARE_IMAGE = 27;
|
||||
int SHOP_IMAGE_WITH_GOOGLE_LENS = 23;
|
||||
int SHARE_IMAGE = 24;
|
||||
int DIRECT_SHARE_IMAGE = 25;
|
||||
// Message Group
|
||||
int CALL = 28;
|
||||
int SEND_MESSAGE = 29;
|
||||
int ADD_TO_CONTACTS = 30;
|
||||
int COPY = 31;
|
||||
int CALL = 26;
|
||||
int SEND_MESSAGE = 27;
|
||||
int ADD_TO_CONTACTS = 28;
|
||||
int COPY = 29;
|
||||
// Video Group
|
||||
int SAVE_VIDEO = 32;
|
||||
int SAVE_VIDEO = 30;
|
||||
// Other
|
||||
int OPEN_IN_CHROME = 33;
|
||||
int OPEN_IN_CHROME = 31;
|
||||
// Shared Highlighting options
|
||||
int SHARE_HIGHLIGHT = 34;
|
||||
int REMOVE_HIGHLIGHT = 35;
|
||||
int LEARN_MORE = 36;
|
||||
int SHARE_HIGHLIGHT = 32;
|
||||
int REMOVE_HIGHLIGHT = 33;
|
||||
int LEARN_MORE = 34;
|
||||
// ALWAYS UPDATE!
|
||||
int NUM_ENTRIES = 37;
|
||||
int NUM_ENTRIES = 35;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,9 +119,7 @@ class ChromeContextMenuItem {
|
||||
R.id.contextmenu_copy_image, // Item.COPY_IMAGE
|
||||
R.id.contextmenu_search_by_image, // Item.SEARCH_BY_IMAGE
|
||||
R.id.contextmenu_search_with_google_lens, // Item.SEARCH_WITH_GOOGLE_LENS
|
||||
R.id.contextmenu_shop_similar_products, // Item.SHOP_SIMILAR_PRODUCTS
|
||||
R.id.contextmenu_shop_image_with_google_lens, // Item.SHOP_IMAGE_WITH_GOOGLE_LENS
|
||||
R.id.contextmenu_search_similar_products, // Item.SEARCH_SIMILAR_PRODUCTS
|
||||
R.id.contextmenu_share_image, // Item.SHARE_IMAGE
|
||||
R.id.contextmenu_direct_share_image, // Item.DIRECT_SHARE_IMAGE
|
||||
R.id.contextmenu_call, // Item.CALL
|
||||
@ -167,9 +162,7 @@ class ChromeContextMenuItem {
|
||||
LensUtils.useSearchImageWithGoogleLensItemName()
|
||||
? R.string.contextmenu_search_image_with_google_lens
|
||||
: R.string.contextmenu_search_with_google_lens, // Item.SEARCH_WITH_GOOGLE_LENS:
|
||||
R.string.contextmenu_shop_similar_products, // Item.SHOP_SIMILAR_PRODUCTS
|
||||
R.string.contextmenu_shop_image_with_google_lens, // Item.SHOP_IMAGE_WITH_GOOGLE_LENS
|
||||
R.string.contextmenu_search_similar_products, // Item.SEARCH_SIMILAR_PRODUCTS
|
||||
R.string.contextmenu_shop_image_with_google_lens, // Item.SHOP_IMAGE_WITH_GOOGLE_LENS:
|
||||
R.string.contextmenu_share_image, // Item.SHARE_IMAGE
|
||||
0, // Item.DIRECT_SHARE_IMAGE is not handled by this mapping.
|
||||
R.string.contextmenu_call, // Item.CALL:
|
||||
@ -242,18 +235,10 @@ class ChromeContextMenuItem {
|
||||
return addOrRemoveNewLabel(context, item,
|
||||
ChromePreferenceKeys.CONTEXT_MENU_SEARCH_WITH_GOOGLE_LENS_CLICKED,
|
||||
showInProductHelp);
|
||||
case Item.SHOP_SIMILAR_PRODUCTS:
|
||||
return addOrRemoveNewLabel(context, item,
|
||||
ChromePreferenceKeys.CONTEXT_MENU_SHOP_SIMILAR_PRODUCTS_CLICKED,
|
||||
showInProductHelp);
|
||||
case Item.SHOP_IMAGE_WITH_GOOGLE_LENS:
|
||||
return addOrRemoveNewLabel(context, item,
|
||||
ChromePreferenceKeys.CONTEXT_MENU_SHOP_IMAGE_WITH_GOOGLE_LENS_CLICKED,
|
||||
showInProductHelp);
|
||||
case Item.SEARCH_SIMILAR_PRODUCTS:
|
||||
return addOrRemoveNewLabel(context, item,
|
||||
ChromePreferenceKeys.CONTEXT_MENU_SEARCH_SIMILAR_PRODUCTS_CLICKED,
|
||||
showInProductHelp);
|
||||
default:
|
||||
return context.getString(getStringId(item));
|
||||
}
|
||||
|
@ -139,8 +139,7 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
|
||||
Action.OPEN_IN_CHROME_INCOGNITO_TAB, Action.OPEN_IN_BROWSER, Action.OPEN_IN_CHROME,
|
||||
Action.SHARE_LINK, Action.OPEN_IN_EPHEMERAL_TAB, Action.OPEN_IMAGE_IN_EPHEMERAL_TAB,
|
||||
Action.DIRECT_SHARE_LINK, Action.DIRECT_SHARE_IMAGE, Action.SEARCH_WITH_GOOGLE_LENS,
|
||||
Action.COPY_IMAGE, Action.SHOP_SIMILAR_PRODUCTS, Action.SHOP_IMAGE_WITH_GOOGLE_LENS,
|
||||
Action.SEARCH_SIMILAR_PRODUCTS, Action.READ_LATER,
|
||||
Action.COPY_IMAGE, Action.SHOP_IMAGE_WITH_GOOGLE_LENS, Action.READ_LATER,
|
||||
Action.SHOP_WITH_GOOGLE_LENS_CHIP, Action.TRANSLATE_WITH_GOOGLE_LENS_CHIP,
|
||||
Action.SHARE_HIGHLIGHT, Action.REMOVE_HIGHLIGHT, Action.LEARN_MORE,
|
||||
Action.OPEN_IN_NEW_TAB_IN_GROUP})
|
||||
@ -176,9 +175,9 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
|
||||
int DIRECT_SHARE_IMAGE = 27;
|
||||
int SEARCH_WITH_GOOGLE_LENS = 28;
|
||||
int COPY_IMAGE = 29;
|
||||
int SHOP_SIMILAR_PRODUCTS = 30;
|
||||
// int SHOP_SIMILAR_PRODUCTS = 30; Deprecated since 06/2021.
|
||||
int SHOP_IMAGE_WITH_GOOGLE_LENS = 31;
|
||||
int SEARCH_SIMILAR_PRODUCTS = 32;
|
||||
// int SEARCH_SIMILAR_PRODUCTS = 32; // Deprecated since 06/2021.
|
||||
int READ_LATER = 33;
|
||||
int SHOP_WITH_GOOGLE_LENS_CHIP = 34;
|
||||
int TRANSLATE_WITH_GOOGLE_LENS_CHIP = 35;
|
||||
@ -558,15 +557,7 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
|
||||
|
||||
// Show Lens Shopping Menu Item when the Lens Shopping feature is supported.
|
||||
if (showLensShoppingMenuItem) {
|
||||
if (LensUtils.useLensWithShopSimilarProducts()) {
|
||||
imageGroup.add(createListItem(Item.SHOP_SIMILAR_PRODUCTS, true));
|
||||
// If the image is classified as shoppy always use the Shop Image with Google
|
||||
// Lens item text.
|
||||
} else if (LensUtils.useLensWithShopImageWithGoogleLens()) {
|
||||
imageGroup.add(createListItem(Item.SHOP_IMAGE_WITH_GOOGLE_LENS, true));
|
||||
} else if (LensUtils.useLensWithSearchSimilarProducts()) {
|
||||
imageGroup.add(createListItem(Item.SEARCH_SIMILAR_PRODUCTS, true));
|
||||
}
|
||||
imageGroup.add(createListItem(Item.SHOP_IMAGE_WITH_GOOGLE_LENS, true));
|
||||
maybeRecordUkmLensShoppingShown();
|
||||
}
|
||||
|
||||
@ -774,35 +765,19 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
|
||||
ShareHelper.shareWithLastUsedComponent(shareParams);
|
||||
} else if (itemId == R.id.contextmenu_search_with_google_lens) {
|
||||
recordContextMenuSelection(ContextMenuUma.Action.SEARCH_WITH_GOOGLE_LENS);
|
||||
searchWithGoogleLens(
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM, /*requiresConfirmation=*/false);
|
||||
searchWithGoogleLens(LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
SharedPreferencesManager prefManager = SharedPreferencesManager.getInstance();
|
||||
prefManager.writeBoolean(
|
||||
ChromePreferenceKeys.CONTEXT_MENU_SEARCH_WITH_GOOGLE_LENS_CLICKED, true);
|
||||
} else if (itemId == R.id.contextmenu_search_by_image) {
|
||||
recordContextMenuSelection(ContextMenuUma.Action.SEARCH_BY_IMAGE);
|
||||
mNativeDelegate.searchForImage();
|
||||
} else if (itemId == R.id.contextmenu_shop_similar_products) {
|
||||
recordContextMenuSelection(ContextMenuUma.Action.SHOP_SIMILAR_PRODUCTS);
|
||||
searchWithGoogleLens(
|
||||
LensEntryPoint.CONTEXT_MENU_SHOP_MENU_ITEM, /*requiresConfirmation=*/true);
|
||||
SharedPreferencesManager prefManager = SharedPreferencesManager.getInstance();
|
||||
prefManager.writeBoolean(
|
||||
ChromePreferenceKeys.CONTEXT_MENU_SHOP_SIMILAR_PRODUCTS_CLICKED, true);
|
||||
} else if (itemId == R.id.contextmenu_shop_image_with_google_lens) {
|
||||
recordContextMenuSelection(ContextMenuUma.Action.SHOP_IMAGE_WITH_GOOGLE_LENS);
|
||||
searchWithGoogleLens(
|
||||
LensEntryPoint.CONTEXT_MENU_SHOP_MENU_ITEM, /*requiresConfirmation=*/false);
|
||||
searchWithGoogleLens(LensEntryPoint.CONTEXT_MENU_SHOP_MENU_ITEM);
|
||||
SharedPreferencesManager prefManager = SharedPreferencesManager.getInstance();
|
||||
prefManager.writeBoolean(
|
||||
ChromePreferenceKeys.CONTEXT_MENU_SHOP_IMAGE_WITH_GOOGLE_LENS_CLICKED, true);
|
||||
} else if (itemId == R.id.contextmenu_search_similar_products) {
|
||||
recordContextMenuSelection(ContextMenuUma.Action.SEARCH_SIMILAR_PRODUCTS);
|
||||
searchWithGoogleLens(
|
||||
LensEntryPoint.CONTEXT_MENU_SHOP_MENU_ITEM, /*requiresConfirmation=*/true);
|
||||
SharedPreferencesManager prefManager = SharedPreferencesManager.getInstance();
|
||||
prefManager.writeBoolean(
|
||||
ChromePreferenceKeys.CONTEXT_MENU_SEARCH_SIMILAR_PRODUCTS_CLICKED, true);
|
||||
} else if (itemId == R.id.contextmenu_share_image) {
|
||||
recordContextMenuSelection(ContextMenuUma.Action.SHARE_IMAGE);
|
||||
shareImage();
|
||||
@ -925,14 +900,12 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
|
||||
/**
|
||||
* Search for the image by intenting to the lens app with the image data attached.
|
||||
* @param lensEntryPoint The entry point that launches the Lens app.
|
||||
* @param requiresConfirmation Whether the request requires an account dialog.
|
||||
*/
|
||||
protected void searchWithGoogleLens(
|
||||
@LensEntryPoint int lensEntryPoint, boolean requiresConfirmation) {
|
||||
protected void searchWithGoogleLens(@LensEntryPoint int lensEntryPoint) {
|
||||
mNativeDelegate.retrieveImageForShare(ContextMenuImageFormat.PNG, (Uri imageUri) -> {
|
||||
ShareHelper.shareImageWithGoogleLens(getWindow(), imageUri, mItemDelegate.isIncognito(),
|
||||
mParams.getSrcUrl(), mParams.getTitleText(), mParams.getPageUrl(),
|
||||
lensEntryPoint, requiresConfirmation);
|
||||
lensEntryPoint);
|
||||
});
|
||||
}
|
||||
|
||||
@ -1109,21 +1082,12 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
|
||||
// minimum shopping supported version.
|
||||
if (LensUtils.isGoogleLensShoppingFeatureEnabled(isIncognito)
|
||||
&& !GSAState.getInstance(mContext).isAgsaVersionBelowMinimum(
|
||||
versionName, LensUtils.getMinimumAgsaVersionForLensShoppingSupport())) {
|
||||
if (LensUtils.isInShoppingAllowlist(pageUrl)) {
|
||||
// Hide Search With Google Lens menu item when experiment only with Lens Shopping
|
||||
// menu items.
|
||||
if (!LensUtils.showBothSearchAndShopImageWithLens()) {
|
||||
LensMetrics.recordLensSupportStatus(LENS_SUPPORT_STATUS_HISTOGRAM_NAME,
|
||||
LensMetrics.LensSupportStatus.LENS_SHOP_SUPPORTED);
|
||||
return Collections.unmodifiableMap(new HashMap<String, Boolean>() {
|
||||
{
|
||||
put(LENS_SEARCH_MENU_ITEM_KEY, false);
|
||||
put(LENS_SHOP_MENU_ITEM_KEY, true);
|
||||
put(SEARCH_BY_IMAGE_MENU_ITEM_KEY, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
versionName, LensUtils.getMinimumAgsaVersionForLensShoppingSupport())
|
||||
&& LensUtils.isInShoppingAllowlist(pageUrl)) {
|
||||
// Show both search and shop menu items when experiment with both Lens searching and
|
||||
// shopping.
|
||||
if (ChromeFeatureList.isEnabled(
|
||||
ChromeFeatureList.CONTEXT_MENU_SEARCH_AND_SHOP_WITH_GOOGLE_LENS)) {
|
||||
LensMetrics.recordLensSupportStatus(LENS_SUPPORT_STATUS_HISTOGRAM_NAME,
|
||||
LensMetrics.LensSupportStatus.LENS_SHOP_AND_SEARCH_SUPPORTED);
|
||||
return Collections.unmodifiableMap(new HashMap<String, Boolean>() {
|
||||
@ -1134,6 +1098,18 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Hide Search With Google Lens menu item when experiment only with Lens Shopping
|
||||
// menu items.
|
||||
LensMetrics.recordLensSupportStatus(LENS_SUPPORT_STATUS_HISTOGRAM_NAME,
|
||||
LensMetrics.LensSupportStatus.LENS_SHOP_SUPPORTED);
|
||||
return Collections.unmodifiableMap(new HashMap<String, Boolean>() {
|
||||
{
|
||||
put(LENS_SEARCH_MENU_ITEM_KEY, false);
|
||||
put(LENS_SHOP_MENU_ITEM_KEY, true);
|
||||
put(SEARCH_BY_IMAGE_MENU_ITEM_KEY, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
LensMetrics.recordLensSupportStatus(LENS_SUPPORT_STATUS_HISTOGRAM_NAME,
|
||||
|
@ -43,7 +43,6 @@ public class LensUtils {
|
||||
private static final String PAGE_URI_KEY = "PageUrl";
|
||||
private static final String VARIATION_ID_URI_KEY = "Gid";
|
||||
private static final String LENS_INTENT_TYPE_KEY = "lens_intent_type";
|
||||
private static final String REQUIRE_ACCOUNT_DIALOG_KEY = "requiresConfirmation";
|
||||
|
||||
private static final String MIN_AGSA_VERSION_FEATURE_PARAM_NAME = "minAgsaVersionName";
|
||||
private static final String MIN_AGSA_VERSION_SHOPPING_FEATURE_PARAM_NAME =
|
||||
@ -76,7 +75,6 @@ public class LensUtils {
|
||||
private static final String MIN_AGSA_VERSION_NAME_FOR_LENS_DIRECT_INTENT_SDK = "11.39.7";
|
||||
private static final String MIN_AGSA_VERSION_NAME_FOR_LENS_INTENT_API = "12.10";
|
||||
private static final int LENS_INTENT_TYPE_LENS_CHROME_SHOPPING = 18;
|
||||
private static final String LENS_SHOPPING_FEATURE_FLAG_VARIANT_NAME = "lensShopVariation";
|
||||
private static final String LENS_DEFAULT_SHOPPING_URL_PATTERNS =
|
||||
"^https://www.google.com/shopping/.*|^https://www.google.com/.*tbm=shop.*";
|
||||
|
||||
@ -321,16 +319,11 @@ public class LensUtils {
|
||||
* image.
|
||||
* @param pageUrl The url of the top level frame of the page.
|
||||
* @param lensEntryPoint The entry point that launches the Lens app.
|
||||
* @param requiresConfirmation A boolean to indicate whether the request is from one of the
|
||||
* entry points that are not explicitly specified with
|
||||
* "Google Lens". We will show a confirmation dialog for this
|
||||
* request if true.
|
||||
* @return The intent to Google Lens.
|
||||
*/
|
||||
public static Intent getShareWithGoogleLensIntent(final Context context, final Uri imageUri,
|
||||
final boolean isIncognito, final long currentTimeNanos, final GURL srcUrl,
|
||||
final String titleOrAltText, final GURL pageUrl, @LensEntryPoint int lensEntryPoint,
|
||||
boolean requiresConfirmation) {
|
||||
final String titleOrAltText, final GURL pageUrl, @LensEntryPoint int lensEntryPoint) {
|
||||
int lensIntentType = lensEntryPoint == LensEntryPoint.CONTEXT_MENU_SHOP_MENU_ITEM
|
||||
? LensUtils.getLensShoppingIntentType()
|
||||
: 0;
|
||||
@ -359,11 +352,6 @@ public class LensUtils {
|
||||
LENS_INTENT_TYPE_KEY, Integer.toString(lensIntentType));
|
||||
}
|
||||
|
||||
if (requiresConfirmation) {
|
||||
lensUriBuilder.appendQueryParameter(
|
||||
REQUIRE_ACCOUNT_DIALOG_KEY, Boolean.toString(requiresConfirmation));
|
||||
}
|
||||
|
||||
if (!isIncognito) {
|
||||
if (ChromeFeatureList.getFieldTrialParamByFeatureAsBoolean(
|
||||
ChromeFeatureList.CONTEXT_MENU_SEARCH_WITH_GOOGLE_LENS,
|
||||
@ -442,16 +430,11 @@ public class LensUtils {
|
||||
* image.
|
||||
* @param pageUrl The url of the top level frame of the page.
|
||||
* @param lensEntryPoint The entry point that launches the Lens app.
|
||||
* @param requiresConfirmation A boolean to indicate whether the request is from one of the
|
||||
* entry points that are not explicitly specified with
|
||||
* "Google Lens". We will show a confirmation dialog for this
|
||||
* request if true.
|
||||
* @return The intent parameters to intent to Google Lens.
|
||||
*/
|
||||
public static LensIntentParams buildLensIntentParams(final Uri imageUri,
|
||||
final boolean isIncognito, final String srcUrl, final String titleOrAltText,
|
||||
final String pageUrl, @LensEntryPoint int lensEntryPoint,
|
||||
boolean requiresConfirmation) {
|
||||
final String pageUrl, @LensEntryPoint int lensEntryPoint) {
|
||||
// TODO(yusuyoutube): deprecate lensIntentType once we have the mapping for LensEntryPoint
|
||||
// to intent type in the Lens closed source repository.
|
||||
int lensIntentType = lensEntryPoint == LensEntryPoint.CONTEXT_MENU_SHOP_MENU_ITEM
|
||||
@ -461,7 +444,6 @@ public class LensUtils {
|
||||
LensIntentParams.Builder intentParamsBuilder =
|
||||
new LensIntentParams.Builder(lensEntryPoint, isIncognito);
|
||||
return intentParamsBuilder.withImageUri(imageUri)
|
||||
.withRequiresConfirmation(requiresConfirmation)
|
||||
.withIntentType(lensIntentType)
|
||||
.withImageTitleOrAltText(titleOrAltText)
|
||||
.withSrcUrl(srcUrl)
|
||||
@ -478,14 +460,24 @@ public class LensUtils {
|
||||
}
|
||||
|
||||
public static boolean isGoogleLensShoppingFeatureEnabled(boolean isIncognito) {
|
||||
return (useLensWithShopSimilarProducts() || useLensWithShopImageWithGoogleLens()
|
||||
|| useLensWithSearchSimilarProducts())
|
||||
&& !(isIncognito
|
||||
&& ChromeFeatureList.getFieldTrialParamByFeatureAsBoolean(
|
||||
ChromeFeatureList.CONTEXT_MENU_SHOP_WITH_GOOGLE_LENS,
|
||||
DISABLE_ON_INCOGNITO_PARAM_NAME, true))
|
||||
// Dont enable both the chip and the shopping menu item.
|
||||
&& !ChromeFeatureList.isEnabled(ChromeFeatureList.CONTEXT_MENU_GOOGLE_LENS_CHIP);
|
||||
if (!ChromeFeatureList.isEnabled(ChromeFeatureList.CONTEXT_MENU_SHOP_WITH_GOOGLE_LENS)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Dont enable both the chip and the shopping menu item.
|
||||
if (ChromeFeatureList.isEnabled(ChromeFeatureList.CONTEXT_MENU_GOOGLE_LENS_CHIP)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Disable on Incognito.
|
||||
if (isIncognito
|
||||
&& ChromeFeatureList.getFieldTrialParamByFeatureAsBoolean(
|
||||
ChromeFeatureList.CONTEXT_MENU_SHOP_WITH_GOOGLE_LENS,
|
||||
DISABLE_ON_INCOGNITO_PARAM_NAME, true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -543,28 +535,6 @@ public class LensUtils {
|
||||
getMinimumAgsaVersionForLensIntentApiSupport());
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to display the lens menu item shop similar products. only one of the
|
||||
* 3 params should be set to true: useLensWithShopSimilarProducts,
|
||||
* useLensWithShopImageWithGoogleLens and useLensWithShopImageWithGoogleLens.
|
||||
*/
|
||||
public static boolean useLensWithShopSimilarProducts() {
|
||||
String variation = ChromeFeatureList.getFieldTrialParamByFeature(
|
||||
ChromeFeatureList.CONTEXT_MENU_SHOP_WITH_GOOGLE_LENS,
|
||||
LENS_SHOPPING_FEATURE_FLAG_VARIANT_NAME);
|
||||
return variation.equals("ShopSimilarProducts");
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to display the lens menu item shop image with google lens.
|
||||
*/
|
||||
public static boolean useLensWithShopImageWithGoogleLens() {
|
||||
String variation = ChromeFeatureList.getFieldTrialParamByFeature(
|
||||
ChromeFeatureList.CONTEXT_MENU_SHOP_WITH_GOOGLE_LENS,
|
||||
LENS_SHOPPING_FEATURE_FLAG_VARIANT_NAME);
|
||||
return variation.equals("ShopImageWithGoogleLens");
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to display the lens shop image with google lens chip.
|
||||
*/
|
||||
@ -593,21 +563,6 @@ public class LensUtils {
|
||||
ORDER_SHARE_IMAGE_BEFORE_LENS_PARAM_NAME, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to display the lens menu item search similar products.
|
||||
*/
|
||||
public static boolean useLensWithSearchSimilarProducts() {
|
||||
String variation = ChromeFeatureList.getFieldTrialParamByFeature(
|
||||
ChromeFeatureList.CONTEXT_MENU_SHOP_WITH_GOOGLE_LENS,
|
||||
LENS_SHOPPING_FEATURE_FLAG_VARIANT_NAME);
|
||||
return variation.equals("SearchSimilarProducts");
|
||||
}
|
||||
|
||||
public static boolean showBothSearchAndShopImageWithLens() {
|
||||
return ChromeFeatureList.isEnabled(
|
||||
ChromeFeatureList.CONTEXT_MENU_SEARCH_AND_SHOP_WITH_GOOGLE_LENS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of Allowlisted Entries as String. Format is a comma separated
|
||||
* list of Entry names (as strings).
|
||||
|
@ -138,18 +138,18 @@ public class ShareHelper extends org.chromium.components.browser_ui.share.ShareH
|
||||
*/
|
||||
public static void shareImageWithGoogleLens(final WindowAndroid window, Uri imageUri,
|
||||
boolean isIncognito, GURL srcUrl, String titleOrAltText, GURL pageUrl,
|
||||
@LensEntryPoint int lensEntryPoint, boolean requiresConfirmation) {
|
||||
@LensEntryPoint int lensEntryPoint) {
|
||||
if (LensUtils.useDirectIntentSdkIntegration(ContextUtils.getApplicationContext())
|
||||
|| LensUtils.useLensIntentApi()) {
|
||||
LensIntentParams intentParams = LensUtils.buildLensIntentParams(imageUri, isIncognito,
|
||||
srcUrl.getValidSpecOrEmpty(), titleOrAltText, pageUrl.getValidSpecOrEmpty(),
|
||||
lensEntryPoint, requiresConfirmation);
|
||||
lensEntryPoint);
|
||||
LensController.getInstance().startLens(window, intentParams);
|
||||
} else {
|
||||
Intent shareIntent =
|
||||
LensUtils.getShareWithGoogleLensIntent(ContextUtils.getApplicationContext(),
|
||||
imageUri, isIncognito, SystemClock.elapsedRealtimeNanos(), srcUrl,
|
||||
titleOrAltText, pageUrl, lensEntryPoint, requiresConfirmation);
|
||||
titleOrAltText, pageUrl, lensEntryPoint);
|
||||
try {
|
||||
// Pass an empty callback to ensure the triggered activity can identify the source
|
||||
// of the intent (startActivityForResult allows app identification).
|
||||
|
@ -208,41 +208,8 @@ public class ContextMenuTest implements DownloadTestRule.CustomMainActivityStart
|
||||
@Test
|
||||
@MediumTest
|
||||
@Feature({"Browser"})
|
||||
@Features.EnableFeatures({ChromeFeatureList.CONTEXT_MENU_ENABLE_LENS_SHOPPING_ALLOWLIST})
|
||||
@CommandLineFlags.Add({"enable-features=" + ChromeFeatureList.CONTEXT_MENU_SHOP_WITH_GOOGLE_LENS
|
||||
+ "<FakeStudyName",
|
||||
"force-fieldtrials=FakeStudyName/Enabled",
|
||||
"force-fieldtrial-params=FakeStudyName.Enabled:lensShopVariation/ShopSimilarProducts"})
|
||||
public void
|
||||
testShopSimilarProductsFiresIntent() throws Throwable {
|
||||
LensUtils.setFakePassableLensEnvironmentForTesting(true);
|
||||
LensUtils.setFakeImageUrlInShoppingAllowlistForTesting(true);
|
||||
Tab tab = mDownloadTestRule.getActivity().getActivityTab();
|
||||
ShareHelper.setIgnoreActivityNotFoundExceptionForTesting(true);
|
||||
hardcodeTestImageForSharing(TEST_JPG_IMAGE_FILE_EXTENSION);
|
||||
|
||||
ContextMenuUtils.selectContextMenuItemWithExpectedIntent(
|
||||
InstrumentationRegistry.getInstrumentation(), mDownloadTestRule.getActivity(), tab,
|
||||
"testImage", R.id.contextmenu_shop_similar_products,
|
||||
"com.google.android.googlequicksearchbox");
|
||||
Assert.assertEquals(1,
|
||||
RecordHistogram.getHistogramTotalCountForTesting(
|
||||
"ContextMenu.SelectedOptionAndroid.Image"));
|
||||
Assert.assertEquals(1,
|
||||
RecordHistogram.getHistogramTotalCountForTesting(
|
||||
"ContextMenu.SelectedOptionAndroid.Image.ShoppingDomain"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@MediumTest
|
||||
@Feature({"Browser"})
|
||||
@CommandLineFlags.Add({"enable-features=" + ChromeFeatureList.CONTEXT_MENU_SHOP_WITH_GOOGLE_LENS
|
||||
+ "<FakeStudyName",
|
||||
"force-fieldtrials=FakeStudyName/Enabled",
|
||||
"force-fieldtrial-params=FakeStudyName.Enabled:"
|
||||
+ "lensShopVariation/ShopImageWithGoogleLens"})
|
||||
public void
|
||||
testShopImageWithGoogleLensFiresIntent() throws Throwable {
|
||||
@Features.EnableFeatures({ChromeFeatureList.CONTEXT_MENU_SHOP_WITH_GOOGLE_LENS})
|
||||
public void testShopImageWithGoogleLensFiresIntent() throws Throwable {
|
||||
LensUtils.setFakePassableLensEnvironmentForTesting(true);
|
||||
LensUtils.setFakeImageUrlInShoppingAllowlistForTesting(true);
|
||||
Tab tab = mDownloadTestRule.getActivity().getActivityTab();
|
||||
@ -269,36 +236,7 @@ public class ContextMenuTest implements DownloadTestRule.CustomMainActivityStart
|
||||
+ "<FakeStudyName",
|
||||
"force-fieldtrials=FakeStudyName/Enabled",
|
||||
"force-fieldtrial-params=FakeStudyName.Enabled:"
|
||||
+ "lensShopVariation/SearchSimilarProducts"})
|
||||
public void
|
||||
testSearchSimilarProductsFiresIntent() throws Throwable {
|
||||
LensUtils.setFakePassableLensEnvironmentForTesting(true);
|
||||
LensUtils.setFakeImageUrlInShoppingAllowlistForTesting(true);
|
||||
Tab tab = mDownloadTestRule.getActivity().getActivityTab();
|
||||
ShareHelper.setIgnoreActivityNotFoundExceptionForTesting(true);
|
||||
hardcodeTestImageForSharing(TEST_JPG_IMAGE_FILE_EXTENSION);
|
||||
|
||||
ContextMenuUtils.selectContextMenuItemWithExpectedIntent(
|
||||
InstrumentationRegistry.getInstrumentation(), mDownloadTestRule.getActivity(), tab,
|
||||
"testImage", R.id.contextmenu_search_similar_products,
|
||||
"com.google.android.googlequicksearchbox");
|
||||
Assert.assertEquals(1,
|
||||
RecordHistogram.getHistogramTotalCountForTesting(
|
||||
"ContextMenu.SelectedOptionAndroid.Image"));
|
||||
Assert.assertEquals(1,
|
||||
RecordHistogram.getHistogramTotalCountForTesting(
|
||||
"ContextMenu.SelectedOptionAndroid.Image.ShoppingDomain"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@MediumTest
|
||||
@Feature({"Browser"})
|
||||
@Features.EnableFeatures({ChromeFeatureList.CONTEXT_MENU_ENABLE_LENS_SHOPPING_ALLOWLIST})
|
||||
@CommandLineFlags.Add({"enable-features=" + ChromeFeatureList.CONTEXT_MENU_SHOP_WITH_GOOGLE_LENS
|
||||
+ "<FakeStudyName",
|
||||
"force-fieldtrials=FakeStudyName/Enabled",
|
||||
"force-fieldtrial-params=FakeStudyName.Enabled:"
|
||||
+ "lensShopVariation/SearchSimilarProducts/minAgsaVersionNameForShopping/11.21"})
|
||||
+ "minAgsaVersionNameForShopping/11.21"})
|
||||
public void
|
||||
testSearchSimilarProductsBelowShoppingMinimumAgsaVersion() throws Throwable {
|
||||
LensUtils.setFakePassableLensEnvironmentForTesting(true);
|
||||
@ -793,37 +731,9 @@ public class ContextMenuTest implements DownloadTestRule.CustomMainActivityStart
|
||||
@Test
|
||||
@SmallTest
|
||||
@Feature({"Browser", "ContextMenu"})
|
||||
@Features.EnableFeatures({ChromeFeatureList.CONTEXT_MENU_ENABLE_LENS_SHOPPING_ALLOWLIST})
|
||||
@CommandLineFlags.Add({"enable-features=" + ChromeFeatureList.CONTEXT_MENU_SHOP_WITH_GOOGLE_LENS
|
||||
+ "<FakeStudyName",
|
||||
"force-fieldtrials=FakeStudyName/Enabled",
|
||||
"force-fieldtrial-params=FakeStudyName.Enabled:"
|
||||
+ "lensShopVariation/ShopSimilarProducts"})
|
||||
public void
|
||||
testContextMenuLensEnabledShopSimilarProducts() throws TimeoutException {
|
||||
LensUtils.setFakePassableLensEnvironmentForTesting(true);
|
||||
LensUtils.setFakeImageUrlInShoppingAllowlistForTesting(true);
|
||||
Tab tab = mDownloadTestRule.getActivity().getActivityTab();
|
||||
ContextMenuCoordinator menu = ContextMenuUtils.openContextMenu(tab, "testImage");
|
||||
|
||||
Integer[] expectedItems = {R.id.contextmenu_save_image,
|
||||
R.id.contextmenu_open_image_in_new_tab, R.id.contextmenu_share_image,
|
||||
R.id.contextmenu_shop_similar_products, R.id.contextmenu_copy_image};
|
||||
Integer[] featureItems = {R.id.contextmenu_open_image_in_ephemeral_tab};
|
||||
expectedItems =
|
||||
addItemsIf(EphemeralTabCoordinator.isSupported(), expectedItems, featureItems);
|
||||
assertMenuItemsAreEqual(menu, expectedItems);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
@Feature({"Browser", "ContextMenu"})
|
||||
@Features.EnableFeatures({ChromeFeatureList.CONTEXT_MENU_ENABLE_LENS_SHOPPING_ALLOWLIST})
|
||||
@CommandLineFlags.Add({"enable-features=" + ChromeFeatureList.CONTEXT_MENU_SHOP_WITH_GOOGLE_LENS
|
||||
+ "<FakeStudyName",
|
||||
"force-fieldtrials=FakeStudyName/Enabled",
|
||||
"force-fieldtrial-params=FakeStudyName.Enabled:"
|
||||
+ "lensShopVariation/ShopImageWithGoogleLens"})
|
||||
@Features.DisableFeatures({ChromeFeatureList.CONTEXT_MENU_GOOGLE_LENS_CHIP})
|
||||
@Features.EnableFeatures({ChromeFeatureList.CONTEXT_MENU_ENABLE_LENS_SHOPPING_ALLOWLIST,
|
||||
ChromeFeatureList.CONTEXT_MENU_SHOP_WITH_GOOGLE_LENS})
|
||||
public void
|
||||
testContextMenuLensEnabledShopImageWithGoogleLens() throws TimeoutException {
|
||||
LensUtils.setFakePassableLensEnvironmentForTesting(true);
|
||||
@ -840,31 +750,6 @@ public class ContextMenuTest implements DownloadTestRule.CustomMainActivityStart
|
||||
assertMenuItemsAreEqual(menu, expectedItems);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
@Feature({"Browser", "ContextMenu"})
|
||||
@Features.EnableFeatures({ChromeFeatureList.CONTEXT_MENU_ENABLE_LENS_SHOPPING_ALLOWLIST})
|
||||
@CommandLineFlags.Add({"enable-features=" + ChromeFeatureList.CONTEXT_MENU_SHOP_WITH_GOOGLE_LENS
|
||||
+ "<FakeStudyName",
|
||||
"force-fieldtrials=FakeStudyName/Enabled",
|
||||
"force-fieldtrial-params=FakeStudyName.Enabled:"
|
||||
+ "lensShopVariation/SearchSimilarProducts"})
|
||||
public void
|
||||
testContextMenuLensEnabledSeachSimilarProducts() throws TimeoutException {
|
||||
LensUtils.setFakePassableLensEnvironmentForTesting(true);
|
||||
LensUtils.setFakeImageUrlInShoppingAllowlistForTesting(true);
|
||||
Tab tab = mDownloadTestRule.getActivity().getActivityTab();
|
||||
ContextMenuCoordinator menu = ContextMenuUtils.openContextMenu(tab, "testImage");
|
||||
|
||||
Integer[] expectedItems = {R.id.contextmenu_save_image,
|
||||
R.id.contextmenu_open_image_in_new_tab, R.id.contextmenu_share_image,
|
||||
R.id.contextmenu_search_similar_products, R.id.contextmenu_copy_image};
|
||||
Integer[] featureItems = {R.id.contextmenu_open_image_in_ephemeral_tab};
|
||||
expectedItems =
|
||||
addItemsIf(EphemeralTabCoordinator.isSupported(), expectedItems, featureItems);
|
||||
assertMenuItemsAreEqual(menu, expectedItems);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
@Feature({"Browser", "ContextMenu"})
|
||||
@ -889,32 +774,6 @@ public class ContextMenuTest implements DownloadTestRule.CustomMainActivityStart
|
||||
assertMenuItemsAreEqual(menu, expectedItems);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
@Feature({"Browser", "ContextMenu"})
|
||||
@Features.EnableFeatures({ChromeFeatureList.CONTEXT_MENU_ENABLE_LENS_SHOPPING_ALLOWLIST,
|
||||
ChromeFeatureList.CONTEXT_MENU_SEARCH_AND_SHOP_WITH_GOOGLE_LENS})
|
||||
@CommandLineFlags.Add({"enable-features=" + ChromeFeatureList.CONTEXT_MENU_SHOP_WITH_GOOGLE_LENS
|
||||
+ "<FakeStudyName",
|
||||
"force-fieldtrials=FakeStudyName/Enabled",
|
||||
"force-fieldtrial-params=FakeStudyName.Enabled:lensShopVariation/ShopSimilarProducts"})
|
||||
public void
|
||||
testContextMenuLensEnabledSearchAndShopSimilarProducts() throws TimeoutException {
|
||||
LensUtils.setFakePassableLensEnvironmentForTesting(true);
|
||||
LensUtils.setFakeImageUrlInShoppingAllowlistForTesting(true);
|
||||
Tab tab = mDownloadTestRule.getActivity().getActivityTab();
|
||||
ContextMenuCoordinator menu = ContextMenuUtils.openContextMenu(tab, "testImage");
|
||||
|
||||
Integer[] expectedItems = {R.id.contextmenu_save_image,
|
||||
R.id.contextmenu_open_image_in_new_tab, R.id.contextmenu_search_with_google_lens,
|
||||
R.id.contextmenu_share_image, R.id.contextmenu_shop_similar_products,
|
||||
R.id.contextmenu_copy_image};
|
||||
Integer[] featureItems = {R.id.contextmenu_open_image_in_ephemeral_tab};
|
||||
expectedItems =
|
||||
addItemsIf(EphemeralTabCoordinator.isSupported(), expectedItems, featureItems);
|
||||
assertMenuItemsAreEqual(menu, expectedItems);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
@Feature({"Browser", "ContextMenu"})
|
||||
|
@ -33,6 +33,7 @@ import org.chromium.chrome.browser.lens.LensEntryPoint;
|
||||
import org.chromium.chrome.browser.lens.LensIntentParams;
|
||||
import org.chromium.chrome.test.ChromeBrowserTestRule;
|
||||
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
|
||||
import org.chromium.chrome.test.util.browser.Features.DisableFeatures;
|
||||
import org.chromium.chrome.test.util.browser.Features.EnableFeatures;
|
||||
import org.chromium.content_public.browser.test.util.TestThreadUtils;
|
||||
import org.chromium.url.GURL;
|
||||
@ -76,8 +77,7 @@ public class LensUtilsTest {
|
||||
|
||||
Intent intentNoUri = getShareWithGoogleLensIntentOnUiThread(Uri.EMPTY,
|
||||
/* isIncognito= */ false, 1234L, /* srcUrl */ "", /* titleOrAltText */ "",
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM,
|
||||
/* requiresConfirmation */ false);
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
Assert.assertEquals("Intent without image has incorrect URI", "googleapp://lens",
|
||||
intentNoUri.getData().toString());
|
||||
Assert.assertEquals("Intent without image has incorrect action", Intent.ACTION_VIEW,
|
||||
@ -86,8 +86,7 @@ public class LensUtilsTest {
|
||||
final String contentUrl = "content://image-url";
|
||||
Intent intentWithContentUri = getShareWithGoogleLensIntentOnUiThread(Uri.parse(contentUrl),
|
||||
/* isIncognito= */ false, 1234L, /* srcUrl */ "", /* titleOrAltText */ "",
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM,
|
||||
/* requiresConfirmation */ false);
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
Assert.assertEquals("Intent with image has incorrect URI",
|
||||
"googleapp://lens?LensBitmapUriKey=content%3A%2F%2Fimage-url&AccountNameUriKey="
|
||||
+ "test%40gmail.com&IncognitoUriKey=false&ActivityLaunchTimestampNanos=1234",
|
||||
@ -159,14 +158,11 @@ public class LensUtilsTest {
|
||||
* Test {@link LensUtils#isGoogleLensFeatureEnabled()} method when disable incognito param is
|
||||
* unset and user is incognito.
|
||||
*/
|
||||
@CommandLineFlags.Add({"enable-features=" + ChromeFeatureList.CONTEXT_MENU_SHOP_WITH_GOOGLE_LENS
|
||||
+ "<FakeStudyName",
|
||||
"force-fieldtrials=FakeStudyName/Enabled",
|
||||
"force-fieldtrial-params=FakeStudyName.Enabled:lensShopVariation/ShopSimilarProducts"})
|
||||
@DisableFeatures({ChromeFeatureList.CONTEXT_MENU_GOOGLE_LENS_CHIP})
|
||||
@EnableFeatures({ChromeFeatureList.CONTEXT_MENU_SHOP_WITH_GOOGLE_LENS})
|
||||
@Test
|
||||
@SmallTest
|
||||
public void
|
||||
isGoogleLensShoppingFeatureEnabled_incognitoParamUnsetIncognitoUser() {
|
||||
public void isGoogleLensShoppingFeatureEnabled_incognitoParamUnsetIncognitoUser() {
|
||||
Assert.assertFalse("Feature incorrectly enabled when incognito param is not set",
|
||||
isGoogleLensShoppingFeatureEnabledOnUiThread(true));
|
||||
}
|
||||
@ -175,11 +171,11 @@ public class LensUtilsTest {
|
||||
* Test {@link LensUtils#isGoogleLensShoppingFeatureEnabled()} method when incognito users are
|
||||
* enabled and user is incognito.
|
||||
*/
|
||||
@DisableFeatures({ChromeFeatureList.CONTEXT_MENU_GOOGLE_LENS_CHIP})
|
||||
@CommandLineFlags.Add({"enable-features=" + ChromeFeatureList.CONTEXT_MENU_SHOP_WITH_GOOGLE_LENS
|
||||
+ "<FakeStudyName",
|
||||
"force-fieldtrials=FakeStudyName/Enabled",
|
||||
"force-fieldtrial-params=FakeStudyName.Enabled:disableOnIncognito/false/"
|
||||
+ "lensShopVariation/ShopSimilarProducts"})
|
||||
"force-fieldtrial-params=FakeStudyName.Enabled:disableOnIncognito/false"})
|
||||
@Test
|
||||
@SmallTest
|
||||
public void
|
||||
@ -192,11 +188,11 @@ public class LensUtilsTest {
|
||||
* Test {@link LensUtils#isGoogleLensFeatureEnabled()} method when incognito users are disabled
|
||||
* and user is incognito.
|
||||
*/
|
||||
@DisableFeatures({ChromeFeatureList.CONTEXT_MENU_GOOGLE_LENS_CHIP})
|
||||
@CommandLineFlags.Add({"enable-features=" + ChromeFeatureList.CONTEXT_MENU_SHOP_WITH_GOOGLE_LENS
|
||||
+ "<FakeStudyName",
|
||||
"force-fieldtrials=FakeStudyName/Enabled",
|
||||
"force-fieldtrial-params=FakeStudyName.Enabled:disableOnIncognito/true/"
|
||||
+ "lensShopVariation/ShopSimilarProducts"})
|
||||
"force-fieldtrial-params=FakeStudyName.Enabled:disableOnIncognito/true"})
|
||||
@Test
|
||||
@SmallTest
|
||||
public void
|
||||
@ -209,11 +205,11 @@ public class LensUtilsTest {
|
||||
* Test {@link LensUtils#isGoogleLensFeatureEnabled()} method when incognito users are disabled
|
||||
* and user is not incognito.
|
||||
*/
|
||||
@DisableFeatures({ChromeFeatureList.CONTEXT_MENU_GOOGLE_LENS_CHIP})
|
||||
@CommandLineFlags.Add({"enable-features=" + ChromeFeatureList.CONTEXT_MENU_SHOP_WITH_GOOGLE_LENS
|
||||
+ "<FakeStudyName",
|
||||
"force-fieldtrials=FakeStudyName/Enabled",
|
||||
"force-fieldtrial-params=FakeStudyName.Enabled:disableOnIncognito/true/"
|
||||
+ "lensShopVariation/ShopSimilarProducts"})
|
||||
"force-fieldtrial-params=FakeStudyName.Enabled:disableOnIncognito/true"})
|
||||
@Test
|
||||
@SmallTest
|
||||
public void
|
||||
@ -229,8 +225,7 @@ public class LensUtilsTest {
|
||||
+ "<FakeStudyName," + ChromeFeatureList.CONTEXT_MENU_GOOGLE_LENS_CHIP
|
||||
+ "<FakeStudyName",
|
||||
"force-fieldtrials=FakeStudyName/Enabled",
|
||||
"force-fieldtrial-params=FakeStudyName.Enabled:disableOnIncognito/true/"
|
||||
+ "lensShopVariation/ShopSimilarProducts"})
|
||||
"force-fieldtrial-params=FakeStudyName.Enabled:disableOnIncognito/true"})
|
||||
@Test
|
||||
@SmallTest
|
||||
public void
|
||||
@ -255,8 +250,7 @@ public class LensUtilsTest {
|
||||
LensUtils.setFakeInstalledAgsaVersion(TEST_MIN_AGSA_VERSION);
|
||||
Intent intentNoUri = getShareWithGoogleLensIntentOnUiThread(Uri.EMPTY,
|
||||
/* isIncognito= */ false, 1234L, /* srcUrl */ "", /* titleOrAltText */ "",
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM,
|
||||
/* requiresConfirmation */ false);
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
Assert.assertEquals("Intent without image has incorrect URI", "google://lens",
|
||||
intentNoUri.getData().toString());
|
||||
Assert.assertEquals("Intent without image has incorrect action", Intent.ACTION_VIEW,
|
||||
@ -265,8 +259,7 @@ public class LensUtilsTest {
|
||||
final String contentUrl = "content://image-url";
|
||||
Intent intentWithContentUri = getShareWithGoogleLensIntentOnUiThread(Uri.parse(contentUrl),
|
||||
/* isIncognito= */ false, 1234L, /* srcUrl */ "", /* titleOrAltText */ "",
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM,
|
||||
/* requiresConfirmation */ false);
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
Assert.assertEquals("Intent with image has incorrect URI",
|
||||
"google://lens?LensBitmapUriKey=content%3A%2F%2Fimage-url"
|
||||
+ "&AccountNameUriKey=test%40gmail.com&IncognitoUriKey=false"
|
||||
@ -292,8 +285,7 @@ public class LensUtilsTest {
|
||||
LensUtils.setFakeInstalledAgsaVersion("");
|
||||
Intent intentNoUri = getShareWithGoogleLensIntentOnUiThread(Uri.EMPTY,
|
||||
/* isIncognito= */ false, 1234L, /* srcUrl */ "", /* titleOrAltText */ "",
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM,
|
||||
/* requiresConfirmation */ false);
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
Assert.assertEquals("Intent without image has incorrect URI", "googleapp://lens",
|
||||
intentNoUri.getData().toString());
|
||||
Assert.assertEquals("Intent without image has incorrect action", Intent.ACTION_VIEW,
|
||||
@ -302,8 +294,7 @@ public class LensUtilsTest {
|
||||
final String contentUrl = "content://image-url";
|
||||
Intent intentWithContentUri = getShareWithGoogleLensIntentOnUiThread(Uri.parse(contentUrl),
|
||||
/* isIncognito= */ false, 1234L, /* srcUrl */ "", /* titleOrAltText */ "",
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM,
|
||||
/* requiresConfirmation */ false);
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
Assert.assertEquals("Intent with image has incorrect URI",
|
||||
"googleapp://lens?LensBitmapUriKey=content%3A%2F%2Fimage-url"
|
||||
+ "&AccountNameUriKey=test%40gmail.com&IncognitoUriKey=false"
|
||||
@ -330,8 +321,7 @@ public class LensUtilsTest {
|
||||
LensUtils.setFakeInstalledAgsaVersion(TEST_MIN_AGSA_VERSION_BELOW_DIRECT_INTENT_MIN);
|
||||
Intent intentNoUri = getShareWithGoogleLensIntentOnUiThread(Uri.EMPTY,
|
||||
/* isIncognito= */ false, 1234L, /* srcUrl */ "", /* titleOrAltText */ "",
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM,
|
||||
/* requiresConfirmation */ false);
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
Assert.assertEquals("Intent without image has incorrect URI", "googleapp://lens",
|
||||
intentNoUri.getData().toString());
|
||||
Assert.assertEquals("Intent without image has incorrect action", Intent.ACTION_VIEW,
|
||||
@ -340,8 +330,7 @@ public class LensUtilsTest {
|
||||
final String contentUrl = "content://image-url";
|
||||
Intent intentWithContentUri = getShareWithGoogleLensIntentOnUiThread(Uri.parse(contentUrl),
|
||||
/* isIncognito= */ false, 1234L, /* srcUrl */ "", /* titleOrAltText */ "",
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM,
|
||||
/* requiresConfirmation */ false);
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
Assert.assertEquals("Intent with image has incorrect URI",
|
||||
"googleapp://lens?LensBitmapUriKey=content%3A%2F%2Fimage-url"
|
||||
+ "&AccountNameUriKey=test%40gmail.com&IncognitoUriKey=false"
|
||||
@ -361,8 +350,7 @@ public class LensUtilsTest {
|
||||
mBrowserTestRule.addTestAccountThenSigninAndEnableSync();
|
||||
Intent intentNoUri = getShareWithGoogleLensIntentOnUiThread(Uri.EMPTY,
|
||||
/* isIncognito= */ true, 1234L, /* srcUrl */ "", /* titleOrAltText */ "",
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM,
|
||||
/* requiresConfirmation */ false);
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
Assert.assertEquals("Intent without image has incorrect URI", "googleapp://lens",
|
||||
intentNoUri.getData().toString());
|
||||
Assert.assertEquals("Intent without image has incorrect action", Intent.ACTION_VIEW,
|
||||
@ -371,8 +359,7 @@ public class LensUtilsTest {
|
||||
final String contentUrl = "content://image-url";
|
||||
Intent intentWithContentUri = getShareWithGoogleLensIntentOnUiThread(Uri.parse(contentUrl),
|
||||
/* isIncognito= */ true, 1234L, /* srcUrl */ "", /* titleOrAltText */ "",
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM,
|
||||
/* requiresConfirmation */ false);
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
// The account name should not be included in the intent because the uesr is incognito.
|
||||
Assert.assertEquals("Intent with image has incorrect URI",
|
||||
"googleapp://lens?LensBitmapUriKey=content%3A%2F%2Fimage-url&AccountNameUriKey="
|
||||
@ -396,7 +383,7 @@ public class LensUtilsTest {
|
||||
Intent intentWithContentUri = getShareWithGoogleLensIntentOnUiThread(Uri.parse(contentUrl),
|
||||
/* isIncognito= */ false, 1234L, /* srcUrl */ "",
|
||||
/* titleOrAltText */ "", /* pageUrl */ null,
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM, /* requiresConfirmation */ false);
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
// The account name should not be included in the intent because the uesr is incognito.
|
||||
Assert.assertEquals("Intent with image has incorrect URI",
|
||||
"googleapp://lens?LensBitmapUriKey=content%3A%2F%2Fimage-url&AccountNameUriKey="
|
||||
@ -421,7 +408,7 @@ public class LensUtilsTest {
|
||||
Intent intentWithContentUri = getShareWithGoogleLensIntentOnUiThread(Uri.parse(contentUrl),
|
||||
/* isIncognito= */ true, 1234L, /* srcUrl */ "",
|
||||
/* titleOrAltText */ "", /* pageUrl */ null,
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM, /* requiresConfirmation */ false);
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
// The account name should not be included in the intent because the uesr is incognito.
|
||||
Assert.assertEquals("Intent with image has incorrect URI",
|
||||
"googleapp://lens?LensBitmapUriKey=content%3A%2F%2Fimage-url&AccountNameUriKey="
|
||||
@ -440,8 +427,7 @@ public class LensUtilsTest {
|
||||
public void getShareWithGoogleLensIntentNotSignedInTest() {
|
||||
Intent intentNoUri = getShareWithGoogleLensIntentOnUiThread(Uri.EMPTY,
|
||||
/* isIncognito= */ false, 1234L, /* srcUrl */ "", /* titleOrAltText */ "",
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM,
|
||||
/* requiresConfirmation */ false);
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
Assert.assertEquals("Intent without image has incorrect URI", "googleapp://lens",
|
||||
intentNoUri.getData().toString());
|
||||
Assert.assertEquals("Intent without image has incorrect action", Intent.ACTION_VIEW,
|
||||
@ -450,8 +436,7 @@ public class LensUtilsTest {
|
||||
final String contentUrl = "content://image-url";
|
||||
Intent intentWithContentUri = getShareWithGoogleLensIntentOnUiThread(Uri.parse(contentUrl),
|
||||
/* isIncognito= */ false, 1234L, /* srcUrl */ "", /* titleOrAltText */ "",
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM,
|
||||
/* requiresConfirmation */ false);
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
Assert.assertEquals("Intent with image has incorrect URI",
|
||||
"googleapp://lens?LensBitmapUriKey=content%3A%2F%2Fimage-url&AccountNameUriKey="
|
||||
+ "&IncognitoUriKey=false&ActivityLaunchTimestampNanos=1234",
|
||||
@ -471,8 +456,7 @@ public class LensUtilsTest {
|
||||
Intent intentWithContentUriZeroTimestamp =
|
||||
getShareWithGoogleLensIntentOnUiThread(Uri.parse(contentUrl),
|
||||
/* isIncognito= */ false, 0L, /* srcUrl */ "", /* titleOrAltText */ "",
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM,
|
||||
/* requiresConfirmation */ false);
|
||||
/* pageUrl */ null, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
Assert.assertEquals("Intent with image has incorrect URI",
|
||||
"googleapp://lens?LensBitmapUriKey=content%3A%2F%2Fimage-url&AccountNameUriKey="
|
||||
+ "&IncognitoUriKey=false&ActivityLaunchTimestampNanos=0",
|
||||
@ -481,12 +465,12 @@ public class LensUtilsTest {
|
||||
|
||||
private Intent getShareWithGoogleLensIntentOnUiThread(Uri imageUri, boolean isIncognito,
|
||||
long currentTimeNanos, String srcUrl, String titleOrAltText, String pageUrl,
|
||||
@LensEntryPoint int lensEntryPoint, boolean requiresConfirmation) {
|
||||
@LensEntryPoint int lensEntryPoint) {
|
||||
return TestThreadUtils.runOnUiThreadBlockingNoException(
|
||||
()
|
||||
-> LensUtils.getShareWithGoogleLensIntent(mContext, imageUri, isIncognito,
|
||||
currentTimeNanos, new GURL(srcUrl), titleOrAltText,
|
||||
new GURL(pageUrl), lensEntryPoint, requiresConfirmation));
|
||||
new GURL(pageUrl), lensEntryPoint));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -500,7 +484,7 @@ public class LensUtilsTest {
|
||||
Intent intentWithContentUri = getShareWithGoogleLensIntentOnUiThread(Uri.parse(contentUrl),
|
||||
/* isIncognito= */ false, 1234L, /* srcUrl */ "",
|
||||
/* titleOrAltText */ "An image description.", /* pageUrl */ null,
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM, /* requiresConfirmation */ false);
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
// The account name should not be included in the intent because the uesr is incognito.
|
||||
Assert.assertEquals("Intent with image has incorrect URI",
|
||||
"googleapp://lens?LensBitmapUriKey=content%3A%2F%2Fimage-url&AccountNameUriKey="
|
||||
@ -526,7 +510,7 @@ public class LensUtilsTest {
|
||||
Intent intentWithContentUri = getShareWithGoogleLensIntentOnUiThread(Uri.parse(contentUrl),
|
||||
/* isIncognito= */ true, 1234L, /* srcUrl */ "",
|
||||
/* titleOrAltText */ "An image description.", /* pageUrl */ null,
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM, /* requiresConfirmation */ false);
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
// The account name should not be included in the intent because the uesr is incognito.
|
||||
Assert.assertEquals("Intent with image has incorrect URI",
|
||||
"googleapp://lens?LensBitmapUriKey=content%3A%2F%2Fimage-url&AccountNameUriKey="
|
||||
@ -547,7 +531,7 @@ public class LensUtilsTest {
|
||||
Intent intentWithContentUri = getShareWithGoogleLensIntentOnUiThread(Uri.parse(contentUrl),
|
||||
/* isIncognito= */ false, 1234L, /* srcUrl */ "",
|
||||
/* titleOrAltText */ "", /* pageUrl */ null,
|
||||
LensEntryPoint.CONTEXT_MENU_SHOP_MENU_ITEM, /* requiresConfirmation */ false);
|
||||
LensEntryPoint.CONTEXT_MENU_SHOP_MENU_ITEM);
|
||||
// The account name should not be included in the intent because the uesr is incognito.
|
||||
Assert.assertEquals("Intent with image has incorrect URI",
|
||||
"googleapp://lens?LensBitmapUriKey=content%3A%2F%2Fimage-url&AccountNameUriKey="
|
||||
@ -558,27 +542,6 @@ public class LensUtilsTest {
|
||||
intentWithContentUri.getAction());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test {@link LensUtils#getShareWithGoogleLensIntent()} method when requires confirmation.
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
public void getShareWithGoogleLensIntentWithConfirmationTest() {
|
||||
final String contentUrl = "content://image-url";
|
||||
Intent intentWithContentUri = getShareWithGoogleLensIntentOnUiThread(Uri.parse(contentUrl),
|
||||
/* isIncognito= */ false, 1234L, /* srcUrl */ "",
|
||||
/* titleOrAltText */ "", /* pageUrl */ null,
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM, /* requiresConfirmation */ true);
|
||||
// The account name should not be included in the intent because the uesr is incognito.
|
||||
Assert.assertEquals("Intent with image has incorrect URI",
|
||||
"googleapp://lens?LensBitmapUriKey=content%3A%2F%2Fimage-url&AccountNameUriKey="
|
||||
+ "&IncognitoUriKey=false&ActivityLaunchTimestampNanos=1234&"
|
||||
+ "requiresConfirmation=true",
|
||||
intentWithContentUri.getData().toString());
|
||||
Assert.assertEquals("Intent with image has incorrect action", Intent.ACTION_VIEW,
|
||||
intentWithContentUri.getAction());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test {@link LensUtils#getShareWithGoogleLensIntent()} method when alt text is available and
|
||||
* enabled by finch.
|
||||
@ -595,7 +558,7 @@ public class LensUtilsTest {
|
||||
Intent intentWithContentUri = getShareWithGoogleLensIntentOnUiThread(Uri.parse(contentUrl),
|
||||
/* isIncognito= */ false, 1234L, /* srcUrl */ "",
|
||||
/* titleOrAltText= */ "An image description.", /* pageUrl= */ null,
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM, /* requiresConfirmation */ false);
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
// The account name should not be included in the intent because the uesr is incognito.
|
||||
Assert.assertEquals("Intent with image has incorrect URI",
|
||||
"googleapp://lens?LensBitmapUriKey=content%3A%2F%2Fimage-url&AccountNameUriKey="
|
||||
@ -623,7 +586,7 @@ public class LensUtilsTest {
|
||||
/* isIncognito= */ false, 1234L, /* srcUrl */ "",
|
||||
/* titleOrAltText */ "",
|
||||
/* pageUrl */ "https://www.google.com?testQueryParam",
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM, /* requiresConfirmation */ false);
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
Assert.assertEquals("Intent with image has incorrect Page URL",
|
||||
"googleapp://lens?LensBitmapUriKey=content%3A%2F%2Fimage-url&AccountNameUriKey="
|
||||
+ "&IncognitoUriKey=false&ActivityLaunchTimestampNanos=1234&PageUrl="
|
||||
@ -648,7 +611,7 @@ public class LensUtilsTest {
|
||||
/* isIncognito= */ true, 1234L, /* srcUrl */ "",
|
||||
/* titleOrAltText */ "",
|
||||
/* pageUrl */ "https://www.google.com?testQueryParam",
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM, /* requiresConfirmation */ false);
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
Assert.assertEquals("Intent with image has incorrect URI",
|
||||
"googleapp://lens?LensBitmapUriKey=content%3A%2F%2Fimage-url&AccountNameUriKey="
|
||||
+ "&IncognitoUriKey=true&ActivityLaunchTimestampNanos=1234",
|
||||
@ -667,7 +630,7 @@ public class LensUtilsTest {
|
||||
/* isIncognito= */ false, 1234L, /* srcUrl */ "",
|
||||
/* titleOrAltText */ "",
|
||||
/* pageUrl */ "https://www.google.com?testQueryParam",
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM, /* requiresConfirmation */ false);
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
// The account name should not be included in the intent because the uesr is incognito.
|
||||
Assert.assertEquals("Intent with image has incorrect URI",
|
||||
"googleapp://lens?LensBitmapUriKey=content%3A%2F%2Fimage-url&AccountNameUriKey="
|
||||
@ -686,7 +649,7 @@ public class LensUtilsTest {
|
||||
Intent intentWithContentUri = getShareWithGoogleLensIntentOnUiThread(Uri.parse(contentUrl),
|
||||
/* isIncognito= */ false, 1234L, /* srcUrl */ "http://www.google.com?key=val",
|
||||
/* titleOrAltText */ "", /* pageUrl */ null,
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM, /* requiresConfirmation */ false);
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
// The account name should not be included in the intent because the param is disabled..
|
||||
Assert.assertEquals("Intent with image has incorrect URI",
|
||||
"googleapp://lens?LensBitmapUriKey=content%3A%2F%2Fimage-url&AccountNameUriKey="
|
||||
@ -712,7 +675,7 @@ public class LensUtilsTest {
|
||||
Intent intentWithContentUri = getShareWithGoogleLensIntentOnUiThread(Uri.parse(contentUrl),
|
||||
/* isIncognito= */ false, 1234L, /* srcUrl */ "http://www.google.com?key=val",
|
||||
/* titleOrAltText */ "", /* pageUrl */ null,
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM, /* requiresConfirmation */ false);
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
// The account name should not be included in the intent because the uesr is incognito.
|
||||
Assert.assertEquals("Intent with image has incorrect URI",
|
||||
"googleapp://lens?LensBitmapUriKey=content%3A%2F%2Fimage-url&AccountNameUriKey="
|
||||
@ -739,7 +702,7 @@ public class LensUtilsTest {
|
||||
Intent intentWithContentUri = getShareWithGoogleLensIntentOnUiThread(Uri.parse(contentUrl),
|
||||
/* isIncognito= */ true, 1234L, /* srcUrl */ "http://www.google.com?key=val",
|
||||
/* titleOrAltText */ "", /* pageUrl */ null,
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM, /* requiresConfirmation */ false);
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
// The account name should not be included in the intent because the uesr is incognito.
|
||||
Assert.assertEquals("Intent with image has incorrect URI",
|
||||
"googleapp://lens?LensBitmapUriKey=content%3A%2F%2Fimage-url&AccountNameUriKey="
|
||||
@ -842,9 +805,9 @@ public class LensUtilsTest {
|
||||
final String titleOrAltText = "Image Title";
|
||||
final String pageUrl = "https://www.google.com";
|
||||
final int intentType = 0;
|
||||
LensIntentParams lensIntentParams = LensUtils.buildLensIntentParams(Uri.parse(contentUrl),
|
||||
isIncognito, srcUrl, titleOrAltText, pageUrl,
|
||||
LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM, /* requiresConfirmation */ false);
|
||||
LensIntentParams lensIntentParams =
|
||||
LensUtils.buildLensIntentParams(Uri.parse(contentUrl), isIncognito, srcUrl,
|
||||
titleOrAltText, pageUrl, LensEntryPoint.CONTEXT_MENU_SEARCH_MENU_ITEM);
|
||||
|
||||
Assert.assertEquals("Lens intent parameters has incorrect image URI.", contentUrl,
|
||||
lensIntentParams.getImageUri().toString());
|
||||
@ -856,8 +819,6 @@ public class LensUtilsTest {
|
||||
titleOrAltText, lensIntentParams.getImageTitleOrAltText());
|
||||
Assert.assertEquals("Lens intent parameters has incorrect page URL.", pageUrl,
|
||||
lensIntentParams.getPageUrl());
|
||||
Assert.assertEquals("Lens intent parameters has incorrect requires confirmation value.",
|
||||
false, lensIntentParams.getRequiresConfirmation());
|
||||
Assert.assertEquals("Lens intent parameters has incorrect intent type value.", intentType,
|
||||
lensIntentParams.getIntentType());
|
||||
}
|
||||
|
@ -1882,22 +1882,6 @@ const FeatureEntry::FeatureVariation kHomepagePromoCardVariations[] = {
|
||||
#endif // defined(OS_ANDROID)
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
const FeatureEntry::FeatureParam kContextMenuShopSimilarProducts[] = {
|
||||
{"lensShopVariation", "ShopSimilarProducts"}};
|
||||
const FeatureEntry::FeatureParam kContextMenuShopImageWithGoogleLens[] = {
|
||||
{"lensShopVariation", "ShopImageWithGoogleLens"}};
|
||||
const FeatureEntry::FeatureParam kContextMenuSearchSimilarProducts[] = {
|
||||
{"lensShopVariation", "SearchSimilarProducts"}};
|
||||
|
||||
const FeatureEntry::FeatureVariation
|
||||
kContextMenuShopWithGoogleLensShopVariations[] = {
|
||||
{"ShopSimilarProducts", kContextMenuShopSimilarProducts,
|
||||
base::size(kContextMenuShopSimilarProducts), nullptr},
|
||||
{"ShopImageWithGoogleLens", kContextMenuShopImageWithGoogleLens,
|
||||
base::size(kContextMenuShopImageWithGoogleLens), nullptr},
|
||||
{"SearchSimilarProducts", kContextMenuSearchSimilarProducts,
|
||||
base::size(kContextMenuSearchSimilarProducts), nullptr}};
|
||||
|
||||
const FeatureEntry::FeatureParam kLensCameraAssistedSearchLensButtonStart[] = {
|
||||
{"searchBoxStartVariantForLensCameraAssistedSearch", "true"}};
|
||||
|
||||
@ -5854,10 +5838,7 @@ const FeatureEntry kFeatureEntries[] = {
|
||||
{"context-menu-shop-with-google-lens",
|
||||
flag_descriptions::kContextMenuShopWithGoogleLensName,
|
||||
flag_descriptions::kContextMenuShopWithGoogleLensDescription, kOsAndroid,
|
||||
FEATURE_WITH_PARAMS_VALUE_TYPE(
|
||||
chrome::android::kContextMenuShopWithGoogleLens,
|
||||
kContextMenuShopWithGoogleLensShopVariations,
|
||||
"ContextMenuShopWithGoogleLens")},
|
||||
FEATURE_VALUE_TYPE(chrome::android::kContextMenuShopWithGoogleLens)},
|
||||
|
||||
{"context-menu-search-and-shop-with-google-lens",
|
||||
flag_descriptions::kContextMenuSearchAndShopWithGoogleLensName,
|
||||
|
@ -80,7 +80,7 @@ public class LensController {
|
||||
mDelegate.getChipRenderParams(lensQueryParams, chipRenderParamsCallback);
|
||||
}
|
||||
|
||||
// TODO(benwgold): Delete this function after internal code is switched over.
|
||||
// TODO(b/182675578): Deprecated. Switch to use the one without requiresConfirmation
|
||||
/**
|
||||
* Get a deeplink intent to Google Lens with an optional content provider image
|
||||
* URI. The intent should be constructed immediately before the intent is fired
|
||||
@ -103,6 +103,27 @@ public class LensController {
|
||||
requiresConfirmation, titleOrAltText, pageUrl, lensIntentType);
|
||||
}
|
||||
|
||||
// TODO(benwgold): Delete this function after internal code is switched over.
|
||||
/**
|
||||
* Get a deeplink intent to Google Lens with an optional content provider image
|
||||
* URI. The intent should be constructed immediately before the intent is fired
|
||||
* to ensure that the launch timestamp is accurate.
|
||||
*
|
||||
* @param imageUri The content provider URI generated by chrome (or empty URI) if only resolving
|
||||
* the activity.
|
||||
* @param isIncognito Whether the current tab is in incognito mode.
|
||||
* @param srcUrl The 'src' attribute of the image.
|
||||
* @param titleOrAltText The 'title' or, if empty, the 'alt' attribute of the image.
|
||||
* @param pageUrl The url of the current page.
|
||||
* @param lensIntentType The intent type of the request.
|
||||
* @return The intent to Google Lens.
|
||||
*/
|
||||
public Intent getShareWithGoogleLensIntent(Uri imageUri, boolean isIncognito, String srcUrl,
|
||||
String titleOrAltText, String pageUrl, @Nullable String lensIntentType) {
|
||||
return mDelegate.getShareWithGoogleLensIntent(
|
||||
imageUri, isIncognito, srcUrl, titleOrAltText, pageUrl, lensIntentType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch Lens with an intent.
|
||||
* @param window The current window.
|
||||
|
@ -60,6 +60,12 @@ public class LensControllerDelegate {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @see {@link LensController#getShareWithGoogleLensIntent()} */
|
||||
public Intent getShareWithGoogleLensIntent(Uri imageUri, boolean isIncognito, String srcUrl,
|
||||
String titleOrAltText, String pageUrl, @Nullable String lensIntentType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @see {@link LensController#startLens(WindowAndroid, Intent)} */
|
||||
public void startLens(WindowAndroid window, Intent intent) {}
|
||||
|
||||
|
@ -16,6 +16,7 @@ public class LensIntentParams {
|
||||
private String mImageTitleOrAltText;
|
||||
private String mPageUrl;
|
||||
private boolean mIsIncognito;
|
||||
// TODO(b/182675578): Remove requiresConfirmation from LensIntentParams.
|
||||
private boolean mRequiresConfirmation;
|
||||
private int mIntentType;
|
||||
private String mProactiveSessionId;
|
||||
|
@ -297,15 +297,9 @@ public final class ChromePreferenceKeys {
|
||||
public static final String CONTEXT_MENU_SEARCH_WITH_GOOGLE_LENS_CLICKED =
|
||||
"Chrome.ContextMenu.SearchWithGoogleLensClicked";
|
||||
|
||||
public static final String CONTEXT_MENU_SHOP_SIMILAR_PRODUCTS_CLICKED =
|
||||
"Chrome.ContextMenu.ShopSimilarProductsClicked";
|
||||
|
||||
public static final String CONTEXT_MENU_SHOP_IMAGE_WITH_GOOGLE_LENS_CLICKED =
|
||||
"Chrome.ContextMenu.ShopImageWithGoogleLensClicked";
|
||||
|
||||
public static final String CONTEXT_MENU_SEARCH_SIMILAR_PRODUCTS_CLICKED =
|
||||
"Chrome.ContextMenu.SearchSimilarProductsClicked";
|
||||
|
||||
public static final String CRASH_UPLOAD_FAILURE_BROWSER = "browser_crash_failure_upload";
|
||||
public static final String CRASH_UPLOAD_FAILURE_GPU = "gpu_crash_failure_upload";
|
||||
public static final String CRASH_UPLOAD_FAILURE_OTHER = "other_crash_failure_upload";
|
||||
@ -1012,8 +1006,6 @@ public final class ChromePreferenceKeys {
|
||||
CONTEXT_MENU_OPEN_NEW_TAB_IN_GROUP_ITEM_FIRST,
|
||||
CONTEXT_MENU_SEARCH_WITH_GOOGLE_LENS_CLICKED,
|
||||
CONTEXT_MENU_SHOP_IMAGE_WITH_GOOGLE_LENS_CLICKED,
|
||||
CONTEXT_MENU_SHOP_SIMILAR_PRODUCTS_CLICKED,
|
||||
CONTEXT_MENU_SEARCH_SIMILAR_PRODUCTS_CLICKED,
|
||||
CRYPTID_LAST_RENDER_TIMESTAMP,
|
||||
DEFAULT_BROWSER_PROMO_LAST_DEFAULT_STATE,
|
||||
DEFAULT_BROWSER_PROMO_LAST_PROMO_TIME,
|
||||
|
@ -2204,15 +2204,9 @@ To change this setting, <ph name="BEGIN_LINK"><resetlink></ph>reset sync<p
|
||||
<message name="IDS_CONTEXTMENU_TRANSLATE_IMAGE_WITH_GOOGLE_LENS" desc="Context sensitive chip for deep linking into google lens for translate results. [CHAR_LIMIT=30]">
|
||||
Translate image with Google Lens <ph name="BEGIN_NEW"><new></ph>New<ph name="END_NEW"></new></ph>
|
||||
</message>
|
||||
<message name="IDS_CONTEXTMENU_SHOP_SIMILAR_PRODUCTS" desc="Context sensitive menu item for deep linking into google lens for shopping results. [CHAR_LIMIT=30]">
|
||||
Shop similar products <ph name="BEGIN_NEW"><new></ph>New<ph name="END_NEW"></new></ph>
|
||||
</message>
|
||||
<message name="IDS_CONTEXTMENU_SHOP_IMAGE_WITH_GOOGLE_LENS" desc="Context sensitive menu item for deep linking into google lens for shopping results. [CHAR_LIMIT=30]">
|
||||
Shop image with Google Lens <ph name="BEGIN_NEW"><new></ph>New<ph name="END_NEW"></new></ph>
|
||||
</message>
|
||||
<message name="IDS_CONTEXTMENU_SEARCH_SIMILAR_PRODUCTS" desc="Context sensitive menu item for deep linking into google lens for shopping results. [CHAR_LIMIT=30]">
|
||||
Search similar products <ph name="BEGIN_NEW"><new></ph>New<ph name="END_NEW"></new></ph>
|
||||
</message>
|
||||
<message name="IDS_CONTEXTMENU_SEARCH_WEB_FOR_IMAGE" desc="Context sensitive menu item for search-for-Image command in a new tab. [CHAR_LIMIT=30]">
|
||||
Search <ph name="SEARCH_ENGINE">%1$s<ex>Google</ex></ph> for this image
|
||||
</message>
|
||||
|
@ -1 +0,0 @@
|
||||
fb7b73c9f65526f05f909b2156a50bfd90e4cdd1
|
@ -1 +0,0 @@
|
||||
1df58ed84fe0ef4ea3bbd290a2ee6f376ea3afbd
|
@ -2190,7 +2190,6 @@
|
||||
"name": "EnabledWithTextShopImageWithGoogleLens",
|
||||
"params": {
|
||||
"disableOnIncognito": "true",
|
||||
"lensShopVariation": "ShopImageWithGoogleLens",
|
||||
"logUkm": "true",
|
||||
"minAgsaVersionNameForShopping": "11.17"
|
||||
},
|
||||
|
Reference in New Issue
Block a user