Commit 1e515f7d authored by Ben Goldberger's avatar Ben Goldberger Committed by Commit Bot

Add check to prevent menu repositioning if lens queries are not supported.

Bug: 1146194
Change-Id: Ied52ecff145dfa2ccb0b496cc9188a9be640c652
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2522502
Commit-Queue: Ben Goldberger <benwgold@google.com>
Reviewed-by: default avatarSinan Sahin <sinansahin@google.com>
Cr-Commit-Position: refs/heads/master@{#825173}
parent 4abc576e
...@@ -134,8 +134,9 @@ public class ContextMenuHelper { ...@@ -134,8 +134,9 @@ public class ContextMenuHelper {
mCurrentPopulator.onMenuClosed(); mCurrentPopulator.onMenuClosed();
mCurrentPopulator = null; mCurrentPopulator = null;
} }
if (LensUtils.enableImageChip(mIsIncognito)) { if (LensUtils.enableImageChip(mIsIncognito)
// If the image was being classified terminate the classification && LensController.getInstance().isQueryEnabled()) {
// If the image was being classified terminate the classification.
// Has no effect if the classification already succeeded. // Has no effect if the classification already succeeded.
LensController.getInstance().terminateClassification(); LensController.getInstance().terminateClassification();
} }
...@@ -158,7 +159,8 @@ public class ContextMenuHelper { ...@@ -158,7 +159,8 @@ public class ContextMenuHelper {
new RevampedContextMenuCoordinator(topContentOffsetPx, mCurrentNativeDelegate); new RevampedContextMenuCoordinator(topContentOffsetPx, mCurrentNativeDelegate);
mCurrentContextMenu = menuCoordinator; mCurrentContextMenu = menuCoordinator;
if (LensUtils.enableImageChip(mIsIncognito)) { if (LensUtils.enableImageChip(mIsIncognito)
&& LensController.getInstance().isQueryEnabled()) {
LensAsyncManager lensAsyncManager = new LensAsyncManager(mCurrentContextMenuParams, LensAsyncManager lensAsyncManager = new LensAsyncManager(mCurrentContextMenuParams,
mCurrentNativeDelegate, mWindow, mIsIncognito, mPageTitle); mCurrentNativeDelegate, mWindow, mIsIncognito, mPageTitle);
menuCoordinator.displayMenuWithLensChip(mWindow, mWebContents, menuCoordinator.displayMenuWithLensChip(mWindow, mWebContents,
......
...@@ -24,6 +24,7 @@ public class LensController { ...@@ -24,6 +24,7 @@ public class LensController {
} }
/** /**
* TODO(benwgold): Deprecate this API Call.
* Whether the Lens SDK is available. * Whether the Lens SDK is available.
* @return Whether the Lens SDK is available. * @return Whether the Lens SDK is available.
*/ */
...@@ -31,6 +32,16 @@ public class LensController { ...@@ -31,6 +32,16 @@ public class LensController {
return false; return false;
} }
/**
* Whether the Lens chip should be enabled based on user signals.
* @return Whether the Lens SDK is available.
*/
public boolean isQueryEnabled() {
// Return true by default to support integration testing where
// internal code is not available.
return true;
}
/** /**
* Classify an image and once complete trigger a callback with a LensQueryResult on whether that * Classify an image and once complete trigger a callback with a LensQueryResult on whether that
* image supports a lens action. * image supports a lens action.
......
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