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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/omnibox/LocationBarLayout.java

Issue 2159363002: Fix a crash on selecting a suggestion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Switch to equals Created 4 years, 5 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 | no next file » | 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/omnibox/LocationBarLayout.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/LocationBarLayout.java b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/LocationBarLayout.java
index 678ac61056b63460cc57ca3f0dbf23c09a49adec..cd4dd23c1827bc3ab5cdb522f3fde8e908e27848 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/LocationBarLayout.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/LocationBarLayout.java
@@ -1635,17 +1635,32 @@ public class LocationBarLayout extends FrameLayout implements OnClickListener,
String updatedUrl = null;
if (suggestion.getType() != OmniboxSuggestionType.VOICE_SUGGEST) {
- if (!skipCheck && selectedIndex >= mSuggestionItems.size()) {
- // Adding to track down the source of the crash in crbug.com/595395.
- throw new IllegalStateException("Selected index out of bounds");
+ int verifiedIndex = -1;
+ if (!skipCheck) {
+ if (mSuggestionItems.size() > selectedIndex
+ && mSuggestionItems.get(selectedIndex).getSuggestion() == suggestion) {
+ verifiedIndex = selectedIndex;
+ } else {
+ // Underlying omnibox results may have changed since the selection was made,
+ // find the suggestion item, if possible.
+ for (int i = 0; i < mSuggestionItems.size(); i++) {
+ if (suggestion.equals(mSuggestionItems.get(i).getSuggestion())) {
+ verifiedIndex = i;
+ break;
+ }
+ }
+ }
}
+ // If we do not have the suggestion as part of our results, skip the URL update.
+ if (verifiedIndex == -1) return suggestion.getUrl();
+
// TODO(mariakhomenko): Ideally we want to update match destination URL with new aqs
// for query in the omnibox and voice suggestions, but it's currently difficult to do.
long elapsedTimeSinceInputChange = mNewOmniboxEditSessionTimestamp > 0
? (SystemClock.elapsedRealtime() - mNewOmniboxEditSessionTimestamp) : -1;
updatedUrl = mAutocomplete.updateMatchDestinationUrlWithQueryFormulationTime(
- selectedIndex, elapsedTimeSinceInputChange);
+ verifiedIndex, elapsedTimeSinceInputChange);
}
return updatedUrl == null ? suggestion.getUrl() : updatedUrl;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698