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

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

Issue 2725503002: [Media Router] Custom Controls 4 - Implement details view WebUI (Closed)
Patch Set: Add braces to @implements {Interface} Created 3 years, 7 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_browser_api.js
diff --git a/chrome/browser/resources/media_router/media_router_ui_interface.js b/chrome/browser/resources/media_router/media_router_browser_api.js
similarity index 51%
copy from chrome/browser/resources/media_router/media_router_ui_interface.js
copy to chrome/browser/resources/media_router/media_router_browser_api.js
index a8ec54461a248a242f5475c160923d50dc85ccfd..482decffa92a71d194ed75ee775267081ec3a6fb 100644
--- a/chrome/browser/resources/media_router/media_router_ui_interface.js
+++ b/chrome/browser/resources/media_router/media_router_browser_api.js
@@ -1,185 +1,7 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
+// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// API invoked by the browser MediaRouterWebUIMessageHandler to communicate
-// with this UI.
-cr.define('media_router.ui', function() {
- 'use strict';
-
- // The media-router-container element.
- var container = null;
-
- // The media-router-header element.
- var header = null;
-
- /**
- * Handles response of previous create route attempt.
- *
- * @param {string} sinkId The ID of the sink to which the Media Route was
- * creating a route.
- * @param {?media_router.Route} route The newly created route that
- * corresponds to the sink if route creation succeeded; null otherwise.
- * @param {boolean} isForDisplay Whether or not |route| is for display.
- */
- function onCreateRouteResponseReceived(sinkId, route, isForDisplay) {
- container.onCreateRouteResponseReceived(sinkId, route, isForDisplay);
- }
-
- /**
- * Handles the search response by forwarding |sinkId| to the container.
- *
- * @param {string} sinkId The ID of the sink found by search.
- */
- function receiveSearchResult(sinkId) {
- container.onReceiveSearchResult(sinkId);
- }
-
- /**
- * Sets the cast mode list.
- *
- * @param {!Array<!media_router.CastMode>} castModeList
- */
- function setCastModeList(castModeList) {
- container.castModeList = castModeList;
- }
-
- /**
- * Sets |container| and |header|.
- *
- * @param {!MediaRouterContainerElement} mediaRouterContainer
- * @param {!MediaRouterHeaderElement} mediaRouterHeader
- */
- function setElements(mediaRouterContainer, mediaRouterHeader) {
- container = mediaRouterContainer;
- header = mediaRouterHeader;
- }
-
- /**
- * Populates the WebUI with data obtained about the first run flow.
- *
- * @param {{firstRunFlowCloudPrefLearnMoreUrl: string,
- * firstRunFlowLearnMoreUrl: string,
- * wasFirstRunFlowAcknowledged: boolean,
- * showFirstRunFlowCloudPref: boolean}} data
- * Parameters in data:
- * firstRunFlowCloudPrefLearnMoreUrl - url to open when the cloud services
- * pref learn more link is clicked.
- * firstRunFlowLearnMoreUrl - url to open when the first run flow learn
- * more link is clicked.
- * wasFirstRunFlowAcknowledged - true if first run flow was previously
- * acknowledged by user.
- * showFirstRunFlowCloudPref - true if the cloud pref option should be
- * shown.
- */
- function setFirstRunFlowData(data) {
- container.firstRunFlowCloudPrefLearnMoreUrl =
- data['firstRunFlowCloudPrefLearnMoreUrl'];
- container.firstRunFlowLearnMoreUrl =
- data['firstRunFlowLearnMoreUrl'];
- container.showFirstRunFlowCloudPref =
- data['showFirstRunFlowCloudPref'];
- // Some users acknowledged the first run flow before the cloud prefs
- // setting was implemented. These users will see the first run flow
- // again.
- container.showFirstRunFlow = !data['wasFirstRunFlowAcknowledged'] ||
- container.showFirstRunFlowCloudPref;
- }
-
- /**
- * Populates the WebUI with data obtained from Media Router.
- *
- * @param {{deviceMissingUrl: string,
- * sinksAndIdentity: {
- * sinks: !Array<!media_router.Sink>,
- * showEmail: boolean,
- * userEmail: string,
- * showDomain: boolean
- * },
- * routes: !Array<!media_router.Route>,
- * castModes: !Array<!media_router.CastMode>,
- * useTabMirroring: boolean}} data
- * Parameters in data:
- * deviceMissingUrl - url to be opened on "Device missing?" clicked.
- * sinksAndIdentity - list of sinks to be displayed and user identity.
- * 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.
- */
- function setInitialData(data) {
- container.deviceMissingUrl = data['deviceMissingUrl'];
- container.castModeList = data['castModes'];
- this.setSinkListAndIdentity(data['sinksAndIdentity']);
- container.routeList = data['routes'];
- container.maybeShowRouteDetailsOnOpen();
- if (data['useTabMirroring'])
- container.selectCastMode(media_router.CastModeType.TAB_MIRROR);
- media_router.browserApi.onInitialDataReceived();
- }
-
- /**
- * Sets current issue to |issue|, or clears the current issue if |issue| is
- * null.
- *
- * @param {?media_router.Issue} issue
- */
- function setIssue(issue) {
- container.issue = issue;
- }
-
- /**
- * Sets the list of currently active routes.
- *
- * @param {!Array<!media_router.Route>} routeList
- */
- function setRouteList(routeList) {
- container.routeList = routeList;
- }
-
- /**
- * Sets the list of discovered sinks along with properties of whether to hide
- * identity of the user email and domain.
- *
- * @param {{sinks: !Array<!media_router.Sink>,
- * showEmail: boolean,
- * userEmail: string,
- * showDomain: boolean}} data
- * Parameters in data:
- * sinks - list of sinks to be displayed.
- * showEmail - true if the user email should be shown.
- * userEmail - email of the user if the user is signed in.
- * showDomain - true if the user domain should be shown.
- */
- function setSinkListAndIdentity(data) {
- container.showDomain = data['showDomain'];
- container.allSinks = data['sinks'];
- header.userEmail = data['userEmail'];
- header.showEmail = data['showEmail'];
- }
-
- /**
- * Updates the max height of the dialog
- *
- * @param {number} height
- */
- function updateMaxHeight(height) {
- container.updateMaxDialogHeight(height);
- }
-
- return {
- onCreateRouteResponseReceived: onCreateRouteResponseReceived,
- receiveSearchResult: receiveSearchResult,
- setCastModeList: setCastModeList,
- setElements: setElements,
- setFirstRunFlowData: setFirstRunFlowData,
- setInitialData: setInitialData,
- setIssue: setIssue,
- setRouteList: setRouteList,
- setSinkListAndIdentity: setSinkListAndIdentity,
- updateMaxHeight: updateMaxHeight,
- };
-});
-
// API invoked by this UI to communicate with the browser WebUI message handler.
cr.define('media_router.browserApi', function() {
'use strict';
@@ -202,8 +24,9 @@ cr.define('media_router.browserApi', function() {
* @param {?number} helpPageId The numeric help center ID.
*/
function actOnIssue(issueId, actionType, helpPageId) {
- chrome.send('actOnIssue', [{issueId: issueId, actionType: actionType,
- helpPageId: helpPageId}]);
+ chrome.send(
+ 'actOnIssue',
+ [{issueId: issueId, actionType: actionType, helpPageId: helpPageId}]);
}
/**
@@ -215,8 +38,9 @@ cr.define('media_router.browserApi', function() {
* selected.
*/
function changeRouteSource(route, selectedCastMode) {
- chrome.send('requestRoute',
- [{sinkId: route.sinkId, selectedCastMode: selectedCastMode}]);
+ chrome.send(
+ 'requestRoute',
+ [{sinkId: route.sinkId, selectedCastMode: selectedCastMode}]);
}
/**
@@ -255,6 +79,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() {
@@ -376,8 +230,8 @@ cr.define('media_router.browserApi', function() {
* selected.
*/
function requestRoute(sinkId, selectedCastMode) {
- chrome.send('requestRoute',
- [{sinkId: sinkId, selectedCastMode: selectedCastMode}]);
+ chrome.send(
+ 'requestRoute', [{sinkId: sinkId, selectedCastMode: selectedCastMode}]);
}
/**
@@ -394,11 +248,41 @@ cr.define('media_router.browserApi', function() {
*/
function searchSinksAndCreateRoute(
sinkId, searchCriteria, domain, selectedCastMode) {
- chrome.send('searchSinksAndCreateRoute',
- [{sinkId: sinkId,
+ chrome.send('searchSinksAndCreateRoute', [{
+ sinkId: sinkId,
searchCriteria: searchCriteria,
domain: domain,
- selectedCastMode: selectedCastMode}]);
+ 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 {
@@ -409,6 +293,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 +312,8 @@ cr.define('media_router.browserApi', function() {
requestInitialData: requestInitialData,
requestRoute: requestRoute,
searchSinksAndCreateRoute: searchSinksAndCreateRoute,
+ seekCurrentMedia: seekCurrentMedia,
+ setCurrentMediaMute: setCurrentMediaMute,
+ setCurrentMediaVolume: setCurrentMediaVolume,
};
});
« no previous file with comments | « chrome/browser/resources/media_router/media_router.js ('k') | chrome/browser/resources/media_router/media_router_common.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698