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

Side by Side 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: Renamed methods all the way through to our component. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.contextualsearch; 5 package org.chromium.chrome.browser.contextualsearch;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.text.TextUtils; 8 import android.text.TextUtils;
9 import android.view.View; 9 import android.view.View;
10 import android.view.ViewGroup; 10 import android.view.ViewGroup;
11 import android.view.ViewTreeObserver; 11 import android.view.ViewTreeObserver;
12 import android.view.ViewTreeObserver.OnGlobalFocusChangeListener; 12 import android.view.ViewTreeObserver.OnGlobalFocusChangeListener;
13 13
14 import org.chromium.base.Log;
14 import org.chromium.base.SysUtils; 15 import org.chromium.base.SysUtils;
15 import org.chromium.base.VisibleForTesting; 16 import org.chromium.base.VisibleForTesting;
16 import org.chromium.base.annotations.CalledByNative; 17 import org.chromium.base.annotations.CalledByNative;
17 import org.chromium.chrome.R; 18 import org.chromium.chrome.R;
18 import org.chromium.chrome.browser.ChromeActivity; 19 import org.chromium.chrome.browser.ChromeActivity;
19 import org.chromium.chrome.browser.compositor.bottombar.OverlayContentDelegate; 20 import org.chromium.chrome.browser.compositor.bottombar.OverlayContentDelegate;
20 import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState; 21 import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState;
21 import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.StateChange Reason; 22 import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.StateChange Reason;
22 import org.chromium.chrome.browser.compositor.bottombar.OverlayPanelContentViewD elegate; 23 import org.chromium.chrome.browser.compositor.bottombar.OverlayPanelContentViewD elegate;
23 import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.Context ualSearchPanel; 24 import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.Context ualSearchPanel;
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 /** 746 /**
746 * @return Whether a Tap gesture is currently supported. 747 * @return Whether a Tap gesture is currently supported.
747 */ 748 */
748 private boolean isTapSupported() { 749 private boolean isTapSupported() {
749 // Base page just started navigating away, so taps should be ignored. 750 // Base page just started navigating away, so taps should be ignored.
750 if (mDidBasePageLoadJustStart) return false; 751 if (mDidBasePageLoadJustStart) return false;
751 752
752 return mPolicy.isTapSupported(); 753 return mPolicy.isTapSupported();
753 } 754 }
754 755
756 /**
757 * Called by the page through the CS JavaScript API to notify CS that there is
758 * a caption available on the current overlay.
759 * @param caption The caption to display.
760 * @param doesAnswer Whether the caption should be regarded as an answer suc h
761 * that the user may not need to open the panel, or whether the capti on
762 * is simply informative or descriptive of the answer in the full res ults.
763 */
764 @CalledByNative
765 private void onSetCaption(String caption, boolean doesAnswer) {
766 // TODO(donnd): notify the UX of the caption and log doesAnswer.
767 Log.i(TAG, "ctxs setCaption: '" + caption + "', " + doesAnswer);
768 }
769
755 // ========================================================================= =================== 770 // ========================================================================= ===================
756 // Translation support 771 // Translation support
757 // TODO(donnd): move to a separate file. 772 // TODO(donnd): move to a separate file.
758 // ========================================================================= =================== 773 // ========================================================================= ===================
759 774
760 /** 775 /**
761 * Gets the list of readable languages for the current user, with the first 776 * Gets the list of readable languages for the current user, with the first
762 * item in the list being the user's primary language (according to the Tran slate Service). 777 * item in the list being the user's primary language (according to the Tran slate Service).
763 * We assume that the user can read all languages that they can write. 778 * We assume that the user can read all languages that they can write.
764 * @return The {@link List} of languages the user understands with their pri mary language first. 779 * @return The {@link List} of languages the user understands with their pri mary language first.
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 mSearchRequest.setNormalPriority(); 1008 mSearchRequest.setNormalPriority();
994 loadSearchUrl(); 1009 loadSearchUrl();
995 } 1010 }
996 mShouldLoadDelayedSearch = true; 1011 mShouldLoadDelayedSearch = true;
997 mPolicy.updateCountersForOpen(); 1012 mPolicy.updateCountersForOpen();
998 } 1013 }
999 } 1014 }
1000 1015
1001 @Override 1016 @Override
1002 public void onContentViewCreated(ContentViewCore contentViewCore) { 1017 public void onContentViewCreated(ContentViewCore contentViewCore) {
1018 // TODO(donnd): Consider moving to OverlayPanelContent.
1019 if (mPolicy.isContextualSearchJsApiEnabled()) {
1020 // Enable the Contextual Search JavaScript API between our servi ce and the new view.
1021 nativeAddViewForContextualSearchJsApi(
1022 mNativeContextualSearchManagerPtr, contentViewCore);
1023 }
1024
1003 // TODO(mdjones): Move SearchContentViewDelegate ownership to panel. 1025 // TODO(mdjones): Move SearchContentViewDelegate ownership to panel.
1004 mSearchContentViewDelegate.setOverlayPanelContentViewCore(contentVie wCore); 1026 mSearchContentViewDelegate.setOverlayPanelContentViewCore(contentVie wCore);
1005 } 1027 }
1006 1028
1007 @Override 1029 @Override
1008 public void onContentViewDestroyed() { 1030 public void onContentViewDestroyed() {
1009 if (mSearchContentViewDelegate != null) { 1031 if (mSearchContentViewDelegate != null) {
1010 mSearchContentViewDelegate.releaseOverlayPanelContentViewCore(); 1032 mSearchContentViewDelegate.releaseOverlayPanelContentViewCore();
1011 } 1033 }
1012 } 1034 }
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 // ------------------------------------------------------------------------- ------------------- 1365 // ------------------------------------------------------------------------- -------------------
1344 1366
1345 private native long nativeInit(); 1367 private native long nativeInit();
1346 private native void nativeDestroy(long nativeContextualSearchManager); 1368 private native void nativeDestroy(long nativeContextualSearchManager);
1347 private native void nativeStartSearchTermResolutionRequest(long nativeContex tualSearchManager, 1369 private native void nativeStartSearchTermResolutionRequest(long nativeContex tualSearchManager,
1348 String selection, boolean useResolvedSearchTerm, ContentViewCore bas eContentViewCore, 1370 String selection, boolean useResolvedSearchTerm, ContentViewCore bas eContentViewCore,
1349 boolean maySendBasePageUrl); 1371 boolean maySendBasePageUrl);
1350 private native void nativeGatherSurroundingText(long nativeContextualSearchM anager, 1372 private native void nativeGatherSurroundingText(long nativeContextualSearchM anager,
1351 String selection, boolean useResolvedSearchTerm, ContentViewCore bas eContentViewCore, 1373 String selection, boolean useResolvedSearchTerm, ContentViewCore bas eContentViewCore,
1352 boolean maySendBasePageUrl); 1374 boolean maySendBasePageUrl);
1375 private native void nativeAddViewForContextualSearchJsApi(
1376 long nativeContextualSearchManager, ContentViewCore overlayContentVi ewCore);
1353 // Don't call these directly, instead call the private methods that cache th e results. 1377 // Don't call these directly, instead call the private methods that cache th e results.
1354 private native String nativeGetTargetLanguage(long nativeContextualSearchMan ager); 1378 private native String nativeGetTargetLanguage(long nativeContextualSearchMan ager);
1355 private native String nativeGetAcceptLanguages(long nativeContextualSearchMa nager); 1379 private native String nativeGetAcceptLanguages(long nativeContextualSearchMa nager);
1356 } 1380 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698