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
|
// 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.
// This Polymer element shows information from media that is currently cast
// to a device.
Polymer({
is: 'route-details',
properties: {
/**
* The text for the current casting activity status.
* @private {string}
*/
activityStatus_: {
type: String,
value: '',
},
/**
* The route to show.
* @type {?media_router.Route}
*/
route: {
type: Object,
value: null,
observer: 'maybeLoadCustomController_',
},
/**
* The text for the join button.
* @private {string}
*/
joinButtonText_: {
type: String,
readOnly: true,
value: loadTimeData.getString('joinButton'),
},
/**
* The text for the stop casting button.
* @private {string}
*/
stopCastingButtonText_: {
type: String,
readOnly: true,
value: function() {
return loadTimeData.getString('stopCastingButton');
},
},
/**
* Whether the custom controller should be hidden.
* A custom controller is shown iff |route| specifies customControllerPath
* and the view can be loaded.
* @private {boolean}
*/
isCustomControllerHidden_: {
type: Boolean,
value: true,
},
},
/**
* Fires a close-route-click event. This is called when the button to close
* the current route is clicked.
*
* @private
*/
closeRoute_: function() {
this.fire('close-route-click', {route: this.route});
},
/**
* Fires a join-route-click event. This is called when the button to join
* the current route is clicked.
*
* @private
*/
joinRoute_: function() {
this.fire('join-route-click', {route: this.route});
},
/**
* Loads the custom controller if |route.customControllerPath| exists.
* Falls back to the default route details view otherwise, or if load fails.
* Updates |activityStatus_| for the default view.
*
* @private
*/
maybeLoadCustomController_: function() {
this.activityStatus_ = this.route ?
loadTimeData.getStringF('castingActivityStatus',
this.route.description) :
'';
if (!this.route || !this.route.customControllerPath) {
this.isCustomControllerHidden_ = true;
return;
}
// Show custom controller
var extensionview = this.$['custom-controller'];
// Do nothing if the url is the same and the view is not hidden.
if (this.route.customControllerPath == extensionview.src &&
!this.isCustomControllerHidden_)
return;
var that = this;
extensionview.load(this.route.customControllerPath)
.then(function() {
// Load was successful; show the custom controller.
that.isCustomControllerHidden_ = false;
}, function() {
// Load was unsuccessful; fall back to default view.
that.isCustomControllerHidden_ = true;
});
},
});
|