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

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: Created 5 years 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 f4d41cb777e9a3d1112fdec2a48e220099f36bc4..54461ab0d40ee3af012314d2669cefe72d0ccf68 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;
@@ -748,6 +749,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 UX of the caption and log doesAnswer.
+ Log.i(TAG, "ctxs setCaption: '" + caption + "', " + doesAnswer);
+ }
+
// ============================================================================================
// Translation support
// TODO(donnd): move to a separate file.
@@ -990,6 +1005,13 @@ public class ContextualSearchManager extends ContextualSearchObservable
@Override
public void onContentViewCreated(ContentViewCore contentViewCore) {
+ // TODO(donnd): Consider moving to OverlayPanelContent.
+ if (mPolicy.shouldEnableOverlayApi()) {
+ // Enable the Contextual Search JavaScript API between our service and the new view.
+ nativeAddViewForContextualSearchApi(
+ mNativeContextualSearchManagerPtr, contentViewCore);
+ }
+
// TODO(mdjones): Move SearchContentViewDelegate ownership to panel.
mSearchContentViewDelegate.setOverlayPanelContentViewCore(contentViewCore);
}
@@ -1343,4 +1365,6 @@ public class ContextualSearchManager extends ContextualSearchObservable
// 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);
+ private native void nativeAddViewForContextualSearchApi(
+ long nativeContextualSearchManager, ContentViewCore overlayContentViewCore);
}

Powered by Google App Engine
This is Rietveld 408576698