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

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

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

Powered by Google App Engine
This is Rietveld 408576698