Index: chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarTablet.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarTablet.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarTablet.java |
index 2ccefe712e54428283d129d44751f583a389ca6d..ce8f4462786c6d3395a1399fc9cd016a4c7461c8 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarTablet.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarTablet.java |
@@ -21,6 +21,7 @@ import org.chromium.chrome.R; |
import org.chromium.chrome.browser.ChromeSwitches; |
import org.chromium.chrome.browser.NavigationPopup; |
import org.chromium.chrome.browser.device.DeviceClassManager; |
+import org.chromium.chrome.browser.ntp.NewTabPage; |
import org.chromium.chrome.browser.omnibox.LocationBar; |
import org.chromium.chrome.browser.omnibox.LocationBarTablet; |
import org.chromium.chrome.browser.partnercustomizations.HomepageManager; |
@@ -69,6 +70,8 @@ public class ToolbarTablet extends ToolbarLayout implements OnClickListener { |
private boolean mShouldAnimateButtonVisibilityChange; |
private AnimatorSet mButtonVisibilityAnimators; |
+ private NewTabPage mVisibleNtp; |
+ |
/** |
* Constructs a ToolbarTablet object. |
* @param context The Context in which this View object is created. |
@@ -337,6 +340,37 @@ public class ToolbarTablet extends ToolbarLayout implements OnClickListener { |
} |
mUseLightColorAssets = incognito; |
} |
+ |
+ updateNtp(); |
+ } |
+ |
+ /** |
+ * Called when the currently visible New Tab Page changes. |
+ */ |
+ private void updateNtp() { |
+ NewTabPage newVisibleNtp = getToolbarDataProvider().getNewTabPageForCurrentTab(); |
+ if (mVisibleNtp == newVisibleNtp) return; |
+ |
+ if (mVisibleNtp != null) { |
+ mVisibleNtp.setSearchBoxScrollListener(null); |
+ } |
+ mVisibleNtp = newVisibleNtp; |
+ if (mVisibleNtp != null) { |
+ mVisibleNtp.setSearchBoxScrollListener(new NewTabPage.OnSearchBoxScrollListener() { |
+ @Override |
+ public void onNtpScrollChanged(float scrollPercentage) { |
+ // Fade the search box out in the first 40% of the scrolling transition. |
+ float alpha = Math.max(1f - scrollPercentage * 2.5f, 0f); |
+ mVisibleNtp.setSearchBoxAlpha(alpha); |
+ } |
+ }); |
+ } |
+ } |
+ |
+ @Override |
+ protected void onTabContentViewChanged() { |
+ super.onTabContentViewChanged(); |
+ updateNtp(); |
} |
@Override |