[sql] Remove _HAS_EXCEPTIONS=0 from build info.
[chromium-blink-merge.git] / chrome / browser / resources / media_router / elements / issue_banner / issue_banner.js
blob7b0a7edfb9fbed08d971476bb7e4d35aebd1b7b5
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 is used to show information about issues related
6 // to casting.
7 Polymer({
8 is: 'issue-banner',
10 properties: {
11 /**
12 * The issue to show.
13 * @type {?media_router.Issue}
15 issue: {
16 type: Object,
17 value: null,
18 observer: 'updateActionButtonText_',
21 /**
22 * Maps an issue action type to the resource identifier of the text shown
23 * in the action button.
24 * This is a property of issue-banner because it is used in tests.
25 * @type {!Array<string>}
27 issueActionTypeToButtonTextResource_: {
28 type: Array,
29 value: function() {
30 return ['okButton', 'cancelButton', 'dismissButton',
31 'learnMoreButton'];
35 /**
36 * The text shown in the default action button.
37 * @private {string}
39 defaultActionButtonText_: {
40 type: String,
41 value: '',
44 /**
45 * The text shown in the secondary action button.
46 * @private {string}
48 secondaryActionButtonText_: {
49 type: String,
50 value: '',
54 /**
55 * @param {?media_router.Issue} issue
56 * @return {boolean} Whether or not to hide the blocking issue UI.
57 * @private
59 computeIsBlockingIssueHidden_: function(issue) {
60 return !issue || !issue.isBlocking;
63 /**
64 * Returns true to hide the non-blocking issue UI, false to show it.
66 * @param {?media_router.Issue} issue
67 * @private
69 computeIsNonBlockingIssueHidden_: function(issue) {
70 return !issue || issue.isBlocking;
73 /**
74 * @param {?media_router.Issue} issue
75 * @return {boolean} Whether or not to hide the non-blocking issue UI.
76 * @private
78 computeOptionalActionHidden_: function(issue) {
79 return !issue || !issue.secondaryActionType;
82 /**
83 * Fires an issue-action-click event.
85 * @param {number} actionType The type of issue action.
86 * @private
88 fireIssueActionClick_: function(actionType) {
89 this.fire('issue-action-click', {
90 id: this.issue.id,
91 actionType: actionType,
92 helpPageId: this.issue.helpPageId
93 });
96 /**
97 * Called when a default issue action is clicked.
99 * @param {!Event} event The event object.
100 * @private
102 onClickDefaultAction_: function(event) {
103 this.fireIssueActionClick_(this.issue.defaultActionType);
107 * Called when an optional issue action is clicked.
109 * @param {!Event} event The event object.
110 * @private
112 onClickOptAction_: function(event) {
113 this.fireIssueActionClick_(this.issue.secondaryActionType);
117 * Called when |issue| is updated. This updates the default and secondary
118 * action button text.
120 * @private
122 updateActionButtonText_: function() {
123 var defaultText = '';
124 var secondaryText = '';
125 if (this.issue) {
126 defaultText = loadTimeData.getString(
127 this.issueActionTypeToButtonTextResource_[
128 this.issue.defaultActionType]);
130 if (this.issue.secondaryActionType) {
131 secondaryText = loadTimeData.getString(
132 this.issueActionTypeToButtonTextResource_[
133 this.issue.secondaryActionType]);
137 this.defaultActionButtonText_ = defaultText;
138 this.secondaryActionButtonText_ = secondaryText;