[iOS] Improve Lens Shop (with product image) behavior
This CL improves the behavior of the Shop with Lens ephemeral card in the Magic Stack on iOS. Key changes: - Fixes the Lens entrypoint for accurate metrics: Changes the entrypoint from HomeScreenWidget to NewTabPage to ensure accurate metrics reporting. - Improves ContentSuggestionsModuleType determination: More reliably determines the module type (kTips or kTipsWithProductImage) by consistently checking the TipsLensShopExperimentType and validating product image data for non-empty values. This also improves efficiency. - Enhances code readability: Improves the readability of the -type method in TipsModuleState. Low-Coverage-Reason: TRIVIAL_CHANGE Change-Id: I9ae02a092a570134f6a0b2934f1e552a962da41f Fixed: 375462605 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5968113 Commit-Queue: Benjamin Williams <bwwilliams@google.com> Reviewed-by: Chris Lu <thegreenfrog@chromium.org> Auto-Submit: Benjamin Williams <bwwilliams@google.com> Cr-Commit-Position: refs/heads/main@{#1374679}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
9ea0ebde03
commit
0844129049
ios/chrome/browser/ui/content_suggestions
@ -631,21 +631,25 @@ using segmentation_platform::TipIdentifier;
|
||||
case TipIdentifier::kLensTranslate: {
|
||||
LensEntrypoint entryPoint = tip == TipIdentifier::kLensTranslate
|
||||
? LensEntrypoint::TranslateOnebox
|
||||
: LensEntrypoint::HomeScreenWidget;
|
||||
: LensEntrypoint::NewTabPage;
|
||||
|
||||
if (tip == TipIdentifier::kLensShop &&
|
||||
_tipsMediator.state.productImageData != nil) {
|
||||
TipsLensShopExperimentTypeEnabled() ==
|
||||
TipsLensShopExperimentType::kWithProductImage &&
|
||||
_tipsMediator.state.productImageData.length > 0) {
|
||||
UIImage* productImage =
|
||||
[UIImage imageWithData:_tipsMediator.state.productImageData];
|
||||
|
||||
SearchImageWithLensCommand* command =
|
||||
[[SearchImageWithLensCommand alloc] initWithImage:productImage
|
||||
entryPoint:entryPoint];
|
||||
if (productImage) {
|
||||
SearchImageWithLensCommand* command =
|
||||
[[SearchImageWithLensCommand alloc] initWithImage:productImage
|
||||
entryPoint:entryPoint];
|
||||
|
||||
[HandlerForProtocol(self.browser->GetCommandDispatcher(), LensCommands)
|
||||
searchImageWithLens:command];
|
||||
[HandlerForProtocol(self.browser->GetCommandDispatcher(),
|
||||
LensCommands) searchImageWithLens:command];
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
OpenLensInputSelectionCommand* command =
|
||||
|
@ -553,10 +553,14 @@ using segmentation_platform::home_modules::SavePasswordsEphemeralModule;
|
||||
TipIdentifier tipIdentifier = TipIdentifierForOutputLabel(label);
|
||||
|
||||
if (tipIdentifier != TipIdentifier::kUnknown) {
|
||||
BOOL shouldShowTipsWithProductImage =
|
||||
tipIdentifier == TipIdentifier::kLensShop &&
|
||||
TipsLensShopExperimentTypeEnabled() ==
|
||||
TipsLensShopExperimentType::kWithProductImage &&
|
||||
_tipsMediator.state.productImageData.length > 0;
|
||||
|
||||
_ephemeralCardToShow =
|
||||
(tipIdentifier == TipIdentifier::kLensShop &&
|
||||
TipsLensShopExperimentTypeEnabled() ==
|
||||
TipsLensShopExperimentType::kWithProductImage)
|
||||
shouldShowTipsWithProductImage
|
||||
? ContentSuggestionsModuleType::kTipsWithProductImage
|
||||
: ContentSuggestionsModuleType::kTips;
|
||||
|
||||
|
@ -212,7 +212,7 @@ using segmentation_platform::TipIdentifier;
|
||||
NSData* data = [NSData dataWithBytes:imageData.data()
|
||||
length:imageData.size()];
|
||||
|
||||
if (!data) {
|
||||
if (data.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -26,14 +26,14 @@ using segmentation_platform::TipIdentifier;
|
||||
- (ContentSuggestionsModuleType)type {
|
||||
CHECK(IsTipsMagicStackEnabled());
|
||||
|
||||
if (_identifier != TipIdentifier::kLensShop ||
|
||||
(TipsLensShopExperimentTypeEnabled() ==
|
||||
TipsLensShopExperimentType::kWithProductImage &&
|
||||
!_productImageData)) {
|
||||
return ContentSuggestionsModuleType::kTips;
|
||||
if (_identifier == TipIdentifier::kLensShop &&
|
||||
TipsLensShopExperimentTypeEnabled() ==
|
||||
TipsLensShopExperimentType::kWithProductImage &&
|
||||
_productImageData.length > 0) {
|
||||
return ContentSuggestionsModuleType::kTipsWithProductImage;
|
||||
}
|
||||
|
||||
return ContentSuggestionsModuleType::kTipsWithProductImage;
|
||||
return ContentSuggestionsModuleType::kTips;
|
||||
}
|
||||
|
||||
@end
|
||||
|
Reference in New Issue
Block a user