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

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

Issue 2211353002: [TTS] Gather surrounding text on Tap before any UX. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split usage of the Tapped text from the SearchAction into a separate CL. Created 4 years, 4 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/action/ResolvedSearchAction.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/action/ResolvedSearchAction.java b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/action/ResolvedSearchAction.java
new file mode 100644
index 0000000000000000000000000000000000000000..dea1eb876f46a5ef82558cc1c1354d96156d721a
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/action/ResolvedSearchAction.java
@@ -0,0 +1,51 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.contextualsearch.action;
+
+import android.text.TextUtils;
+
+import org.chromium.chrome.browser.contextualsearch.gesture.SearchGestureHost;
+
+/**
+ * Represents a Search Action that will gather and examine surrounding text in order to
+ * "resolve" what to search for.
+ */
+public class ResolvedSearchAction extends SearchAction {
Theresa 2016/08/16 15:41:49 Right now this class is just being used to extract
Donn Denman 2016/08/17 04:35:22 Correct. Added your nice description to the heade
+ // ============================================================================================
+ // Constructor
+ // ============================================================================================
+
+ public ResolvedSearchAction(SearchActionListener listener) {
+ super(listener);
+ }
+
+ // ============================================================================================
+ // Abstract implementations
+ // ============================================================================================
+
+ @Override
+ public void extractContext(SearchGestureHost host) {
+ updateState(host);
pedro (no code reviews) 2016/08/22 20:54:17 Why is updateState() being exposed? I think it sho
Donn Denman 2016/08/23 23:21:46 Something needs to set the host, and I wondered wh
+ requestSurroundingText();
+ }
+
+ // ============================================================================================
+ // State handling
+ // ============================================================================================
+
+ @Override
+ protected void onSurroundingTextResponse(String surroundingTextSample, int sampleStart,
+ int focusStart, int focusEnd, int focusedWordStart, int focusedWordEnd) {
+ super.onSurroundingTextResponse(surroundingTextSample, sampleStart, focusStart, focusEnd,
+ focusedWordStart, focusedWordEnd);
+
+ String focusedWord = getFocusedWord();
+ if (!TextUtils.isEmpty(focusedWord) && focusStart == focusEnd) {
+ notifyContextReady();
+ } else {
+ dismissAction();
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698