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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaSessionTabHelper.java

Issue 1847063005: [Media, UI] Change MediaNotification style to MediaStyle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests and rebase Created 4 years, 8 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/media/ui/MediaSessionTabHelper.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaSessionTabHelper.java b/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaSessionTabHelper.java
index 56e26b285f0398969b2b19491324df1a23e8e505..c89c030a9b26f5a1c2e470a46592377d21ec09a3 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaSessionTabHelper.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaSessionTabHelper.java
@@ -5,6 +5,7 @@
package org.chromium.chrome.browser.media.ui;
import android.app.Activity;
+import android.graphics.Bitmap;
import android.media.AudioManager;
import android.text.TextUtils;
@@ -34,6 +35,8 @@ public class MediaSessionTabHelper {
private static final String UNICODE_PLAY_CHARACTER = "\u25B6";
private Tab mTab;
+ private Bitmap mFavicon = null;
+ private String mOrigin = null;
private WebContents mWebContents;
private WebContentsObserver mWebContentsObserver;
private int mPreviousVolumeControlStream = AudioManager.USE_DEFAULT_STREAM_TYPE;
@@ -93,13 +96,6 @@ public class MediaSessionTabHelper {
hideNotification();
return;
}
- String origin = mTab.getUrl();
- try {
- origin = UrlUtilities.formatUrlForSecurityDisplay(new URI(origin), true);
- } catch (URISyntaxException e) {
- Log.e(TAG, "Unable to parse the origin from the URL. "
- + "Showing the full URL instead.");
- }
mFallbackMetadata = null;
@@ -116,10 +112,11 @@ public class MediaSessionTabHelper {
mNotificationInfoBuilder = new MediaNotificationInfo.Builder()
.setMetadata(metadata)
.setPaused(isPaused)
- .setOrigin(origin)
+ .setOrigin(mOrigin)
.setTabId(mTab.getId())
.setPrivate(mTab.isIncognito())
.setIcon(R.drawable.audio_playing)
+ .setLargeIcon(mFavicon)
.setActions(MediaNotificationInfo.ACTION_PLAY_PAUSE
| MediaNotificationInfo.ACTION_SWIPEAWAY)
.setContentIntent(Tab.createBringTabToFrontIntent(mTab.getId()))
@@ -159,6 +156,41 @@ public class MediaSessionTabHelper {
}
@Override
+ public void onFaviconUpdated(Tab tab, Bitmap icon) {
+ assert tab == mTab;
+ updateFavicon(icon);
mlamouri (slow - plz ping) 2016/04/07 19:47:34 Maybe `updateFavicon` could return a boolean sayin
Zhiqiang Zhang (Slow) 2016/04/11 09:26:28 Done.
+
+ if (mNotificationInfoBuilder == null) return;
+
+ mNotificationInfoBuilder.setLargeIcon(mFavicon);
+ MediaNotificationManager.show(ApplicationStatus.getApplicationContext(),
+ mNotificationInfoBuilder.build());
+ }
+
+ @Override
+ public void onUrlUpdated(Tab tab) {
+ assert tab == mTab;
+
+ String origin = mTab.getUrl();
+ try {
+ origin = UrlUtilities.formatUrlForSecurityDisplay(new URI(origin), true);
+ } catch (URISyntaxException e) {
+ Log.e(TAG, "Unable to parse the origin from the URL. "
+ + "Using the full URL instead.");
+ }
+
+ if (mOrigin != null && mOrigin.equals(origin)) return;
+ mOrigin = origin;
+ mFavicon = null;
+
+ if (mNotificationInfoBuilder == null) return;
+
+ mNotificationInfoBuilder.setLargeIcon(mFavicon);
mlamouri (slow - plz ping) 2016/04/07 19:47:34 Shouldn't you call mNotificationInfoBuilder.setOri
Zhiqiang Zhang (Slow) 2016/04/11 09:26:28 I think not. mNotificationInfoBuilder can be null
+ MediaNotificationManager.show(ApplicationStatus.getApplicationContext(),
+ mNotificationInfoBuilder.build());
+ }
+
+ @Override
public void onTitleUpdated(Tab tab) {
assert tab == mTab;
if (mNotificationInfoBuilder == null || mFallbackMetadata == null) return;
@@ -240,4 +272,15 @@ public class MediaSessionTabHelper {
return windowAndroid.getActivity().get();
}
+
+ private void updateFavicon(Bitmap icon) {
+ if (icon == null) return;
+ if (icon.getWidth() < 112 || icon.getHeight() < 112) return;
mlamouri (slow - plz ping) 2016/04/07 19:47:34 Why 112px instead of the values from the design do
Zhiqiang Zhang (Slow) 2016/04/11 09:26:28 Done.
+ if (mFavicon != null
+ && (icon.getWidth() < mFavicon.getWidth()
+ || icon.getHeight() < mFavicon.getHeight())) {
+ return;
+ }
+ mFavicon = icon;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698