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

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

Issue 9814030: get rid of old options pages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixes Created 8 years, 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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.
4
5 cr.define('options', function() {
6 const OptionsPage = options.OptionsPage;
7 const ArrayDataModel = cr.ui.ArrayDataModel;
8
9 /**
10 * Encapsulated handling of search engine management page.
11 * @constructor
12 */
13 function SearchEngineManager() {
14 this.activeNavTab = null;
15 OptionsPage.call(this, 'searchEngines',
16 templateData.searchEngineManagerPageTabTitle,
17 'search-engine-manager-page');
18 }
19
20 cr.addSingletonGetter(SearchEngineManager);
21
22 SearchEngineManager.prototype = {
23 __proto__: OptionsPage.prototype,
24
25 /**
26 * List for default search engine options.
27 * @private
28 */
29 defaultsList_: null,
30
31 /**
32 * List for other search engine options.
33 * @private
34 */
35 othersList_: null,
36
37 /**
38 * List for extension keywords.
39 * @private
40 extensionList_ : null,
41
42 /** inheritDoc */
43 initializePage: function() {
44 OptionsPage.prototype.initializePage.call(this);
45
46 this.defaultsList_ = $('default-search-engine-list');
47 this.setUpList_(this.defaultsList_);
48
49 this.othersList_ = $('other-search-engine-list');
50 this.setUpList_(this.othersList_);
51
52 this.extensionList_ = $('extension-keyword-list');
53 this.setUpList_(this.extensionList_);
54 },
55
56 /**
57 * Sets up the given list as a search engine list
58 * @param {List} list The list to set up.
59 * @private
60 */
61 setUpList_: function(list) {
62 options.search_engines.SearchEngineList.decorate(list);
63 list.autoExpands = true;
64 },
65
66 /**
67 * Updates the search engine list with the given entries.
68 * @private
69 * @param {Array} defaultEngines List of possible default search engines.
70 * @param {Array} otherEngines List of other search engines.
71 * @param {Array} keywords List of keywords from extensions.
72 */
73 updateSearchEngineList_: function(defaultEngines, otherEngines, keywords) {
74 this.defaultsList_.dataModel = new ArrayDataModel(defaultEngines);
75
76 otherEngines = otherEngines.map(function(x) {
77 return [x, x['name'].toLocaleLowerCase()];
78 }).sort(function(a,b){
79 return a[1].localeCompare(b[1]);
80 }).map(function(x){
81 return x[0];
82 });
83
84 var othersModel = new ArrayDataModel(otherEngines);
85 // Add a "new engine" row.
86 othersModel.push({
87 'modelIndex': '-1',
88 'canBeEdited': true
89 });
90 this.othersList_.dataModel = othersModel;
91
92 if (keywords.length > 0) {
93 $('extension-keyword-div').hidden = false;
94 var extensionsModel = new ArrayDataModel(keywords);
95 this.extensionList_.dataModel = extensionsModel;
96 } else {
97 $('extension-keyword-div').hidden = true;
98 }
99 },
100 };
101
102 SearchEngineManager.updateSearchEngineList = function(defaultEngines,
103 otherEngines,
104 keywords) {
105 SearchEngineManager.getInstance().updateSearchEngineList_(defaultEngines,
106 otherEngines,
107 keywords);
108 };
109
110 SearchEngineManager.validityCheckCallback = function(validity, modelIndex) {
111 // Forward to both lists; the one without a matching modelIndex will ignore
112 // it.
113 SearchEngineManager.getInstance().defaultsList_.validationComplete(
114 validity, modelIndex);
115 SearchEngineManager.getInstance().othersList_.validationComplete(
116 validity, modelIndex);
117 };
118
119 // Export
120 return {
121 SearchEngineManager: SearchEngineManager
122 };
123
124 });
125
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698