Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: chrome/browser/resources/options/search_engine_manager_engine_list.js

Issue 552883002: Compile chrome://settings, part 4: 149 proper errors left (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@H_options_errors_2
Patch Set: reannotate createItem() Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /**
6 * @typedef {{
7 * canBeDefault: boolean,
8 * canBeEdited: boolean,
9 * canBeRemoved: boolean,
10 * default: boolean,
11 * displayName: string,
12 * extension: (Object|undefined),
13 * iconURL: (string|undefined),
14 * isExtension: boolean,
15 * keyword: string,
16 * modelIndex: string,
17 * name: string,
18 * url: string,
19 * urlLocked: boolean
Dan Beam 2014/09/12 23:29:09 nit: indent keys
Vitaly Pavlenko 2014/09/12 23:51:59 Done.
20 * }}
21 * @see chrome/browser/ui/webui/options/search_engine_manager_handler.cc
22 */
23 var SearchEngine;
24
5 cr.define('options.search_engines', function() { 25 cr.define('options.search_engines', function() {
6 /** @const */ var ControlledSettingIndicator = 26 /** @const */ var ControlledSettingIndicator =
7 options.ControlledSettingIndicator; 27 options.ControlledSettingIndicator;
8 /** @const */ var InlineEditableItemList = options.InlineEditableItemList; 28 /** @const */ var InlineEditableItemList = options.InlineEditableItemList;
9 /** @const */ var InlineEditableItem = options.InlineEditableItem; 29 /** @const */ var InlineEditableItem = options.InlineEditableItem;
10 /** @const */ var ListSelectionController = cr.ui.ListSelectionController; 30 /** @const */ var ListSelectionController = cr.ui.ListSelectionController;
11 31
12 /** 32 /**
13 * Creates a new search engine list item. 33 * Creates a new search engine list item.
14 * @param {Object} searchEngine The search engine this represents. 34 * @param {SearchEngine} searchEngine The search engine this represents.
15 * @constructor 35 * @constructor
16 * @extends {cr.ui.ListItem} 36 * @extends {options.InlineEditableItem}
17 */ 37 */
18 function SearchEngineListItem(searchEngine) { 38 function SearchEngineListItem(searchEngine) {
19 var el = cr.doc.createElement('div'); 39 var el = cr.doc.createElement('div');
20 el.searchEngine_ = searchEngine; 40 el.searchEngine_ = searchEngine;
21 SearchEngineListItem.decorate(el); 41 SearchEngineListItem.decorate(el);
22 return el; 42 return el;
23 } 43 }
24 44
25 /** 45 /**
26 * Decorates an element as a search engine list item. 46 * Decorates an element as a search engine list item.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 */ 82 */
63 waitingForValidation_: false, 83 waitingForValidation_: false,
64 84
65 /** 85 /**
66 * Whether or not the current set of input is known to be valid. 86 * Whether or not the current set of input is known to be valid.
67 * @type {boolean} 87 * @type {boolean}
68 * @private 88 * @private
69 */ 89 */
70 currentlyValid_: false, 90 currentlyValid_: false,
71 91
92 /**
93 * @type {?SearchEngine}
94 */
95 searchEngine_: null,
96
72 /** @override */ 97 /** @override */
73 decorate: function() { 98 decorate: function() {
74 InlineEditableItem.prototype.decorate.call(this); 99 InlineEditableItem.prototype.decorate.call(this);
75 100
76 var engine = this.searchEngine_; 101 var engine = this.searchEngine_;
77 102
78 if (engine.modelIndex == '-1') { 103 if (engine.modelIndex == '-1') {
79 this.isPlaceholder = true; 104 this.isPlaceholder = true;
80 engine.name = ''; 105 engine.name = '';
81 engine.keyword = ''; 106 engine.keyword = '';
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 // Don't select the row when clicking the button. 164 // Don't select the row when clicking the button.
140 e.stopPropagation(); 165 e.stopPropagation();
141 // Don't focus on the button. 166 // Don't focus on the button.
142 e.preventDefault(); 167 e.preventDefault();
143 }; 168 };
144 urlWithButtonEl.appendChild(makeDefaultButtonEl); 169 urlWithButtonEl.appendChild(makeDefaultButtonEl);
145 } 170 }
146 } 171 }
147 172
148 // Do final adjustment to the input fields. 173 // Do final adjustment to the input fields.
149 this.nameField_ = nameEl.querySelector('input'); 174 this.nameField_ = /** @type {HTMLElement} */(
175 nameEl.querySelector('input'));
150 // The editable field uses the raw name, not the display name. 176 // The editable field uses the raw name, not the display name.
151 this.nameField_.value = engine.name; 177 this.nameField_.value = engine.name;
152 this.keywordField_ = keywordEl.querySelector('input'); 178 this.keywordField_ = /** @type {HTMLElement} */(
153 this.urlField_ = urlEl.querySelector('input'); 179 keywordEl.querySelector('input'));
180 this.urlField_ = /** @type {HTMLElement} */(urlEl.querySelector('input'));
154 181
155 if (engine.urlLocked) 182 if (engine.urlLocked)
156 this.urlField_.disabled = true; 183 this.urlField_.disabled = true;
157 184
158 if (engine.isExtension) 185 if (engine.isExtension)
159 this.nameField_.disabled = true; 186 this.nameField_.disabled = true;
160 187
161 if (this.isPlaceholder) { 188 if (this.isPlaceholder) {
162 this.nameField_.placeholder = 189 this.nameField_.placeholder =
163 loadTimeData.getString('searchEngineTableNamePlaceholder'); 190 loadTimeData.getString('searchEngineTableNamePlaceholder');
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 this.urlField_.setCustomValidity(''); 320 this.urlField_.setCustomValidity('');
294 } else { 321 } else {
295 this.urlField_.setCustomValidity( 322 this.urlField_.setCustomValidity(
296 loadTimeData.getString('editSearchEngineInvalidURLToolTip')); 323 loadTimeData.getString('editSearchEngineInvalidURLToolTip'));
297 } 324 }
298 325
299 this.currentlyValid_ = validity.name && validity.keyword && validity.url; 326 this.currentlyValid_ = validity.name && validity.keyword && validity.url;
300 }, 327 },
301 }; 328 };
302 329
330 /**
331 * @constructor
332 * @extends {options.InlineEditableItemList}
333 */
303 var SearchEngineList = cr.ui.define('list'); 334 var SearchEngineList = cr.ui.define('list');
304 335
305 SearchEngineList.prototype = { 336 SearchEngineList.prototype = {
306 __proto__: InlineEditableItemList.prototype, 337 __proto__: InlineEditableItemList.prototype,
307 338
308 /** @override */ 339 /**
340 * @override
341 * @param {SearchEngine} searchEngine
342 */
309 createItem: function(searchEngine) { 343 createItem: function(searchEngine) {
310 return new SearchEngineListItem(searchEngine); 344 return new SearchEngineListItem(searchEngine);
311 }, 345 },
312 346
313 /** @override */ 347 /** @override */
314 deleteItemAtIndex: function(index) { 348 deleteItemAtIndex: function(index) {
315 var modelIndex = this.dataModel.item(index).modelIndex; 349 var modelIndex = this.dataModel.item(index).modelIndex;
316 chrome.send('removeSearchEngine', [String(modelIndex)]); 350 chrome.send('removeSearchEngine', [String(modelIndex)]);
317 }, 351 },
318 352
(...skipping 14 matching lines...) Expand all
333 }, 367 },
334 }; 368 };
335 369
336 // Export 370 // Export
337 return { 371 return {
338 SearchEngineList: SearchEngineList 372 SearchEngineList: SearchEngineList
339 }; 373 };
340 374
341 }); 375 });
342 376
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/search_engine_manager.js ('k') | chrome/browser/resources/options/search_page.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698