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
3 // found in the LICENSE file.
5 <include src="media_router_data.js">
6 <include src="media_router_ui_interface.js">
8 // Handles user events for the Media Router UI.
9 cr.define('media_router', function() {
12 // The media-router-container element. Initialized after polymer is ready.
16 * Initializes the Media Router WebUI and requests initial media
17 * router content, such as the media sink and media route lists.
19 function initialize() {
20 media_router.browserApi.requestInitialData();
22 container = $('media-router-container');
23 media_router.ui.setContainer(container);
25 container.addEventListener('close-button-click', onCloseDialogClick);
26 container.addEventListener('close-route-click', onCloseRouteClick);
27 container.addEventListener('create-route', onCreateRoute);
28 container.addEventListener('issue-action-click', onIssueActionClick);
33 * Called when the user clicks the close button on the dialog.
35 function onCloseDialogClick() {
36 media_router.browserApi.closeDialog();
40 * Acts on an issue and dismisses it from the UI.
41 * Called when the user performs an action on an issue.
43 * @param {{detail: {id: string, actionType: number, helpPageId: number}}}
45 * Parameters in |data|.detail:
47 * actionType - type of action performed by the user.
48 * helpPageId - the numeric help center ID.
50 function onIssueActionClick(data) {
51 media_router.browserApi.actOnIssue(data.detail.id,
52 data.detail.actionType,
53 data.detail.helpPageId);
54 container.issue = null;
58 * Creates a media route.
59 * Called when the user requests to create a media route.
61 * @param {{detail: {sinkId: string, selectedCastModeValue: number}}} data
62 * Parameters in |data|.detail:
63 * sinkId - sink ID selected by the user.
64 * selectedCastModeValue - cast mode selected by the user.
66 function onCreateRoute(data) {
67 media_router.browserApi.requestRoute(data.detail.sinkId,
68 data.detail.selectedCastModeValue);
73 * Called when the user requests to stop a media route.
75 * @param {{detail: {route: string}}} data
76 * Parameters in |data|.detail:
79 function onCloseRouteClick(data) {
80 media_router.browserApi.closeRoute(data.detail.route);
84 initialize: initialize,
88 window.addEventListener('load', media_router.initialize);