[sql] Remove _HAS_EXCEPTIONS=0 from build info.
[chromium-blink-merge.git] / chrome / browser / resources / media_router / elements / route_details / route_details.js
blob0388a1ad7568bab754e373ef19d7024653707e90
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.
7 Polymer({
8 is: 'route-details',
10 properties: {
11 /**
12 * The text for the current casting activity status.
13 * @private {string}
15 activityStatus_: {
16 type: String,
17 value: '',
20 /**
21 * The route to show.
22 * @type {?media_router.Route}
24 route: {
25 type: Object,
26 value: null,
27 observer: 'maybeLoadCustomController_',
30 /**
31 * The sink to show.
32 * @type {?media_router.Sink}
34 sink: {
35 type: Object,
36 value: null,
39 /**
40 * The ID of the media route provider extension.
41 * @type {string}
43 routeProviderExtensionId: {
44 type: String,
45 value: '',
48 /**
49 * The text for the stop casting button.
50 * @private {string}
52 stopCastingButtonText_: {
53 type: String,
54 value: loadTimeData.getString('stopCastingButton'),
57 /**
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.
61 * @private {boolean}
63 isCustomControllerHidden_: {
64 type: Boolean,
65 value: true,
69 /**
70 * Fires a back-click event. This is called when the back link is clicked.
72 * @private
74 back_: function() {
75 this.fire('back-click');
78 /**
79 * Fires a close-route-click event. This is called when the button to close
80 * the current route is clicked.
82 * @private
84 closeRoute_: function() {
85 this.fire('close-route-click', {route: this.route});
88 /**
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.
93 * @private
95 maybeLoadCustomController_: function() {
96 this.activityStatus_ = this.route ?
97 loadTimeData.getStringF('castingActivityStatus', this.route.title) :
98 '';
100 if (!this.route || !this.route.customControllerPath ||
101 !this.routeProviderExtensionId) {
102 this.isCustomControllerHidden_ = true;
103 return;
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.
112 return;
115 this.isCustomControllerHidden_ = false;
116 var that = this;
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.
126 * @private
128 onCloseButtonClick_: function() {
129 this.fire('close-button-click');