OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.media.ui; | 5 package org.chromium.chrome.browser.media.ui; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.content.Intent; | 8 import android.content.Intent; |
9 import android.graphics.Bitmap; | 9 import android.graphics.Bitmap; |
10 import android.media.AudioManager; | 10 import android.media.AudioManager; |
(...skipping 28 matching lines...) Expand all Loading... |
39 * media actions from the controls to the {@link org.chromium.content.browser.Me
diaSession} | 39 * media actions from the controls to the {@link org.chromium.content.browser.Me
diaSession} |
40 */ | 40 */ |
41 public class MediaSessionTabHelper implements MediaImageCallback { | 41 public class MediaSessionTabHelper implements MediaImageCallback { |
42 private static final String TAG = "MediaSession"; | 42 private static final String TAG = "MediaSession"; |
43 | 43 |
44 private static final String UNICODE_PLAY_CHARACTER = "\u25B6"; | 44 private static final String UNICODE_PLAY_CHARACTER = "\u25B6"; |
45 private static final int MINIMAL_FAVICON_SIZE = 114; | 45 private static final int MINIMAL_FAVICON_SIZE = 114; |
46 private static final int HIDE_NOTIFICATION_DELAY_MILLIS = 1000; | 46 private static final int HIDE_NOTIFICATION_DELAY_MILLIS = 1000; |
47 | 47 |
48 private Tab mTab; | 48 private Tab mTab; |
49 private Bitmap mPageMediaImage = null; | 49 private Bitmap mPageMediaImage; |
50 private Bitmap mFavicon = null; | 50 private Bitmap mFavicon; |
51 private Bitmap mCurrentMediaImage = null; | 51 private Bitmap mCurrentMediaImage; |
52 private String mOrigin = null; | 52 private String mOrigin; |
53 private MediaSessionObserver mMediaSessionObserver; | 53 private MediaSessionObserver mMediaSessionObserver; |
54 private int mPreviousVolumeControlStream = AudioManager.USE_DEFAULT_STREAM_T
YPE; | 54 private int mPreviousVolumeControlStream = AudioManager.USE_DEFAULT_STREAM_T
YPE; |
55 private MediaNotificationInfo.Builder mNotificationInfoBuilder = null; | 55 private MediaNotificationInfo.Builder mNotificationInfoBuilder; |
56 // The fallback title if |mPageMetadata| is null or its title is empty. | 56 // The fallback title if |mPageMetadata| is null or its title is empty. |
57 private String mFallbackTitle = null; | 57 private String mFallbackTitle; |
58 // The metadata set by the page. | 58 // The metadata set by the page. |
59 private MediaMetadata mPageMetadata = null; | 59 private MediaMetadata mPageMetadata; |
60 // The currently showing metadata. | 60 // The currently showing metadata. |
61 private MediaMetadata mCurrentMetadata = null; | 61 private MediaMetadata mCurrentMetadata; |
62 private MediaImageManager mMediaImageManager = null; | 62 private MediaImageManager mMediaImageManager; |
63 private Set<Integer> mMediaSessionActions = null; | 63 private Set<Integer> mMediaSessionActions; |
64 private Handler mHandler; | 64 private Handler mHandler; |
65 // The delayed task to hide notification. Hiding notification can be immedia
te or delayed. | 65 // The delayed task to hide notification. Hiding notification can be immedia
te or delayed. |
66 // Delayed hiding will schedule this delayed task to |mHandler|. The task wi
ll be canceled when | 66 // Delayed hiding will schedule this delayed task to |mHandler|. The task wi
ll be canceled when |
67 // showing or immediate hiding. | 67 // showing or immediate hiding. |
68 private Runnable mHideNotificationDelayedTask; | 68 private Runnable mHideNotificationDelayedTask; |
69 | 69 |
70 @VisibleForTesting | 70 @VisibleForTesting |
71 @Nullable | 71 @Nullable |
72 MediaSessionObserver getMediaSessionObserverForTesting() { | 72 MediaSessionObserver getMediaSessionObserverForTesting() { |
73 return mMediaSessionObserver; | 73 return mMediaSessionObserver; |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 } | 468 } |
469 | 469 |
470 private Bitmap getNotificationImage() { | 470 private Bitmap getNotificationImage() { |
471 return (mPageMediaImage != null) ? mPageMediaImage : mFavicon; | 471 return (mPageMediaImage != null) ? mPageMediaImage : mFavicon; |
472 } | 472 } |
473 | 473 |
474 private boolean isNotificationHiddingOrHidden() { | 474 private boolean isNotificationHiddingOrHidden() { |
475 return mNotificationInfoBuilder == null; | 475 return mNotificationInfoBuilder == null; |
476 } | 476 } |
477 } | 477 } |
OLD | NEW |