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

Unified Diff: chrome/browser/resources/media_router/media_router.js

Issue 2725503002: [Media Router] Custom Controls 4 - Implement details view WebUI (Closed)
Patch Set: . Created 3 years, 10 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/browser/resources/media_router/media_router.js
diff --git a/chrome/browser/resources/media_router/media_router.js b/chrome/browser/resources/media_router/media_router.js
index d3bc326a7711b413c338d86e05f31cee48b1c46b..7fdf1b7f6beb18ab42831cffe69b16c6a1c1dcb9 100644
--- a/chrome/browser/resources/media_router/media_router.js
+++ b/chrome/browser/resources/media_router/media_router.js
@@ -38,6 +38,7 @@ cr.define('media_router', function() {
onChangeRouteSourceClick);
container.addEventListener('close-dialog', onCloseDialog);
container.addEventListener('close-route', onCloseRoute);
+ container.addEventListener('close-route-details', onRouteDetailsClosed);
container.addEventListener('create-route', onCreateRoute);
container.addEventListener('issue-action-click', onIssueActionClick);
container.addEventListener('join-route-click', onJoinRouteClick);
@@ -45,6 +46,9 @@ cr.define('media_router', function() {
onNavigateToDetails);
container.addEventListener('navigate-to-cast-mode-list',
onNavigateToCastMode);
+ container.addEventListener('open-route-details', onRouteDetailsOpened);
+ container.addEventListener('pause-route', onPauseRoute);
imcheng 2017/03/02 02:25:47 While I appreciate the isolation of browser API fr
takumif 2017/03/08 23:34:58 It looks like the layer of event firing is there f
imcheng 2017/03/11 21:57:39 It looks like we should be able to define chrome.b
takumif 2017/03/16 20:16:02 Done.
+ container.addEventListener('play-route', onPlayRoute);
container.addEventListener('report-filter', onFilter);
container.addEventListener('report-initial-action', onInitialAction);
container.addEventListener('report-initial-action-close',
@@ -59,8 +63,11 @@ cr.define('media_router', function() {
onRequestInitialData);
container.addEventListener('search-sinks-and-create-route',
onSearchSinksAndCreateRoute);
+ container.addEventListener('seek-route', onSeekRoute);
+ container.addEventListener('set-route-volume', onSetRouteVolume);
container.addEventListener('show-initial-state', onShowInitialState);
container.addEventListener('sink-click', onSinkClick);
+ container.addEventListener('set-route-mute', onSetRouteMute);
window.addEventListener('blur', onWindowBlur);
}
@@ -131,6 +138,20 @@ cr.define('media_router', function() {
}
/**
+ * Sends a command to set the volume of the route shown in the route details
+ * view. Called when the user manipulates the volume slider.
+ *
+ * @param {!Event} event
+ * Parameters in |event|.detail:
+ * volume - The volume between 0 and 1.
+ */
+ function onSetRouteVolume(event) {
+ /** @type {{volume: number}} */
+ var detail = event.detail;
+ media_router.browserApi.setRouteVolume(detail.volume);
+ }
+
+ /**
* Closes the dialog.
* Called when the user clicks the close button on the dialog. Reports
* whether the user closed the dialog via the ESC key.
@@ -216,7 +237,7 @@ cr.define('media_router', function() {
* selectedCastModeValue - cast mode selected by the user.
*/
function onCreateRoute(event) {
- /** @type {{sinkId: string, selectedCastModeValue, number}} */
+ /** @type {{sinkId: string, selectedCastModeValue: number}} */
var detail = event.detail;
media_router.browserApi.requestRoute(detail.sinkId,
detail.selectedCastModeValue);
@@ -282,6 +303,22 @@ cr.define('media_router', function() {
}
/**
+ * Sends a command to pause the route shown in the route details view.
+ * Called when the user clicks on the pause button.
+ */
+ function onPauseRoute() {
+ media_router.browserApi.pauseRoute();
+ }
+
+ /**
+ * Sends a command to play the route shown in the route details view.
+ * Called when the user clicks on the play button.
+ */
+ function onPlayRoute() {
+ media_router.browserApi.playRoute();
+ }
+
+ /**
* Reports whether or not the route creation was successful.
*
* @param {!Event} event
@@ -318,6 +355,54 @@ cr.define('media_router', function() {
}
/**
+ * Reports that the route details view has been closed.
+ */
+ function onRouteDetailsClosed() {
+ media_router.browserApi.onRouteDetailsClosed();
+ }
+
+ /**
+ * Reports that the route details view has been opened.
+ *
+ * @param {!Event} event
+ * Parameters in |event|.detail:
+ * routeId - The ID of the media route shown in the details view.
+ */
+ function onRouteDetailsOpened(event) {
+ /** @type {{routeId: string}} */
+ var detail = event.detail;
+ media_router.browserApi.onRouteDetailsOpened(detail.routeId);
+ }
+
+ /**
+ * Sends a command to seek the route shown in the route details view. Called
+ * when the user manipulates the seek slider.
+ *
+ * @param {!Event} event
+ * Parameters in |event|.detail:
+ * mute - whether to mute the route.
+ */
+ function onSeekRoute(event) {
+ /** @type {{time: number}} */
+ var detail = event.detail;
+ media_router.browserApi.seekRoute(detail.time);
+ }
+
+ /**
+ * Sends a command to mute or unmute the route shown in the route details
+ * view. Called when the user clicks on the mute/unmute button.
+ *
+ * @param {!Event} event
+ * Parameters in |event|.detail:
+ * mute - whether to mute the route.
+ */
+ function onSetRouteMute(event) {
+ /** @type {{mute: boolean}} */
+ var detail = event.detail;
+ media_router.browserApi.setRouteMute(detail.mute);
+ }
+
+ /**
* Reports the initial state of the dialog after it is opened.
* Called after initial data is populated.
*

Powered by Google App Engine
This is Rietveld 408576698