Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3153)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java

Issue 1343913002: Introduce Animated Logo to Chrome on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: respond to newt's comments Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java
index 2edbf6eaf404192a0a77899c15165133e9f358f4..f66e715b482a5b472430e770c36a5195a662a4fd 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java
@@ -10,6 +10,7 @@ import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
+import android.text.TextUtils;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -55,6 +56,8 @@ import org.chromium.ui.base.PageTransition;
import java.util.concurrent.TimeUnit;
+import jp.tomorrowkey.android.gifplayer.BaseGifImage;
+
/**
* Provides functionality when the user interacts with the NTP.
*/
@@ -87,6 +90,7 @@ public class NewTabPage
private boolean mSearchProviderHasLogo;
private final boolean mOptOutPromoShown;
private String mOnLogoClickUrl;
+ private String mAnimatedLogoUrl;
private FakeboxDelegate mFakeboxDelegate;
// The timestamp at which the constructor was called.
@@ -350,10 +354,22 @@ public class NewTabPage
}
@Override
- public void openLogoLink() {
+ public void onLogoClicked(boolean isAnimatedLogoShowing) {
if (mIsDestroyed) return;
- if (mOnLogoClickUrl == null) return;
- mTab.loadUrl(new LoadUrlParams(mOnLogoClickUrl, PageTransition.LINK));
+
+ boolean shouldDownloadAnimatedLogo = !isAnimatedLogoShowing
+ && !TextUtils.isEmpty(mAnimatedLogoUrl);
newt (away) 2015/09/23 20:38:43 I'd prefer to continue using simple null checks, r
Ian Wen 2015/09/23 21:59:51 (≧σ≦)
+ if (shouldDownloadAnimatedLogo) {
+ mLogoBridge.getAnimatedLogo(new LogoBridge.AnimatedLogoCallback() {
+ @Override
+ public void onGifDownloaded(byte[] bytes) {
+ if (mIsDestroyed) return;
+ mNewTabPageView.playAnimatedLogo(new BaseGifImage(bytes));
newt (away) 2015/09/23 20:38:43 Currently, we construct the BaseGifImage here, but
Ian Wen 2015/09/23 21:59:51 Done. Moved it to bridge. I dislike passing bytes
+ }
+ }, mAnimatedLogoUrl);
+ } else if (!TextUtils.isEmpty(mOnLogoClickUrl)) {
+ mTab.loadUrl(new LoadUrlParams(mOnLogoClickUrl, PageTransition.LINK));
+ }
}
@Override
@@ -364,6 +380,7 @@ public class NewTabPage
public void onLogoAvailable(Logo logo, boolean fromCache) {
if (mIsDestroyed) return;
mOnLogoClickUrl = logo != null ? logo.onClickUrl : null;
+ mAnimatedLogoUrl = logo != null ? logo.animagedLogoUrl : null;
logoObserver.onLogoAvailable(logo, fromCache);
}
};

Powered by Google App Engine
This is Rietveld 408576698