| 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 4e61575465170c28683030d305f82a61c8458d8e..dd27eb5a348b6694b942383d1dd42eaa7d3bef88 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,11 +243,13 @@ public class ContextualSearchPanel extends ContextualSearchPanelAnimation
|
| } else if (isExpanded()) {
|
| peekPanel(StateChangeReason.SEARCH_BAR_TAP);
|
| } else if (isMaximized()) {
|
| - // TODO(twellington): check if click happened inside close button,
|
| - // using ContextualSearchPanelFeatures.isCloseButtonAvailable().
|
| if (ContextualSearchPanelFeatures.isSearchTermRefiningAvailable()) {
|
| mManagementDelegate.promoteToTab(true);
|
| }
|
| + if (ContextualSearchPanelFeatures.isCloseButtonAvailable()
|
| + && isCoordinateInsideCloseButton(x, y)) {
|
| + closePanel(StateChangeReason.CLOSE_BUTTON, true);
|
| + }
|
| }
|
| }
|
| }
|
| @@ -289,6 +291,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() {
|
|
|