1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
// Copyright 2015 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.
// Any strings used here will already be localized. Values such as
// CastMode.type or IDs will be defined elsewhere and determined later.
cr.exportPath('media_router');
/**
* This corresponds to the C++ MediaCastMode, with the exception of AUTO.
* See below for details. Note to support fast bitset operations, the values
* here are (1 << [corresponding value in MR]).
* @enum {number}
*/
media_router.CastModeType = {
// Note: AUTO mode is only used to configure the sink list container to show
// all sinks. Individual sinks are configured with a specific cast mode
// (DEFAULT, TAB_MIRROR, DESKTOP_MIRROR).
AUTO: -1,
DEFAULT: 0x1,
TAB_MIRROR: 0x2,
DESKTOP_MIRROR: 0x4,
};
/**
* This corresponds to the C++ MediaRouterMetrics MediaRouterUserAction.
* @enum {number}
*/
media_router.MediaRouterUserAction = {
CHANGE_MODE: 0,
START_LOCAL: 1,
STOP_LOCAL: 2,
CLOSE: 3,
STATUS_REMOTE: 4,
};
/**
* The possible states of the Media Router dialog. Used to determine which
* components to show.
* @enum {string}
*/
media_router.MediaRouterView = {
CAST_MODE_LIST: 'cast-mode-list',
FILTER: 'filter',
ISSUE: 'issue',
ROUTE_DETAILS: 'route-details',
SINK_LIST: 'sink-list',
};
/**
* This corresponds to the C++ MediaSink IconType.
* @enum {number}
*/
media_router.SinkIconType = {
CAST: 0,
CAST_AUDIO: 1,
CAST_AUDIO_GROUP: 2,
GENERIC: 3,
HANGOUT: 4,
};
/**
* @enum {string}
*/
media_router.SinkStatus = {
IDLE: 'idle',
ACTIVE: 'active',
REQUEST_PENDING: 'request_pending'
};
cr.define('media_router', function() {
'use strict';
/**
* @param {number} type The type of cast mode.
* @param {string} description The description of the cast mode.
* @param {?string} host The hostname of the site to cast.
* @constructor
* @struct
*/
var CastMode = function(type, description, host) {
/** @type {number} */
this.type = type;
/** @type {string} */
this.description = description;
/** @type {?string} */
this.host = host || null;
};
/**
* Placeholder object for AUTO cast mode. See comment in CastModeType.
* @const {!media_router.CastMode}
*/
var AUTO_CAST_MODE = new CastMode(media_router.CastModeType.AUTO,
loadTimeData.getString('autoCastMode'), null);
/**
* @param {string} id The ID of this issue.
* @param {string} title The issue title.
* @param {string} message The issue message.
* @param {number} defaultActionType The type of default action.
* @param {?number} secondaryActionType The type of optional action.
* @param {?string} mediaRouteId The route ID to which this issue
* pertains. If not set, this is a global issue.
* @param {boolean} isBlocking True if this issue blocks other UI.
* @param {?number} helpPageId The numeric help center ID.
* @constructor
* @struct
*/
var Issue = function(id, title, message, defaultActionType,
secondaryActionType, mediaRouteId, isBlocking,
helpPageId) {
/** @type {string} */
this.id = id;
/** @type {string} */
this.title = title;
/** @type {string} */
this.message = message;
/** @type {number} */
this.defaultActionType = defaultActionType;
/** @type {?number} */
this.secondaryActionType = secondaryActionType;
/** @type {?string} */
this.mediaRouteId = mediaRouteId;
/** @type {boolean} */
this.isBlocking = isBlocking;
/** @type {?number} */
this.helpPageId = helpPageId;
};
/**
* @param {string} id The media route ID.
* @param {string} sinkId The ID of the media sink running this route.
* @param {string} description The short description of this route.
* @param {?number} tabId The ID of the tab in which web app is running and
* accessing the route.
* @param {boolean} isLocal True if this is a locally created route.
* @param {boolean} canJoin True if this route can be joined.
* @param {?string} customControllerPath non-empty if this route has custom
* controller.
* @constructor
* @struct
*/
var Route = function(id, sinkId, description, tabId, isLocal, canJoin,
customControllerPath) {
/** @type {string} */
this.id = id;
/** @type {string} */
this.sinkId = sinkId;
/** @type {string} */
this.description = description;
/** @type {?number} */
this.tabId = tabId;
/** @type {boolean} */
this.isLocal = isLocal;
/** @type {boolean} */
this.canJoin = canJoin;
/** @type {?string} */
this.customControllerPath = customControllerPath;
};
/**
* @param {string} id The ID of the media sink.
* @param {string} name The name of the sink.
* @param {?string} description Optional description of the sink.
* @param {?string} domain Optional domain of the sink.
* @param {media_router.SinkIconType} iconType the type of icon for the sink.
* @param {media_router.SinkStatus} status The readiness state of the sink.
* @param {number} castModes Bitset of cast modes compatible with the sink.
* @constructor
* @struct
*/
var Sink = function(id, name, description, domain, iconType, status,
castModes) {
/** @type {string} */
this.id = id;
/** @type {string} */
this.name = name;
/** @type {?string} */
this.description = description;
/** @type {?string} */
this.domain = domain;
/** @type {!media_router.SinkIconType} */
this.iconType = iconType;
/** @type {!media_router.SinkStatus} */
this.status = status;
/** @type {number} */
this.castModes = castModes;
};
/**
* @param {number} tabId The current tab ID.
* @param {string} domain The domain of the current tab.
* @constructor
* @struct
*/
var TabInfo = function(tabId, domain) {
/** @type {number} */
this.tabId = tabId;
/** @type {string} */
this.domain = domain;
};
return {
AUTO_CAST_MODE: AUTO_CAST_MODE,
CastMode: CastMode,
Issue: Issue,
Route: Route,
Sink: Sink,
TabInfo: TabInfo,
};
});
|