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 // This Polymer element shows information from media that is currently cast
6 // to a device. It is assumed that |route| and |sink| correspond to each other.
12 * The text for the current casting activity status.
22 * @type {?media_router.Route}
27 observer
: 'maybeLoadCustomController_',
32 * @type {?media_router.Sink}
40 * The ID of the media route provider extension.
43 routeProviderExtensionId
: {
49 * The text for the stop casting button.
52 stopCastingButtonText_
: {
54 value
: loadTimeData
.getString('stopCastingButton'),
58 * Whether the custom controller should be hidden.
59 * A custom controller is shown iff |route| specifies customControllerPath
60 * and the view can be loaded.
63 isCustomControllerHidden_
: {
70 * Fires a back-click event. This is called when the back link is clicked.
75 this.fire('back-click');
79 * Fires a close-route-click event. This is called when the button to close
80 * the current route is clicked.
84 closeRoute_: function() {
85 this.fire('close-route-click', {route
: this.route
});
89 * Loads the custom controller if |route.customControllerPath| exists.
90 * Falls back to the default route details view otherwise, or if load fails.
91 * Updates |activityStatus_| for the default view.
95 maybeLoadCustomController_: function() {
96 this.activityStatus_
= this.route
?
97 loadTimeData
.getStringF('castingActivityStatus', this.route
.title
) :
100 if (!this.route
|| !this.route
.customControllerPath
||
101 !this.routeProviderExtensionId
) {
102 this.isCustomControllerHidden_
= true;
106 // Show custom controller
107 var fullUrl
= 'chrome-extension://' + this.routeProviderExtensionId
+ '/' +
108 this.route
.customControllerPath
;
109 var extensionview
= this.$['custom-controller'];
110 if (fullUrl
== extensionview
.src
&& !this.isCustomControllerHidden_
) {
111 // Do nothing if the url is the same and the view is not hidden.
115 this.isCustomControllerHidden_
= false;
117 extensionview
.load(fullUrl
).catch(function() {
118 // Fall back to default view.
119 that
.isCustomControllerHidden_
= true;
124 * Handles a click on the close button by firing a close-button-click event.
128 onCloseButtonClick_: function() {
129 this.fire('close-button-click');