Move Webstore URL concepts to //extensions and out
[chromium-blink-merge.git] / chrome / browser / resources / options / hotword_search_setting_indicator.js
blob697e63f7b2187a594a6376adcb0308f996f9f1f4
1 // Copyright 2014 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 cr.define('options', function() {
6 /** @const */ var ControlledSettingIndicator =
7 options.ControlledSettingIndicator;
9 /**
10 * A variant of the {@link ControlledSettingIndicator} that shows the status
11 * of the hotword search setting, including a bubble to show setup errors
12 * (such as failures to download extension resources).
13 * @constructor
14 * @extends {options.ControlledSettingIndicator}
16 var HotwordSearchSettingIndicator = cr.ui.define('span');
18 HotwordSearchSettingIndicator.prototype = {
19 __proto__: ControlledSettingIndicator.prototype,
21 /**
22 * Decorates the base element to show the proper icon.
23 * @override
25 decorate: function() {
26 ControlledSettingIndicator.prototype.decorate.call(this);
27 this.hidden = true;
30 /**
31 * Handle changes to the associated pref by hiding any currently visible
32 * bubble.
33 * @param {Event} event Pref change event.
34 * @override
36 handlePrefChange: function(event) {
37 PageManager.hideBubble();
40 /**
41 * Returns the current error.
42 * @return {string} The error message to be displayed. May be undefined if
43 * there is no error.
45 get errorText() {
46 return this.errorText_;
49 /**
50 * Checks for errors and records them.
51 * @param {string} errorMsg The error message to be displayed. May be
52 * undefined if there is no error.
54 setError: function(errorMsg) {
55 this.setAttribute('controlled-by', 'policy');
56 this.errorText_ = errorMsg;
59 /**
60 * Changes the display to be visible if there are errors and disables
61 * the section.
63 updateBasedOnError: function() {
64 if (this.errorText_)
65 this.hidden = false;
68 /**
69 * Toggles showing and hiding the error message bubble. An empty
70 * |errorText_| indicates that there is no error message. So the bubble
71 * only be shown if |errorText_| has a value.
72 * @override
74 toggleBubble: function() {
75 if (this.showingBubble) {
76 PageManager.hideBubble();
77 return;
80 if (!this.errorText_)
81 return;
83 var self = this;
84 // Create the DOM tree for the bubble content.
85 var closeButton = document.createElement('div');
86 closeButton.classList.add('close-button');
88 var text = document.createElement('p');
89 text.innerHTML = this.errorText_;
91 var textDiv = document.createElement('div');
92 textDiv.appendChild(text);
94 var container = document.createElement('div');
95 container.appendChild(closeButton);
96 container.appendChild(textDiv);
98 var content = document.createElement('div');
99 content.appendChild(container);
101 PageManager.showBubble(content, this.image, this, this.location);
105 // Export
106 return {
107 HotwordSearchSettingIndicator: HotwordSearchSettingIndicator