Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 /** | 5 /** |
| 6 * This Polymer element shows media controls for a route that is currently cast | 6 * This Polymer element shows media controls for a route that is currently cast |
| 7 * to a device. | 7 * to a device. |
| 8 * @implements {RouteControlsInterface} | 8 * @implements {RouteControlsInterface} |
| 9 */ | 9 */ |
| 10 Polymer({ | 10 Polymer({ |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 /** | 33 /** |
| 34 * The volume shown in the volume control, between 0 and 1. | 34 * The volume shown in the volume control, between 0 and 1. |
| 35 * @private {number} | 35 * @private {number} |
| 36 */ | 36 */ |
| 37 displayedVolume_: { | 37 displayedVolume_: { |
| 38 type: Number, | 38 type: Number, |
| 39 value: 0, | 39 value: 0, |
| 40 }, | 40 }, |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * The time when the initial media status was loaded. | |
| 44 * @private {?Date} | |
| 45 */ | |
| 46 initialLoadTime_: { | |
| 47 type: Date, | |
| 48 value: null, | |
| 49 }, | |
| 50 | |
| 51 /** | |
| 43 * Set to true when the user is dragging the seek bar. Updates for the | 52 * Set to true when the user is dragging the seek bar. Updates for the |
| 44 * current time from the browser will be ignored when set to true. | 53 * current time from the browser will be ignored when set to true. |
| 45 * @private {boolean} | 54 * @private {boolean} |
| 46 */ | 55 */ |
| 47 isSeeking_: { | 56 isSeeking_: { |
| 48 type: Boolean, | 57 type: Boolean, |
| 49 value: false, | 58 value: false, |
| 50 }, | 59 }, |
| 51 | 60 |
| 52 /** | 61 /** |
| 53 * Set to true when the user is dragging the volume bar. Volume updates from | 62 * Set to true when the user is dragging the volume bar. Volume updates from |
| 54 * the browser will be ignored when set to true. | 63 * the browser will be ignored when set to true. |
| 55 * @private {boolean} | 64 * @private {boolean} |
| 56 */ | 65 */ |
| 57 isVolumeChanging_: { | 66 isVolumeChanging_: { |
| 58 type: Boolean, | 67 type: Boolean, |
| 59 value: false, | 68 value: false, |
| 60 }, | 69 }, |
| 61 | 70 |
| 62 /** | 71 /** |
| 72 * The time when the route details view was opened. | |
| 73 * @type {?Date} | |
| 74 */ | |
| 75 routeDetailsOpenTime: { | |
| 76 type: Date, | |
| 77 value: null, | |
| 78 observer: 'onRouteDetailsOpenTimeSet_', | |
|
imcheng
2017/06/02 23:53:13
We can use maybeReportLoadTime_ here. Then we won'
takumif
2017/06/03 01:31:14
Right, the observer is no longer necessary. Remove
| |
| 79 }, | |
| 80 | |
| 81 /** | |
| 63 * The status of the media route shown. | 82 * The status of the media route shown. |
| 64 * @type {!media_router.RouteStatus} | 83 * @type {!media_router.RouteStatus} |
| 65 */ | 84 */ |
| 66 routeStatus: { | 85 routeStatus: { |
| 67 type: Object, | 86 type: Object, |
| 68 observer: 'onRouteStatusChange_', | 87 observer: 'onRouteStatusChange_', |
| 69 value: new media_router.RouteStatus( | 88 value: new media_router.RouteStatus( |
| 70 '', '', false, false, false, false, false, false, 0, 0, 0), | 89 '', '', false, false, false, false, false, false, 0, 0, 0), |
| 71 }, | 90 }, |
| 72 }, | 91 }, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 * @return {string} Localized title for the play/pause button. | 160 * @return {string} Localized title for the play/pause button. |
| 142 * | 161 * |
| 143 * @private | 162 * @private |
| 144 */ | 163 */ |
| 145 getPlayPauseTitle_: function(routeStatus) { | 164 getPlayPauseTitle_: function(routeStatus) { |
| 146 return routeStatus.isPaused ? this.i18n('playTitle') : | 165 return routeStatus.isPaused ? this.i18n('playTitle') : |
| 147 this.i18n('pauseTitle'); | 166 this.i18n('pauseTitle'); |
| 148 }, | 167 }, |
| 149 | 168 |
| 150 /** | 169 /** |
| 170 * Notify the browser the time it took from opening the route details view to | |
| 171 * loading the route controller if the data is available. | |
| 172 * | |
| 173 * @private | |
| 174 */ | |
| 175 maybeReportLoadTime_: function() { | |
| 176 if (this.initialLoadTime_ && this.routeDetailsOpenTime) { | |
| 177 var timeMs = this.initialLoadTime_ - this.routeDetailsOpenTime; | |
| 178 media_router.browserApi.reportWebUIRouteControllerLoaded(timeMs); | |
| 179 } | |
| 180 }, | |
| 181 | |
| 182 /** | |
| 151 * Called when the user toggles the mute status of the media. Sends a mute or | 183 * Called when the user toggles the mute status of the media. Sends a mute or |
| 152 * unmute command to the browser. | 184 * unmute command to the browser. |
| 153 * | 185 * |
| 154 * @private | 186 * @private |
| 155 */ | 187 */ |
| 156 onMuteUnmute_: function() { | 188 onMuteUnmute_: function() { |
| 157 media_router.browserApi.setCurrentMediaMute(!this.routeStatus.isMuted); | 189 media_router.browserApi.setCurrentMediaMute(!this.routeStatus.isMuted); |
| 158 }, | 190 }, |
| 159 | 191 |
| 160 /** | 192 /** |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 174 /** | 206 /** |
| 175 * Resets the route controls. Called when the route details view is closed. | 207 * Resets the route controls. Called when the route details view is closed. |
| 176 */ | 208 */ |
| 177 reset: function() { | 209 reset: function() { |
| 178 this.routeStatus = new media_router.RouteStatus( | 210 this.routeStatus = new media_router.RouteStatus( |
| 179 '', '', false, false, false, false, false, false, 0, 0, 0); | 211 '', '', false, false, false, false, false, false, 0, 0, 0); |
| 180 media_router.ui.setRouteControls(null); | 212 media_router.ui.setRouteControls(null); |
| 181 }, | 213 }, |
| 182 | 214 |
| 183 /** | 215 /** |
| 216 * Called when |routeDetailsOpenTime| is set. | |
| 217 * | |
| 218 * @private | |
| 219 */ | |
| 220 onRouteDetailsOpenTimeSet_: function() { | |
| 221 this.maybeReportLoadTime_(); | |
| 222 }, | |
| 223 | |
| 224 /** | |
| 184 * Updates seek and volume bars if the user is not currently dragging on | 225 * Updates seek and volume bars if the user is not currently dragging on |
| 185 * them. | 226 * them. |
| 186 * @param {!media_router.RouteStatus} newRouteStatus | 227 * @param {!media_router.RouteStatus} newRouteStatus |
| 187 * | 228 * |
| 188 * @private | 229 * @private |
| 189 */ | 230 */ |
| 190 onRouteStatusChange_: function(newRouteStatus) { | 231 onRouteStatusChange_: function(newRouteStatus) { |
| 191 if (!this.isSeeking_) { | 232 if (!this.isSeeking_) { |
| 192 this.displayedCurrentTime_ = newRouteStatus.currentTime; | 233 this.displayedCurrentTime_ = newRouteStatus.currentTime; |
| 193 } | 234 } |
| 194 if (!this.isVolumeChanging_) { | 235 if (!this.isVolumeChanging_) { |
| 195 this.displayedVolume_ = newRouteStatus.volume; | 236 this.displayedVolume_ = newRouteStatus.volume; |
| 196 } | 237 } |
| 197 if (newRouteStatus.description !== '') { | 238 if (newRouteStatus.description !== '') { |
| 198 this.displayedDescription_ = newRouteStatus.description; | 239 this.displayedDescription_ = newRouteStatus.description; |
| 199 } | 240 } |
| 241 if (!this.initialLoadTime_) { | |
| 242 this.initialLoadTime_ = new Date(); | |
|
imcheng
2017/06/02 23:53:13
Date.now()
takumif
2017/06/03 01:31:14
Done.
| |
| 243 this.maybeReportLoadTime_(); | |
| 244 } | |
| 200 }, | 245 }, |
| 201 | 246 |
| 202 /** | 247 /** |
| 203 * Called when the route is updated. Updates the description shown if it has | 248 * Called when the route is updated. Updates the description shown if it has |
| 204 * not been provided by status updates. | 249 * not been provided by status updates. |
| 205 * @param {!media_router.Route} route | 250 * @param {!media_router.Route} route |
| 206 */ | 251 */ |
| 207 onRouteUpdated: function(route) { | 252 onRouteUpdated: function(route) { |
| 208 if (this.routeStatus.description === '') { | 253 if (this.routeStatus.description === '') { |
| 209 this.displayedDescription_ = | 254 this.displayedDescription_ = |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 * @param {!Event} e | 297 * @param {!Event} e |
| 253 * | 298 * |
| 254 * @private | 299 * @private |
| 255 */ | 300 */ |
| 256 onVolumeChangeStart_: function(e) { | 301 onVolumeChangeStart_: function(e) { |
| 257 this.isVolumeChanging_ = true; | 302 this.isVolumeChanging_ = true; |
| 258 var target = /** @type {{immediateValue: number}} */ (e.target); | 303 var target = /** @type {{immediateValue: number}} */ (e.target); |
| 259 this.volumeSliderValue_ = target.immediateValue; | 304 this.volumeSliderValue_ = target.immediateValue; |
| 260 }, | 305 }, |
| 261 }); | 306 }); |
| OLD | NEW |