| Index: chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java
|
| index 16b0ce0348d24201cc7586e16bee99558dd0d450..4619caf04ad77dcf4802e3dc5d708cb6e1ade3c0 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java
|
| @@ -7,7 +7,6 @@ package org.chromium.chrome.browser.compositor.bottombar.contextualsearch;
|
| import android.content.Context;
|
| import android.os.Handler;
|
|
|
| -import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.ContextualSearchPanel.StateChangeReason;
|
| import org.chromium.chrome.browser.compositor.layouts.LayoutUpdateHost;
|
| import org.chromium.chrome.browser.contextualsearch.ContextualSearchManagementDelegate;
|
|
|
| @@ -48,7 +47,8 @@ public class ContextualSearchPanel extends ContextualSearchPanelAnimation
|
| SWIPE,
|
| FLING,
|
| OPTIN,
|
| - OPTOUT;
|
| + OPTOUT,
|
| + CLOSE_BUTTON;
|
| }
|
|
|
| /**
|
| @@ -243,7 +243,11 @@ public class ContextualSearchPanel extends ContextualSearchPanelAnimation
|
| } else if (isExpanded()) {
|
| peekPanel(StateChangeReason.SEARCH_BAR_TAP);
|
| } else if (isMaximized()) {
|
| - mManagementDelegate.promoteToTab(true);
|
| + if (!isCloseIconVisible()) {
|
| + mManagementDelegate.promoteToTab(true);
|
| + } else if (isCoordinateInsideCloseButton(x, y)) {
|
| + closePanel(StateChangeReason.CLOSE_BUTTON, true);
|
| + }
|
| }
|
| }
|
| }
|
| @@ -285,6 +289,17 @@ public class ContextualSearchPanel extends ContextualSearchPanelAnimation
|
| }
|
|
|
| /**
|
| + * @param x The x coordinate in dp.
|
| + * @param y The y coordinate in dp.
|
| + * @return Whether the given |x| |y| coordinate is inside the close button.
|
| + */
|
| + private boolean isCoordinateInsideCloseButton(float x, float y) {
|
| + boolean isInY = y >= getCloseIconY() && y <= (getCloseIconY() + getCloseIconDimension());
|
| + boolean isInX = x >= getCloseIconX() && x <= (getCloseIconX() + getCloseIconDimension());
|
| + return isInY && isInX;
|
| + }
|
| +
|
| + /**
|
| * @return Whether the Panel is in its expanded state.
|
| */
|
| protected boolean isExpanded() {
|
|
|