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 eab9307b34348b61f74e87c51a8f155cf08a41cb..d6b0b12befc22e3975648a3aea09878b798a3107 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 |
@@ -23,6 +23,7 @@ public class ContextualSearchPanel extends ContextualSearchPanelAnimation |
UNDEFINED, |
CLOSED, |
PEEKED, |
+ PROMO, |
EXPANDED, |
MAXIMIZED; |
} |
@@ -145,7 +146,7 @@ public class ContextualSearchPanel extends ContextualSearchPanelAnimation |
} |
@Override |
- protected boolean isPromoAvailable() { |
+ protected boolean isPanelPromoAvailable() { |
return mManagementDelegate != null && mManagementDelegate.isOptOutPromoAvailable(); |
} |
@@ -153,7 +154,6 @@ public class ContextualSearchPanel extends ContextualSearchPanelAnimation |
public void onPromoButtonClick(boolean accepted) { |
super.onPromoButtonClick(accepted); |
mManagementDelegate.logPromoOutcome(); |
- setIsPromoActive(false); |
} |
@Override |
@@ -236,7 +236,19 @@ public class ContextualSearchPanel extends ContextualSearchPanelAnimation |
if (mManagementDelegate.isRunningInCompatibilityMode()) { |
mManagementDelegate.openResolvedSearchUrlInNewTab(); |
} else { |
- expandPanel(StateChangeReason.SEARCH_BAR_TAP); |
+ // NOTE(pedrosimonetti): If the promo is active and getPromoContentHeight() |
+ // returns -1 that means that the promo page hasn't finished loading, and |
+ // therefore it wasn't possible to calculate the height of the promo contents. |
+ // This will only happen if the user taps on a word that will trigger the |
+ // promo, and then quickly taps on the peeking bar, before the promo page |
+ // (which is local) finishes loading. |
+ // |
+ // TODO(pedrosimonetti): For now, we're simply ignoring the tap action in |
+ // that case. Consider implementing a better approach, where the Panel |
+ // would auto-expand once the height is calculated. |
+ if (!getIsPromoActive() || getPromoContentHeight() != -1) { |
+ expandPanel(StateChangeReason.SEARCH_BAR_TAP); |
+ } |
} |
} else if (isExpanded()) { |
peekPanel(StateChangeReason.SEARCH_BAR_TAP); |
@@ -386,6 +398,24 @@ public class ContextualSearchPanel extends ContextualSearchPanelAnimation |
} |
@Override |
+ public void setPromoContentHeight(float height) { |
+ // NOTE(pedrosimonetti): exposing superclass method to the interface. |
+ super.setPromoContentHeight(height); |
+ } |
+ |
+ @Override |
+ public void setShouldHidePromoHeader(boolean shouldHidePromoHeader) { |
+ // NOTE(pedrosimonetti): exposing superclass method to the interface. |
+ super.setShouldHidePromoHeader(shouldHidePromoHeader); |
+ } |
+ |
+ @Override |
+ public void animateAfterFirstRunSuccess() { |
+ // NOTE(pedrosimonetti): exposing superclass method to the interface. |
+ super.animateAfterFirstRunSuccess(); |
+ } |
+ |
+ @Override |
public void onLoadStarted() { |
setProgressBarCompletion(0); |
setProgressBarVisible(true); |