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

Side by Side Diff: chrome/browser/resources/media_router/media_router.js

Issue 1521433002: [MediaRouter UI] Compile MR WebUI js code with Closure. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 unified diff | Download patch
OLDNEW
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 <include src="media_router_data.js"> 5 <include src="media_router_data.js">
6 <include src="media_router_ui_interface.js"> 6 <include src="media_router_ui_interface.js">
7 7
8 // Handles user events for the Media Router UI. 8 // Handles user events for the Media Router UI.
9 cr.define('media_router', function() { 9 cr.define('media_router', function() {
10 'use strict'; 10 'use strict';
11 11
12 // The media-router-container element. Initialized after polymer is ready. 12 /**
13 * The media-router-container element. Initialized after polymer is ready.
14 * @type {?MediaRouterContainerElement}
15 */
13 var container = null; 16 var container = null;
14 17
15 /** 18 /**
16 * Initializes the Media Router WebUI and requests initial media 19 * Initializes the Media Router WebUI and requests initial media
17 * router content, such as the media sink and media route lists. 20 * router content, such as the media sink and media route lists.
18 */ 21 */
19 function initialize() { 22 function initialize() {
20 media_router.browserApi.requestInitialData(); 23 media_router.browserApi.requestInitialData();
21 24
22 container = $('media-router-container'); 25 container = /** @type {!MediaRouterContainerElement} */
26 ($('media-router-container'));
23 media_router.ui.setContainer(container); 27 media_router.ui.setContainer(container);
24 28
25 container.addEventListener('close-button-click', onCloseDialogEvent); 29 container.addEventListener('close-button-click', onCloseDialogEvent);
26 container.addEventListener('close-dialog', onCloseDialogEvent); 30 container.addEventListener('close-dialog', onCloseDialogEvent);
27 container.addEventListener('close-route-click', onCloseRouteClick); 31 container.addEventListener('close-route-click', onCloseRouteClick);
28 container.addEventListener('create-route', onCreateRoute); 32 container.addEventListener('create-route', onCreateRoute);
29 container.addEventListener('issue-action-click', onIssueActionClick); 33 container.addEventListener('issue-action-click', onIssueActionClick);
30 container.addEventListener('report-sink-count', onSinkCountReported); 34 container.addEventListener('report-sink-count', onSinkCountReported);
31 } 35 }
32 36
33 /** 37 /**
34 * Closes the dialog. 38 * Closes the dialog.
35 * Called when the user clicks the close button on the dialog. 39 * Called when the user clicks the close button on the dialog.
36 */ 40 */
37 function onCloseDialogEvent() { 41 function onCloseDialogEvent() {
38 media_router.browserApi.closeDialog(); 42 media_router.browserApi.closeDialog();
39 } 43 }
40 44
41 /** 45 /**
42 * Acts on an issue and dismisses it from the UI. 46 * Acts on an issue and dismisses it from the UI.
43 * Called when the user performs an action on an issue. 47 * Called when the user performs an action on an issue.
44 * 48 *
45 * @param {{detail: {id: string, actionType: number, helpPageId: number}}} 49 * @param {!Event} data
46 * data
47 * Parameters in |data|.detail: 50 * Parameters in |data|.detail:
48 * id - issue ID. 51 * id (string) - issue ID.
49 * actionType - type of action performed by the user. 52 * actionType (number) - type of action performed by the user.
50 * helpPageId - the numeric help center ID. 53 * helpPageId (number) - the numeric help center ID.
Dan Beam 2015/12/10 23:41:34 this is not better than what you had before...
imcheng 2015/12/11 01:14:59 Okay. But Event is not the same as {{detail: {id:
51 */ 54 */
52 function onIssueActionClick(data) { 55 function onIssueActionClick(data) {
53 media_router.browserApi.actOnIssue(data.detail.id, 56 media_router.browserApi.actOnIssue(data.detail.id,
54 data.detail.actionType, 57 data.detail.actionType,
55 data.detail.helpPageId); 58 data.detail.helpPageId);
56 container.issue = null; 59 container.issue = null;
57 } 60 }
58 61
59 /** 62 /**
60 * Creates a media route. 63 * Creates a media route.
61 * Called when the user requests to create a media route. 64 * Called when the user requests to create a media route.
62 * 65 *
63 * @param {{detail: {sinkId: string, selectedCastModeValue: number}}} data 66 * @param {!Event} data
Dan Beam 2015/12/10 23:41:34 same question: why are you undoing this?
imcheng 2015/12/11 01:14:59 See above
64 * Parameters in |data|.detail: 67 * Parameters in |data|.detail:
65 * sinkId - sink ID selected by the user. 68 * sinkId (string) - sink ID selected by the user.
66 * selectedCastModeValue - cast mode selected by the user. 69 * selectedCastModeValue (number) - cast mode selected by the user.
67 */ 70 */
68 function onCreateRoute(data) { 71 function onCreateRoute(data) {
69 media_router.browserApi.requestRoute(data.detail.sinkId, 72 media_router.browserApi.requestRoute(data.detail.sinkId,
70 data.detail.selectedCastModeValue); 73 data.detail.selectedCastModeValue);
71 } 74 }
72 75
73 /** 76 /**
74 * Stops a route. 77 * Stops a route.
75 * Called when the user requests to stop a media route. 78 * Called when the user requests to stop a media route.
76 * 79 *
77 * @param {{detail: {route: string}}} data 80 * @param {!Event} data
78 * Parameters in |data|.detail: 81 * Parameters in |data|.detail:
79 * route - route ID. 82 * route (media_router.Route) - The route to close.
80 */ 83 */
81 function onCloseRouteClick(data) { 84 function onCloseRouteClick(data) {
82 media_router.browserApi.closeRoute(data.detail.route); 85 media_router.browserApi.closeRoute(data.detail.route);
83 } 86 }
84 87
85 /** 88 /**
86 * Reports the current sink count. 89 * Reports the current sink count.
87 * Called 3 seconds after the dialog is initially opened. 90 * Called 3 seconds after the dialog is initially opened.
88 * 91 *
89 * @param {{detail: {sinkCount: number}}} data 92 * @param {!Event} data
90 * Parameters in |data|.detail: 93 * Parameters in |data|.detail:
91 * sinkCount - the number of sinks. 94 * sinkCount (number) - the number of sinks.
92 */ 95 */
93 function onSinkCountReported(data) { 96 function onSinkCountReported(data) {
94 media_router.browserApi.reportSinkCount(data.detail.sinkCount); 97 media_router.browserApi.reportSinkCount(data.detail.sinkCount);
95 } 98 }
96 99
97 return { 100 return {
98 initialize: initialize, 101 initialize: initialize,
99 }; 102 };
100 }); 103 });
101 104
102 window.addEventListener('load', media_router.initialize); 105 window.addEventListener('load', media_router.initialize);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698