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

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

Issue 1516273004: Fix an NPE in location bar suggestion showing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 f959c8a0ed72f54e918060dd824bfb8b9f5600b4..2c7a9bb81a68d2f2a9b288dc5c497090aa437116 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
@@ -1410,7 +1410,11 @@ public class LocationBarLayout extends FrameLayout implements OnClickListener,
.addOnLayoutChangeListener(suggestionListResizer);
mSuggestionList = new OmniboxSuggestionsList(getContext());
+
+ // Ensure the results container is initialized and add the suggestion list to it.
+ initOmniboxResultsContainer();
mOmniboxResultsContainer.addView(mSuggestionList);
+
// Start with visibility GONE to ensure that show() is called. http://crbug.com/517438
mSuggestionList.setVisibility(GONE);
mSuggestionList.setAdapter(mSuggestionListAdapter);
@@ -2077,28 +2081,32 @@ public class LocationBarLayout extends FrameLayout implements OnClickListener,
return currentTab != null ? currentTab.getContentViewCore() : null;
}
+ private void initOmniboxResultsContainer() {
+ if (mOmniboxResultsContainer != null) return;
+
+ ViewStub overlayStub =
+ (ViewStub) getRootView().findViewById(R.id.omnibox_results_container_stub);
+ mOmniboxResultsContainer = (ViewGroup) overlayStub.inflate();
+ mOmniboxResultsContainer.setBackgroundColor(CONTENT_OVERLAY_COLOR);
+ // Prevent touch events from propagating down to the chrome view.
+ mOmniboxResultsContainer.setOnTouchListener(new OnTouchListener() {
+ @Override
+ @SuppressLint("ClickableViewAccessibility")
+ public boolean onTouch(View v, MotionEvent event) {
+ int action = event.getActionMasked();
+ if (action == MotionEvent.ACTION_CANCEL
+ || action == MotionEvent.ACTION_UP) {
+ mUrlBar.clearFocus();
+ updateOmniboxResultsContainerBackground(false);
+ }
+ return true;
+ }
+ });
+ }
+
private void updateOmniboxResultsContainer() {
if (mSuggestionsShown || mUrlHasFocus) {
- if (mOmniboxResultsContainer == null) {
- ViewStub overlayStub =
- (ViewStub) getRootView().findViewById(R.id.omnibox_results_container_stub);
- mOmniboxResultsContainer = (ViewGroup) overlayStub.inflate();
- mOmniboxResultsContainer.setBackgroundColor(CONTENT_OVERLAY_COLOR);
- // Prevent touch events from propagating down to the chrome view.
- mOmniboxResultsContainer.setOnTouchListener(new OnTouchListener() {
- @Override
- @SuppressLint("ClickableViewAccessibility")
- public boolean onTouch(View v, MotionEvent event) {
- int action = event.getActionMasked();
- if (action == MotionEvent.ACTION_CANCEL
- || action == MotionEvent.ACTION_UP) {
- mUrlBar.clearFocus();
- updateOmniboxResultsContainerBackground(false);
- }
- return true;
- }
- });
- }
+ initOmniboxResultsContainer();
updateOmniboxResultsContainerVisibility(true);
} else if (mOmniboxResultsContainer != null) {
updateOmniboxResultsContainerBackground(false);
« 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