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 text for the stop casting button.
43 stopCastingButtonText_: {
45 value: loadTimeData.getString('stopCastingButton'),
49 * Whether the custom controller should be hidden.
50 * A custom controller is shown iff |route| specifies customControllerPath
51 * and the view can be loaded.
54 isCustomControllerHidden_: {
61 * Fires a back-click event. This is called when the back link is clicked.
66 this.fire('back-click');
70 * Fires a close-route-click event. This is called when the button to close
71 * the current route is clicked.
75 closeRoute_: function() {
76 this.fire('close-route-click', {route: this.route});
80 * Loads the custom controller if |route.customControllerPath| exists.
81 * Falls back to the default route details view otherwise, or if load fails.
82 * Updates |activityStatus_| for the default view.
86 maybeLoadCustomController_: function() {
87 this.activityStatus_ = this.route ?
88 loadTimeData.getStringF('castingActivityStatus',
89 this.route.description) :
92 if (!this.route || !this.route.customControllerPath) {
93 this.isCustomControllerHidden_ = true;
97 // Show custom controller
98 var extensionview = this.$['custom-controller'];
100 // Do nothing if the url is the same and the view is not hidden.
101 if (this.route.customControllerPath == extensionview.src &&
102 !this.isCustomControllerHidden_)
106 extensionview.load(this.route.customControllerPath)
108 // Load was successful; show the custom controller.
109 that.isCustomControllerHidden_ = false;
111 // Load was unsuccessful; fall back to default view.
112 that.isCustomControllerHidden_ = true;
117 * Handles a click on the close button by firing a close-button-click event.
121 onCloseButtonClick_: function() {
122 this.fire('close-button-click');