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

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

Issue 2703643004: [TTS] Add an ACK message to SelectWordAroundCaret. (Closed)
Patch Set: Updated and rebased onto recently refactored Contextual Search, which shows simplifications availab… Created 3 years, 7 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.os.Handler; 7 import android.os.Handler;
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;
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 if (!isOverlayVideoMode()) { 1203 if (!isOverlayVideoMode()) {
1204 mSelectionController.handleShowUnhandledTapUIIfNeeded(x, y); 1204 mSelectionController.handleShowUnhandledTapUIIfNeeded(x, y);
1205 } 1205 }
1206 } 1206 }
1207 1207
1208 @Override 1208 @Override
1209 public boolean sendsSelectionPopupUpdates() { 1209 public boolean sendsSelectionPopupUpdates() {
1210 return false; 1210 return false;
1211 } 1211 }
1212 1212
1213 // TODO(donnd): add handling of an ACK to selectWordAroundCaret (crbug.com/4 35778 has details). 1213 @Override
1214 public void selectWordAroundCaretAck(boolean didSelect, int startAdjust, int endAdjust) {
1215 if (isOverlayVideoMode()
aelias_OOO_until_Jul13 2017/04/27 22:01:27 Is this needed? The request is already suppressed
Donn Denman 2017/04/28 20:28:00 Done.
1216 || !mInternalStateController.isStillWorkingOn(InternalState.STAR T_SHOWING_TAP_UI)) {
aelias_OOO_until_Jul13 2017/04/27 22:01:27 This early-return also looks a bit sketchy. Gener
Donn Denman 2017/04/28 20:28:00 I *think* we want to leave this isStillWorkingOn()
aelias_OOO_until_Jul13 2017/04/28 20:55:29 It doesn't fully make sense to me. If the ack sho
Donn Denman 2017/04/28 21:54:41 We have a simple model where we only work on the m
aelias_OOO_until_Jul13 2017/04/28 22:14:33 Counterpoints: - I don't agree with the claim of
1217 return;
1218 }
1219
1220 if (didSelect) {
1221 assert mContext != null;
1222 mContext.onSelectionAdjusted(startAdjust, endAdjust);
1223 showSelectionAsSearchInBar(mSelectionController.getSelectedText());
1224 }
1225 mInternalStateController.notifyFinishedWorkOn(InternalState.START_SHOWIN G_TAP_UI);
1226 }
1214 1227
1215 /** 1228 /**
1216 * @return Whether the display is in a full-screen video overlay mode. 1229 * @return Whether the display is in a full-screen video overlay mode.
1217 */ 1230 */
1218 private boolean isOverlayVideoMode() { 1231 private boolean isOverlayVideoMode() {
1219 return mActivity.getFullscreenManager() != null 1232 return mActivity.getFullscreenManager() != null
1220 && mActivity.getFullscreenManager().isOverlayVideoMode(); 1233 && mActivity.getFullscreenManager().isOverlayVideoMode();
1221 } 1234 }
1222 1235
1223 // ========================================================================= =================== 1236 // ========================================================================= ===================
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 * to expand the selection to a whole word. 1301 * to expand the selection to a whole word.
1289 */ 1302 */
1290 @Override 1303 @Override
1291 public void handleSelection(String selection, boolean selectionValid, Select ionType type, 1304 public void handleSelection(String selection, boolean selectionValid, Select ionType type,
1292 float x, float y) { 1305 float x, float y) {
1293 if (mIsAccessibilityModeEnabled) return; 1306 if (mIsAccessibilityModeEnabled) return;
1294 1307
1295 if (!selection.isEmpty()) { 1308 if (!selection.isEmpty()) {
1296 ContextualSearchUma.logSelectionIsValid(selectionValid); 1309 ContextualSearchUma.logSelectionIsValid(selectionValid);
1297 1310
1298 // Update the context so it knows the selection has changed.
1299 if (mContext != null) mContext.updateContextFromSelection(selection) ;
1300
1301 if (selectionValid && mSearchPanel != null) { 1311 if (selectionValid && mSearchPanel != null) {
1302 mSearchPanel.updateBasePageSelectionYPx(y); 1312 mSearchPanel.updateBasePageSelectionYPx(y);
1303 if (!mSearchPanel.isShowing()) { 1313 if (!mSearchPanel.isShowing()) {
1304 mSearchPanel.getPanelMetrics().onSelectionEstablished(select ion); 1314 mSearchPanel.getPanelMetrics().onSelectionEstablished(select ion);
1305 } 1315 }
1306 showSelectionAsSearchInBar(selection); 1316 showSelectionAsSearchInBar(selection);
1307 1317
1308 // TODO(donnd): remove this complication when we get an ACK mess age from 1318 if (type == SelectionType.LONG_PRESS) {
1309 // selectWordAroundCaret (see crbug.com/435778).
1310 if (type == SelectionType.TAP) {
1311 mInternalStateController.notifyFinishedWorkOn(
1312 InternalState.START_SHOWING_TAP_UI);
1313 } else {
1314 mInternalStateController.enter(InternalState.LONG_PRESS_RECO GNIZED); 1319 mInternalStateController.enter(InternalState.LONG_PRESS_RECO GNIZED);
1315 } 1320 }
1316 } else { 1321 } else {
1317 hideContextualSearch(StateChangeReason.INVALID_SELECTION); 1322 hideContextualSearch(StateChangeReason.INVALID_SELECTION);
1318 } 1323 }
1319 } 1324 }
1320 } 1325 }
1321 1326
1322 @Override 1327 @Override
1323 public void handleSelectionDismissal() { 1328 public void handleSelectionDismissal() {
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1566 private native void nativeStartSearchTermResolutionRequest(long nativeContex tualSearchManager, 1571 private native void nativeStartSearchTermResolutionRequest(long nativeContex tualSearchManager,
1567 ContextualSearchContext contextualSearchContext, WebContents baseWeb Contents); 1572 ContextualSearchContext contextualSearchContext, WebContents baseWeb Contents);
1568 protected native void nativeGatherSurroundingText(long nativeContextualSearc hManager, 1573 protected native void nativeGatherSurroundingText(long nativeContextualSearc hManager,
1569 ContextualSearchContext contextualSearchContext, WebContents baseWeb Contents); 1574 ContextualSearchContext contextualSearchContext, WebContents baseWeb Contents);
1570 private native void nativeEnableContextualSearchJsApiForOverlay( 1575 private native void nativeEnableContextualSearchJsApiForOverlay(
1571 long nativeContextualSearchManager, WebContents overlayWebContents); 1576 long nativeContextualSearchManager, WebContents overlayWebContents);
1572 // Don't call these directly, instead call the private methods that cache th e results. 1577 // Don't call these directly, instead call the private methods that cache th e results.
1573 private native String nativeGetTargetLanguage(long nativeContextualSearchMan ager); 1578 private native String nativeGetTargetLanguage(long nativeContextualSearchMan ager);
1574 private native String nativeGetAcceptLanguages(long nativeContextualSearchMa nager); 1579 private native String nativeGetAcceptLanguages(long nativeContextualSearchMa nager);
1575 } 1580 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698