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

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

Issue 1548283003: Add P2 UMA metrics for Media Router user actions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 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 // The media-router-container element. Initialized after polymer is ready.
13 var container = null; 13 var container = null;
14 14
15 /** 15 /**
16 * Initializes the Media Router WebUI and requests initial media 16 * Initializes the Media Router WebUI and requests initial media
17 * router content, such as the media sink and media route lists. 17 * router content, such as the media sink and media route lists.
18 */ 18 */
19 function initialize() { 19 function initialize() {
20 media_router.browserApi.requestInitialData(); 20 media_router.browserApi.requestInitialData();
21 21
22 container = $('media-router-container'); 22 container = $('media-router-container');
23 media_router.ui.setContainer(container); 23 media_router.ui.setContainer(container);
24 24
25 container.addEventListener('cast-mode-selected', onCastModeSelected);
25 container.addEventListener('close-button-click', onCloseDialogEvent); 26 container.addEventListener('close-button-click', onCloseDialogEvent);
26 container.addEventListener('close-dialog', onCloseDialogEvent); 27 container.addEventListener('close-dialog', onCloseDialogEvent);
27 container.addEventListener('close-route-click', onCloseRouteClick); 28 container.addEventListener('close-route-click', onCloseRouteClick);
28 container.addEventListener('create-route', onCreateRoute); 29 container.addEventListener('create-route', onCreateRoute);
29 container.addEventListener('issue-action-click', onIssueActionClick); 30 container.addEventListener('issue-action-click', onIssueActionClick);
30 container.addEventListener('report-sink-count', onSinkCountReported); 31 container.addEventListener('report-sink-count', onSinkCountReported);
32 container.addEventListener('sink-click', onSinkClick);
31 } 33 }
32 34
33 /** 35 /**
34 * Closes the dialog. 36 * Closes the dialog.
35 * Called when the user clicks the close button on the dialog. 37 * Called when the user clicks the close button on the dialog.
36 */ 38 */
37 function onCloseDialogEvent() { 39 function onCloseDialogEvent() {
38 media_router.browserApi.closeDialog(); 40 media_router.browserApi.closeDialog();
39 } 41 }
40 42
41 /** 43 /**
42 * Acts on an issue and dismisses it from the UI. 44 * Acts on an issue and dismisses it from the UI.
43 * Called when the user performs an action on an issue. 45 * Called when the user performs an action on an issue.
44 * 46 *
45 * @param {{detail: {id: string, actionType: number, helpPageId: number}}} 47 * @param {{detail: {id: string, actionType: number, helpPageId: number}}}
46 * data 48 * data
47 * Parameters in |data|.detail: 49 * Parameters in |data|.detail:
48 * id - issue ID. 50 * id - issue ID.
49 * actionType - type of action performed by the user. 51 * actionType - type of action performed by the user.
50 * helpPageId - the numeric help center ID. 52 * helpPageId - the numeric help center ID.
51 */ 53 */
52 function onIssueActionClick(data) { 54 function onIssueActionClick(data) {
53 media_router.browserApi.actOnIssue(data.detail.id, 55 media_router.browserApi.actOnIssue(data.detail.id,
54 data.detail.actionType, 56 data.detail.actionType,
55 data.detail.helpPageId); 57 data.detail.helpPageId);
56 container.issue = null; 58 container.issue = null;
57 } 59 }
58 60
59 /** 61 /**
62 * Reports the selected cast mode.
63 * Called when the user selects a cast mode from the picker.
64 *
65 * @param {{detail: {castModeType: number}}} data
66 * Parameters in |data|.detail:
67 * castModeType - type of cast mode selected by the user.
68 */
69 function onCastModeSelected(data) {
70 media_router.browserApi.reportSelectedCastMode(data.detail.castModeType);
71 }
72
73 /**
60 * Creates a media route. 74 * Creates a media route.
61 * Called when the user requests to create a media route. 75 * Called when the user requests to create a media route.
62 * 76 *
63 * @param {{detail: {sinkId: string, selectedCastModeValue: number}}} data 77 * @param {{detail: {sinkId: string, selectedCastModeValue: number}}} data
64 * Parameters in |data|.detail: 78 * Parameters in |data|.detail:
65 * sinkId - sink ID selected by the user. 79 * sinkId - sink ID selected by the user.
66 * selectedCastModeValue - cast mode selected by the user. 80 * selectedCastModeValue - cast mode selected by the user.
67 */ 81 */
68 function onCreateRoute(data) { 82 function onCreateRoute(data) {
69 media_router.browserApi.requestRoute(data.detail.sinkId, 83 media_router.browserApi.requestRoute(data.detail.sinkId,
70 data.detail.selectedCastModeValue); 84 data.detail.selectedCastModeValue);
71 } 85 }
72 86
73 /** 87 /**
74 * Stops a route. 88 * Stops a route.
75 * Called when the user requests to stop a media route. 89 * Called when the user requests to stop a media route.
76 * 90 *
77 * @param {{detail: {route: string}}} data 91 * @param {{detail: {route: string}}} data
78 * Parameters in |data|.detail: 92 * Parameters in |data|.detail:
79 * route - route ID. 93 * route - route ID.
80 */ 94 */
81 function onCloseRouteClick(data) { 95 function onCloseRouteClick(data) {
82 media_router.browserApi.closeRoute(data.detail.route); 96 media_router.browserApi.closeRoute(data.detail.route);
83 } 97 }
84 98
85 /** 99 /**
100 * Reports the index of the sink that was clicked.
101 * Called when the user selects a sink on the sink list.
102 *
103 * @param {{detail: {index: number}}} data
104 * Paramters in |data|.detail:
105 * index - the index of the clicked sink.
106 */
107 function onSinkClick(data) {
108 media_router.browserApi.reportClickedSinkIndex(data.detail.index);
109 }
110
111 /**
86 * Reports the current sink count. 112 * Reports the current sink count.
87 * Called 3 seconds after the dialog is initially opened. 113 * Called 3 seconds after the dialog is initially opened.
88 * 114 *
89 * @param {{detail: {sinkCount: number}}} data 115 * @param {{detail: {sinkCount: number}}} data
90 * Parameters in |data|.detail: 116 * Parameters in |data|.detail:
91 * sinkCount - the number of sinks. 117 * sinkCount - the number of sinks.
92 */ 118 */
93 function onSinkCountReported(data) { 119 function onSinkCountReported(data) {
94 media_router.browserApi.reportSinkCount(data.detail.sinkCount); 120 media_router.browserApi.reportSinkCount(data.detail.sinkCount);
95 } 121 }
96 122
97 return { 123 return {
98 initialize: initialize, 124 initialize: initialize,
99 }; 125 };
100 }); 126 });
101 127
102 window.addEventListener('load', media_router.initialize); 128 window.addEventListener('load', media_router.initialize);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698