Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3423)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManager.java

Issue 1532743002: [Contextual Search] Use Mojo API for Quick Answers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated a comment. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManager.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManager.java b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManager.java
index 27d16f0407e25a22c69317c66bf913d76c8bc484..c9a6772ead91a87027f527c2333d42b1523612f4 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManager.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManager.java
@@ -11,6 +11,7 @@ import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnGlobalFocusChangeListener;
+import org.chromium.base.Log;
import org.chromium.base.SysUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.CalledByNative;
@@ -752,6 +753,20 @@ public class ContextualSearchManager extends ContextualSearchObservable
return mPolicy.isTapSupported();
}
+ /**
+ * Called by the page through the CS JavaScript API to notify CS that there is
+ * a caption available on the current overlay.
+ * @param caption The caption to display.
+ * @param doesAnswer Whether the caption should be regarded as an answer such
+ * that the user may not need to open the panel, or whether the caption
+ * is simply informative or descriptive of the answer in the full results.
+ */
+ @CalledByNative
+ private void onSetCaption(String caption, boolean doesAnswer) {
+ // TODO(donnd): notify the UI of the caption and log doesAnswer.
+ Log.i(TAG, "ctxs setCaption: '" + caption + "', " + doesAnswer);
+ }
+
// ============================================================================================
// Translation support
// TODO(donnd): move to a separate file.
@@ -1000,6 +1015,13 @@ public class ContextualSearchManager extends ContextualSearchObservable
@Override
public void onContentViewCreated(ContentViewCore contentViewCore) {
+ // TODO(donnd): Consider moving to OverlayPanelContent.
+ if (mPolicy.isContextualSearchJsApiEnabled()) {
+ // Enable the Contextual Search JavaScript API between our service and the new view.
+ nativeEnableContextualSearchJsApiForOverlay(
+ mNativeContextualSearchManagerPtr, contentViewCore);
+ }
+
// TODO(mdjones): Move SearchContentViewDelegate ownership to panel.
mSearchContentViewDelegate.setOverlayPanelContentViewCore(contentViewCore);
}
@@ -1350,6 +1372,8 @@ public class ContextualSearchManager extends ContextualSearchObservable
private native void nativeGatherSurroundingText(long nativeContextualSearchManager,
String selection, boolean useResolvedSearchTerm, ContentViewCore baseContentViewCore,
boolean maySendBasePageUrl);
+ private native void nativeEnableContextualSearchJsApiForOverlay(
+ long nativeContextualSearchManager, ContentViewCore overlayContentViewCore);
// Don't call these directly, instead call the private methods that cache the results.
private native String nativeGetTargetLanguage(long nativeContextualSearchManager);
private native String nativeGetAcceptLanguages(long nativeContextualSearchManager);

Powered by Google App Engine
This is Rietveld 408576698