Index: chrome/browser/resources/media_router/media_router_ui_interface.js |
diff --git a/chrome/browser/resources/media_router/media_router_ui_interface.js b/chrome/browser/resources/media_router/media_router_ui_interface.js |
index a8ec54461a248a242f5475c160923d50dc85ccfd..2ac355cd1d3b44f05f7d241b23f0b6c0dbd7389e 100644 |
--- a/chrome/browser/resources/media_router/media_router_ui_interface.js |
+++ b/chrome/browser/resources/media_router/media_router_ui_interface.js |
@@ -13,6 +13,9 @@ cr.define('media_router.ui', function() { |
// The media-router-header element. |
var header = null; |
+ // The route-controls element. Is null if the route details view isn't open. |
+ var routeControls = null; |
+ |
/** |
* Handles response of previous create route attempt. |
* |
@@ -27,6 +30,14 @@ cr.define('media_router.ui', function() { |
} |
/** |
+ * Called when the route controller for the route that is currently selected |
+ * is invalidated. |
+ */ |
+ function onRouteControllerInvalidated() { |
+ container.onRouteControllerInvalidated(); |
imcheng
2017/05/05 21:36:41
Do you need to set routeControls to null here?
takumif
2017/05/09 00:14:57
We already do that in RouteControls.reset(), altho
|
+ } |
+ |
+ /** |
* Handles the search response by forwarding |sinkId| to the container. |
* |
* @param {string} sinkId The ID of the sink found by search. |
@@ -105,6 +116,8 @@ cr.define('media_router.ui', function() { |
* routes - list of routes that are associated with the sinks. |
* castModes - list of available cast modes. |
* useTabMirroring - whether the cast mode should be set to TAB_MIRROR. |
+ * useNewRouteControls - whether the new WebUI route controls should be |
+ * used. |
*/ |
function setInitialData(data) { |
container.deviceMissingUrl = data['deviceMissingUrl']; |
@@ -114,6 +127,7 @@ cr.define('media_router.ui', function() { |
container.maybeShowRouteDetailsOnOpen(); |
if (data['useTabMirroring']) |
container.selectCastMode(media_router.CastModeType.TAB_MIRROR); |
+ container.useWebUiRouteControls = data['useNewRouteControls']; |
media_router.browserApi.onInitialDataReceived(); |
} |
@@ -128,6 +142,16 @@ cr.define('media_router.ui', function() { |
} |
/** |
+ * Sets |routeControls|. The argument may be null if the route details view is |
+ * getting closed. |
+ * |
+ * @param {?MediaRouterRouteControlsElement} mediaRouterRouteControls |
+ */ |
+ function setRouteControls(mediaRouterRouteControls) { |
+ routeControls = mediaRouterRouteControls; |
+ } |
+ |
+ /** |
* Sets the list of currently active routes. |
* |
* @param {!Array<!media_router.Route>} routeList |
@@ -166,17 +190,30 @@ cr.define('media_router.ui', function() { |
container.updateMaxDialogHeight(height); |
} |
+ /** |
+ * Updates the route status shown in the route controls. |
+ * |
+ * @param {!media_router.RouteStatus} status |
+ */ |
+ function updateRouteStatus(status) { |
+ if (routeControls) |
+ routeControls.routeStatus = status; |
+ } |
+ |
return { |
onCreateRouteResponseReceived: onCreateRouteResponseReceived, |
+ onRouteControllerInvalidated: onRouteControllerInvalidated, |
receiveSearchResult: receiveSearchResult, |
setCastModeList: setCastModeList, |
setElements: setElements, |
setFirstRunFlowData: setFirstRunFlowData, |
setInitialData: setInitialData, |
setIssue: setIssue, |
+ setRouteControls: setRouteControls, |
setRouteList: setRouteList, |
setSinkListAndIdentity: setSinkListAndIdentity, |
updateMaxHeight: updateMaxHeight, |
+ updateRouteStatus: updateRouteStatus, |
}; |
}); |
@@ -255,6 +292,36 @@ cr.define('media_router.browserApi', function() { |
} |
/** |
+ * Reports that the route details view was closed. |
+ */ |
+ function onMediaControllerClosed() { |
+ chrome.send('onMediaControllerClosed'); |
+ } |
+ |
+ /** |
+ * Reports that the route details view was opened for |routeId|. |
+ * |
+ * @param {string} routeId |
+ */ |
+ function onMediaControllerAvailable(routeId) { |
+ chrome.send('onMediaControllerAvailable', [{routeId: routeId}]); |
+ } |
+ |
+ /** |
+ * Sends a command to pause the route shown in the route details view. |
+ */ |
+ function pauseCurrentMedia() { |
+ chrome.send('pauseCurrentMedia'); |
+ } |
+ |
+ /** |
+ * Sends a command to play the route shown in the route details view. |
+ */ |
+ function playCurrentMedia() { |
+ chrome.send('playCurrentMedia'); |
+ } |
+ |
+ /** |
* Reports when the user clicks outside the dialog. |
*/ |
function reportBlur() { |
@@ -401,6 +468,35 @@ cr.define('media_router.browserApi', function() { |
selectedCastMode: selectedCastMode}]); |
} |
+ /** |
+ * Sends a command to seek the route shown in the route details view. |
+ * |
+ * @param {number} time The new current time in seconds. |
+ */ |
+ function seekCurrentMedia(time) { |
+ chrome.send('seekCurrentMedia', [{time: time}]); |
+ } |
+ |
+ /** |
+ * Sends a command to mute or unmute the route shown in the route details |
+ * view. |
+ * |
+ * @param {boolean} mute Mute the route if true, unmute it if false. |
+ */ |
+ function setCurrentMediaMute(mute) { |
+ chrome.send('setCurrentMediaMute', [{mute: mute}]); |
+ } |
+ |
+ /** |
+ * Sends a command to change the volume of the route shown in the route |
+ * details view. |
+ * |
+ * @param {number} volume The volume between 0 and 1. |
+ */ |
+ function setCurrentMediaVolume(volume) { |
+ chrome.send('setCurrentMediaVolume', [{volume: volume}]); |
+ } |
+ |
return { |
acknowledgeFirstRunFlow: acknowledgeFirstRunFlow, |
actOnIssue: actOnIssue, |
@@ -409,6 +505,10 @@ cr.define('media_router.browserApi', function() { |
closeRoute: closeRoute, |
joinRoute: joinRoute, |
onInitialDataReceived: onInitialDataReceived, |
+ onMediaControllerClosed: onMediaControllerClosed, |
+ onMediaControllerAvailable: onMediaControllerAvailable, |
+ pauseCurrentMedia: pauseCurrentMedia, |
+ playCurrentMedia: playCurrentMedia, |
reportBlur: reportBlur, |
reportClickedSinkIndex: reportClickedSinkIndex, |
reportFilter: reportFilter, |
@@ -424,5 +524,8 @@ cr.define('media_router.browserApi', function() { |
requestInitialData: requestInitialData, |
requestRoute: requestRoute, |
searchSinksAndCreateRoute: searchSinksAndCreateRoute, |
+ seekCurrentMedia: seekCurrentMedia, |
+ setCurrentMediaMute: setCurrentMediaMute, |
+ setCurrentMediaVolume: setCurrentMediaVolume, |
}; |
}); |