Chromium Code Reviews| Index: chrome/android/java_staging/src/org/chromium/chrome/browser/tab/ChromeTab.java |
| diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/tab/ChromeTab.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/tab/ChromeTab.java |
| index a811b72477a451f946e3fcc904bfa60c3044b53e..5fee84b121b9a90c57f6b4b995feab6add5a00ce 100644 |
| --- a/chrome/android/java_staging/src/org/chromium/chrome/browser/tab/ChromeTab.java |
| +++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/tab/ChromeTab.java |
| @@ -35,6 +35,7 @@ import org.chromium.chrome.browser.TabState; |
| import org.chromium.chrome.browser.TabUma; |
| import org.chromium.chrome.browser.TabUma.TabCreationState; |
| import org.chromium.chrome.browser.UrlConstants; |
| +import org.chromium.chrome.browser.UrlUtilities; |
| import org.chromium.chrome.browser.contextmenu.ChromeContextMenuPopulator; |
| import org.chromium.chrome.browser.contextmenu.ContextMenuParams; |
| import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator; |
| @@ -48,6 +49,8 @@ import org.chromium.chrome.browser.externalnav.ExternalNavigationHandler.Overrid |
| import org.chromium.chrome.browser.externalnav.ExternalNavigationParams; |
| import org.chromium.chrome.browser.fullscreen.FullscreenManager; |
| import org.chromium.chrome.browser.media.MediaNotificationService; |
| +import org.chromium.chrome.browser.media.ui.MediaInfo; |
| +import org.chromium.chrome.browser.media.ui.NotificationMediaPlaybackControls; |
| import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings; |
| import org.chromium.chrome.browser.ntp.NativePageAssassin; |
| import org.chromium.chrome.browser.ntp.NativePageFactory; |
| @@ -84,6 +87,8 @@ import org.chromium.ui.WindowOpenDisposition; |
| import org.chromium.ui.base.PageTransition; |
| import org.chromium.ui.base.WindowAndroid; |
| +import java.net.URI; |
| +import java.net.URISyntaxException; |
| import java.util.Locale; |
| /** |
| @@ -93,7 +98,7 @@ import java.util.Locale; |
| public class ChromeTab extends Tab { |
|
Ted C
2015/06/26 00:43:55
ChromeTab is going away, you should probably just
whywhat
2015/06/26 19:29:32
Ack.
|
| public static final int NTP_TAB_ID = -2; |
| - private static final String TAG = "ChromeTab"; |
| + private static final String TAG = "cr.ChromeTab"; |
| // URL didFailLoad error code. Should match the value in net_error_list.h. |
| public static final int BLOCKED_BY_ADMINISTRATOR = -22; |
| @@ -358,6 +363,21 @@ public class ChromeTab extends Tab { |
| */ |
| public class TabChromeWebContentsDelegateAndroidImpl |
| extends TabChromeWebContentsDelegateAndroid { |
| + private NotificationMediaPlaybackControls.Listener mControlsListener = |
|
Ted C
2015/06/26 00:43:55
I'd rather not see this logic within tab. I think
whywhat
2015/06/26 19:29:32
Ack. I'll need a tab id though to be able to come
Ted C
2015/06/30 04:56:13
Per my follow up comment, there is no reason you c
|
| + new NotificationMediaPlaybackControls.Listener() { |
| + @Override |
| + public void onPlay() { |
| + TabChromeWebContentsDelegateAndroidImpl |
| + .nativeOnMediaControlsResume(getWebContents()); |
| + } |
| + |
| + @Override |
| + public void onPause() { |
| + TabChromeWebContentsDelegateAndroidImpl |
| + .nativeOnMediaControlsPause(getWebContents()); |
| + } |
| + }; |
| + |
| /** |
| * This method is meant to be overridden by DocumentTab because the |
| * TabModelSelector returned by the activity is not correct. |
| @@ -490,6 +510,25 @@ public class ChromeTab extends Tab { |
| handleMediaKey(event); |
| } |
| + @Override |
| + public void updateMediaControls(boolean isControllable, boolean isPaused) { |
| + NotificationMediaPlaybackControls notificationControls = |
| + NotificationMediaPlaybackControls.getOrCreate(getApplicationContext()); |
| + if (!isControllable) { |
| + notificationControls.hide(getId()); |
| + notificationControls.removeListener(mControlsListener); |
| + return; |
| + } |
| + notificationControls.addListener(mControlsListener); |
| + String origin = getUrl(); |
| + try { |
| + origin = UrlUtilities.getOriginForDisplay(new URI(getUrl()), true); |
| + } catch (URISyntaxException e) { |
| + Log.e(TAG, "Wrong syntax for the tab URL when playing media. Showing the URL."); |
| + } |
| + notificationControls.show(new MediaInfo(getTitle(), isPaused, origin, getId())); |
| + } |
| + |
| /** |
| * Redispatches unhandled media keys. This allows bluetooth headphones with play/pause or |
| * other buttons to function correctly. |
| @@ -541,7 +580,6 @@ public class ChromeTab extends Tab { |
| private boolean hasAudibleAudio() { |
| return !isClosing() && super.nativeHasAudibleAudio(getWebContents()); |
| } |
| - |
| } |
| /** |
| @@ -886,6 +924,9 @@ public class ChromeTab extends Tab { |
| public void destroy() { |
| MediaNotificationService.updateMediaNotificationForTab( |
| getApplicationContext(), getId(), false, false, false, getUrl()); |
| + NotificationMediaPlaybackControls notificationControls = |
| + NotificationMediaPlaybackControls.getOrCreate(getApplicationContext()); |
| + notificationControls.hide(getId()); |
|
Ted C
2015/06/26 00:43:55
should this be removing the listener as well?
Sho
whywhat
2015/06/26 19:29:32
I've put the listener to MediaInfo so now there's
|
| super.destroy(); |
| } |
| }; |