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

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

Issue 1328663003: [Custom tab]Fix a bug that clicking media notification opens blank tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self review 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/media/ui/NotificationMediaPlaybackControls.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/media/ui/NotificationMediaPlaybackControls.java b/chrome/android/java/src/org/chromium/chrome/browser/media/ui/NotificationMediaPlaybackControls.java
index e70ee53b45fa5084ba02d18d640f651a82dc4a6d..24c811532b1cda056d2b5ee139b78f0cb8002f3e 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/media/ui/NotificationMediaPlaybackControls.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/media/ui/NotificationMediaPlaybackControls.java
@@ -269,6 +269,7 @@ public class NotificationMediaPlaybackControls {
mediaNotificationInfo.origin,
mediaNotificationInfo.tabId,
mediaNotificationInfo.isPrivate,
+ mediaNotificationInfo.isCustomTab,
mediaNotificationInfo.listener);
updateNotification();
}
@@ -301,6 +302,7 @@ public class NotificationMediaPlaybackControls {
mMediaNotificationInfo.origin,
mMediaNotificationInfo.tabId,
mMediaNotificationInfo.isPrivate,
+ mMediaNotificationInfo.isCustomTab,
mMediaNotificationInfo.listener);
updateNotification();
@@ -332,15 +334,24 @@ public class NotificationMediaPlaybackControls {
return title.startsWith("\u25B6") ? title.substring(1).trim() : title;
}
- private String getStatus() {
+ private String getStatusText() {
+ boolean isCustomTab = mMediaNotificationInfo.isCustomTab;
if (mMediaNotificationInfo.origin != null) {
- return mContext.getString(R.string.media_notification_link_text,
- mMediaNotificationInfo.origin);
+ return mContext.getString(isCustomTab ? R.string.media_notification_link_custom_tab
+ : R.string.media_notification_link_text, mMediaNotificationInfo.origin);
}
- return mContext.getString(R.string.media_notification_text_no_link);
+ return mContext.getString(isCustomTab ? R.string.media_notification_no_link_custom_tab
+ : R.string.media_notification_text_no_link);
}
+ /**
+ * @return An {@link PendingIntent} to bring chrome back to forground. If the tab id belongs to
gone 2015/09/02 21:55:17 nit: typos and incorrect description /** * @retu
Ian Wen 2015/09/02 22:00:14 Done.
+ * a custom tab, return an intent that stops the media.
+ */
private PendingIntent createContentIntent() {
+ if (mMediaNotificationInfo.isCustomTab) {
+ return mService.getPendingIntent(ListenerService.ACTION_STOP);
+ }
int tabId = mMediaNotificationInfo.tabId;
return PendingIntent.getActivity(
mContext, tabId, Tab.createBringTabToFrontIntent(tabId), 0);
@@ -397,7 +408,7 @@ public class NotificationMediaPlaybackControls {
RemoteViews contentView = createContentView();
contentView.setTextViewText(R.id.title, mMediaNotificationInfo.title);
- contentView.setTextViewText(R.id.status, getStatus());
+ contentView.setTextViewText(R.id.status, getStatusText());
if (mNotificationIcon != null) {
contentView.setImageViewBitmap(R.id.icon, mNotificationIcon);
} else {

Powered by Google App Engine
This is Rietveld 408576698