diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarLayout.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarLayout.java index 9fb0ac938b0d0..408c57fa2a5bc 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarLayout.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarLayout.java @@ -15,6 +15,8 @@ import android.graphics.drawable.Drawable; import android.os.SystemClock; import android.util.AttributeSet; +import android.view.InputDevice; +import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; @@ -534,6 +536,21 @@ protected void updateTabCountVisuals(int numberOfTabs) { } */ protected void onDefaultSearchEngineChanged() { } + @Override + public boolean onGenericMotionEvent(MotionEvent event) { + // Consumes mouse button events on toolbar so they don't get leaked to content layer. + // See https://crbug.com/740855. + if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0 + && event.getToolType(0) == MotionEvent.TOOL_TYPE_MOUSE) { + int action = event.getActionMasked(); + if (action == MotionEvent.ACTION_BUTTON_PRESS + || action == MotionEvent.ACTION_BUTTON_RELEASE) { + return true; + } + } + return super.onGenericMotionEvent(event); + } + @Override public void getLocationBarContentRect(Rect outRect) { View container = getLocationBar().getContainerView();