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

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

Issue 2114723002: Fix a crash where we tried to update match we didn't have. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update comment Created 4 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 | 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 0ec1862121d60ad01e2cf0b73b2c401e2f5ebf02..9b5fc672749471639ad6377016a62669a2a92527 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
@@ -329,6 +329,7 @@ public class LocationBarLayout extends FrameLayout implements OnClickListener,
private void findMatchAndLoadUrl(String urlText) {
int suggestionMatchPosition;
OmniboxSuggestion suggestionMatch;
+ boolean skipOutOfBoundsCheck = false;
if (mSuggestionList != null
&& mSuggestionList.isShown()
@@ -352,13 +353,16 @@ public class LocationBarLayout extends FrameLayout implements OnClickListener,
// from the autocomplete controller.
suggestionMatch = mAutocomplete.classify(urlText);
suggestionMatchPosition = 0;
+ // Classify matches don't propagate to java, so skip the OOB check.
+ skipOutOfBoundsCheck = true;
// If urlText couldn't be classified, bail.
if (suggestionMatch == null) return;
}
String suggestionMatchUrl = updateSuggestionUrlIfNeeded(suggestionMatch,
- suggestionMatchPosition);
+ suggestionMatchPosition, skipOutOfBoundsCheck);
+
// It's important to use the page transition from the suggestion or we might end
// up saving generated URLs as typed URLs, which would then pollute the subsequent
@@ -1498,7 +1502,8 @@ public class LocationBarLayout extends FrameLayout implements OnClickListener,
@Override
public void onSelection(OmniboxSuggestion suggestion, int position) {
mSuggestionSelectionInProgress = true;
- String suggestionMatchUrl = updateSuggestionUrlIfNeeded(suggestion, position);
+ String suggestionMatchUrl = updateSuggestionUrlIfNeeded(
+ suggestion, position, false);
loadUrlFromOmniboxMatch(suggestionMatchUrl, suggestion.getTransition(), position,
suggestion.getType());
hideSuggestions();
@@ -1608,9 +1613,11 @@ public class LocationBarLayout extends FrameLayout implements OnClickListener,
*
* @param suggestion The chosen omnibox suggestion.
* @param selectedIndex The index of the chosen omnibox suggestion.
+ * @param skipCheck Whether to skip an out of bounds check.
* @return The url to navigate to.
*/
- private String updateSuggestionUrlIfNeeded(OmniboxSuggestion suggestion, int selectedIndex) {
+ private String updateSuggestionUrlIfNeeded(OmniboxSuggestion suggestion, int selectedIndex,
+ boolean skipCheck) {
// Only called once we have suggestions, and don't have a listener though which we can
// receive suggestions until the native side is ready, so this is safe
assert mNativeInitialized
@@ -1618,7 +1625,7 @@ public class LocationBarLayout extends FrameLayout implements OnClickListener,
String updatedUrl = null;
if (suggestion.getType() != OmniboxSuggestionType.VOICE_SUGGEST) {
- if (selectedIndex >= mSuggestionItems.size()) {
+ 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");
}
« 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