Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / resources / settings / search_engines_page / search_engine_entry.js
blobdb9e80d623dfd7031dfc0835dc6d5b881ccc39c6
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 /**
6  * @fileoverview 'cr-search-engine-entry' is a component for showing a search
7  * engine with its name, domain and query URL.
8  *
9  * @group Chrome Settings Elements
10  * @element cr-search-engine-entry
11  */
12 Polymer({
13   is: 'cr-search-engine-entry',
15   properties: {
16     /** @type {!SearchEngine} */
17     engine: Object
18   },
20   /** @private */
21   deleteEngine_: function() {
22     chrome.searchEnginesPrivate.removeSearchEngine(this.engine.guid);
23   },
25   /** @private */
26   makeDefault_: function() {
27     chrome.searchEnginesPrivate.setSelectedSearchEngine(this.engine.guid);
28     this.makeNotEditable_();
29   },
31   /** @private */
32   toggleEditable_: function() {
33     this.$.domainField.disabled = !this.$.domainField.disabled;
34     this.$.keywordField.disabled = !this.$.keywordField.disabled;
35     this.$.queryURLField.disabled = !this.$.queryURLField.disabled;
37     this.$.checkIcon.hidden =
38         !this.$.checkIcon.hidden || this.engine.isSelected;
39     this.$.deleteIcon.hidden =
40         !this.$.deleteIcon.hidden || this.engine.isSelected;
41   },
43   /** @private */
44   makeNotEditable_: function() {
45     this.$.domainField.disabled = true;
46     this.$.keywordField.disabled = true;
47     this.$.queryURLField.disabled = true;
49     this.$.checkIcon.hidden = true;
50     this.$.deleteIcon.hidden = true;
51   },
53   /** @private */
54   fieldChanged_: function() {
55     // NOTE: This currently doesn't fire in response to a change event from the
56     // cr-input, even though it should. This Polymer change should fix the
57     // issue:  https://github.com/PolymerElements/paper-input/pull/33
58     chrome.searchEnginesPrivate.updateSearchEngine(
59         this.engine.guid,
60         this.$.domainField.value,
61         this.$.keywordField.value,
62         this.$.queryURLField.value);
63     this.makeNotEditable_();
64   }
65 });