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

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

Issue 2928053002: [TTS] Robustness for VR: show with null selection. (Closed)
Patch Set: Check that we have a selection in the long-press case too. Cleanup and better document the test. Created 3 years, 6 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
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTapEventTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1b5e0a5a5c3cd7254639eef8af36f625e062f1de..53e907b32a93b9b1cdedf5326a7981434555abe1 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
@@ -431,9 +431,9 @@ public class ContextualSearchManager implements ContextualSearchManagementDelega
if (isTap && mPolicy.shouldPreviousTapResolve()) {
// Cache the native translate data, so JNI calls won't be made when time-critical.
mTranslateController.cacheNativeTranslateData();
- } else {
+ } else if (!TextUtils.isEmpty(selection)) {
boolean shouldPrefetch = mPolicy.shouldPrefetchSearchResult();
- mSearchRequest = createContextualSearchRequest(selection, null, null, shouldPrefetch);
+ mSearchRequest = new ContextualSearchRequest(selection, null, null, shouldPrefetch);
mTranslateController.forceAutoDetectTranslateUnlessDisabled(mSearchRequest);
mDidStartLoadingResolvedSearchRequest = false;
mSearchPanel.setSearchTerm(selection);
@@ -447,6 +447,10 @@ public class ContextualSearchManager implements ContextualSearchManagementDelega
RecordUserAction.record(isSingleWord ? "ContextualSearch.ManualRefineSingleWord"
: "ContextualSearch.ManualRefineMultiWord");
}
+ } else {
+ // The selection is no longer valid, so we can't build a request. Don't show the UX.
+ hideContextualSearch(StateChangeReason.UNKNOWN);
+ return;
}
mWereSearchResultsSeen = false;
@@ -503,18 +507,6 @@ public class ContextualSearchManager implements ContextualSearchManagementDelega
}
}
- /**
- * A method that can override the creation of a standard search request. This should only be
- * used for testing.
- * @param term The search term to create the request with.
- * @param altTerm An alternate search term.
- * @param isLowPriorityEnabled Whether the request can be made at low priority.
- */
- protected ContextualSearchRequest createContextualSearchRequest(
- String term, String altTerm, String mid, boolean isLowPriorityEnabled) {
- return new ContextualSearchRequest(term, altTerm, mid, isLowPriorityEnabled);
- }
-
/** Accessor for the {@code InfoBarContainer} currently attached to the {@code Tab}. */
private InfoBarContainer getInfoBarContainer() {
Tab tab = mActivity.getActivityTab();
@@ -710,7 +702,7 @@ public class ContextualSearchManager implements ContextualSearchManagementDelega
// appear in the user's history until the user views it). See crbug.com/406446.
boolean shouldPreload = !doPreventPreload && mPolicy.shouldPrefetchSearchResult();
mSearchRequest =
- createContextualSearchRequest(searchTerm, alternateTerm, mid, shouldPreload);
+ new ContextualSearchRequest(searchTerm, alternateTerm, mid, shouldPreload);
// Trigger translation, if enabled.
mTranslateController.forceTranslateIfNeeded(mSearchRequest, contextLanguage);
mDidStartLoadingResolvedSearchRequest = false;
@@ -948,8 +940,9 @@ public class ContextualSearchManager implements ContextualSearchManagementDelega
mWereSearchResultsSeen = true;
// If there's no current request, then either a search term resolution
// is in progress or we should do a verbatim search now.
- if (mSearchRequest == null && mPolicy.shouldCreateVerbatimRequest()) {
- mSearchRequest = createContextualSearchRequest(
+ if (mSearchRequest == null && mPolicy.shouldCreateVerbatimRequest()
+ && !TextUtils.isEmpty(mSelectionController.getSelectedText())) {
+ mSearchRequest = new ContextualSearchRequest(
mSelectionController.getSelectedText(), null, null, false);
mDidStartLoadingResolvedSearchRequest = false;
}
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTapEventTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698