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

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

Issue 3058018: Revert 53849 - Implement most of the startup page controls in DOMUI prefs... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 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
« no previous file with comments | « chrome/browser/resources/options/browser_options.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // 5 //
6 // BrowserOptions class 6 // BrowserOptions class
7 // Encapsulated handling of browser options page. 7 // Encapsulated handling of browser options page.
8 // 8 //
9 function BrowserOptions() { 9 function BrowserOptions() {
10 OptionsPage.call(this, 'browser', templateData.browserPage, 'browserPage'); 10 OptionsPage.call(this, 'browser', templateData.browserPage, 'browserPage');
11 } 11 }
12 12
13 cr.addSingletonGetter(BrowserOptions); 13 cr.addSingletonGetter(BrowserOptions);
14 14
15 BrowserOptions.prototype = { 15 BrowserOptions.prototype = {
16 // Inherit BrowserOptions from OptionsPage. 16 // Inherit BrowserOptions from OptionsPage.
17 __proto__: OptionsPage.prototype, 17 __proto__: OptionsPage.prototype,
18 18
19 /** 19 /**
20 * Initialize BrowserOptions page. 20 * Initialize BrowserOptions page.
21 */ 21 */
22 initializePage: function() { 22 initializePage: function() {
23 // Call base class implementation to start preference initialization. 23 // Call base class implementation to start preference initialization.
24 OptionsPage.prototype.initializePage.call(this); 24 OptionsPage.prototype.initializePage.call(this);
25 25
26 // Wire up controls. 26 // Wire up buttons.
27 var self = this;
28 $('startupPages').onchange = function(event) {
29 self.updateRemoveButtonState_();
30 };
31 $('startupAddButton').onclick = function(event) { 27 $('startupAddButton').onclick = function(event) {
32 OptionsPage.showOverlay('addStartupPageOverlay'); 28 OptionsPage.showOverlay('addStartupPageOverlay');
33 }; 29 };
34 $('startupRemoveButton').onclick = function(event) { 30 $('startupRemoveButton').onclick = function(event) {
35 self.removeSelectedStartupPages_(); 31 // TODO(stuartmorgan): Remove selected element(s).
36 }; 32 };
37 $('startupUseCurrentButton').onclick = function(event) { 33 $('startupUseCurrentButton').onclick = function(event) {
38 chrome.send('setStartupPagesToCurrentPages'); 34 // TODO(stuartmorgan): Add all open tabs (except this one).
39 }; 35 };
40 $('defaultSearchManageEnginesButton').onclick = function(event) { 36 $('defaultSearchManageEnginesButton').onclick = function(event) {
41 OptionsPage.showPageByName('searchEngines'); 37 OptionsPage.showPageByName('searchEngines');
42 }; 38 };
43 $('defaultBrowserUseAsDefaultButton').onclick = function(event) { 39 $('defaultBrowserUseAsDefaultButton').onclick = function(event) {
44 chrome.send('becomeDefaultBrowser'); 40 chrome.send('becomeDefaultBrowser');
45 }; 41 };
46 42
47 // Remove Windows-style accelerators from button labels. 43 // Remove Windows-style accelerators from button labels.
48 // TODO(stuartmorgan): Remove this once the strings are updated. 44 // TODO(stuartmorgan): Remove this once the strings are updated.
(...skipping 29 matching lines...) Expand all
78 }, 74 },
79 75
80 /** 76 /**
81 * Updates the search engine popup with the given entries. 77 * Updates the search engine popup with the given entries.
82 * @param {Array} engines List of available search engines. 78 * @param {Array} engines List of available search engines.
83 * @param {Integer} defaultValue The value of the current default engine. 79 * @param {Integer} defaultValue The value of the current default engine.
84 */ 80 */
85 updateSearchEngines_: function(engines, defaultValue) { 81 updateSearchEngines_: function(engines, defaultValue) {
86 this.clearSearchEngines_(); 82 this.clearSearchEngines_();
87 engineSelect = $('defaultSearchEngine'); 83 engineSelect = $('defaultSearchEngine');
88 engineCount = engines.length; 84 engineCount = engines.length
89 var defaultIndex = -1; 85 var defaultIndex = -1;
90 for (var i = 0; i < engineCount; i++) { 86 for (var i = 0; i < engineCount; i++) {
91 var engine = engines[i]; 87 var engine = engines[i]
92 var option = new Option(engine['name'], engine['index']); 88 var option = new Option(engine['name'], engine['index']);
93 if (defaultValue == option.value) 89 if (defaultValue == option.value)
94 defaultIndex = i; 90 defaultIndex = i;
95 engineSelect.appendChild(option); 91 engineSelect.appendChild(option);
96 } 92 }
97 if (defaultIndex >= 0) 93 if (defaultIndex >= 0)
98 engineSelect.selectedIndex = defaultIndex; 94 engineSelect.selectedIndex = defaultIndex;
99 }, 95 },
100 96
101 /** 97 /**
102 * Clears the startup page list.
103 * @private
104 */
105 clearStartupPages_: function() {
106 $('startupPages').textContent = '';
107 },
108
109 /**
110 * Updates the startup pages list with the given entries.
111 * @param {Array} pages List of startup pages.
112 */
113 updateStartupPages_: function(pages) {
114 // TODO(stuartmorgan): Replace <select> with a DOMUI List.
115 this.clearStartupPages_();
116 pageList = $('startupPages');
117 pageCount = pages.length;
118 for (var i = 0; i < pageCount; i++) {
119 var page = pages[i];
120 var option = new Option(page['title']);
121 option.title = page['tooltip'];
122 pageList.appendChild(option);
123 }
124
125 this.updateRemoveButtonState_();
126 },
127
128 /**
129 * Sets the enabled state of the startup page Remove button based on
130 * the current selection in the startup pages list.
131 */
132 updateRemoveButtonState_: function() {
133 $('startupRemoveButton').disabled = ($('startupPages').selectedIndex == -1);
134 },
135
136 /**
137 * Removes the selected startup pages.
138 */
139 removeSelectedStartupPages_: function() {
140 var pageSelect = $('startupPages');
141 var optionCount = pageSelect.options.length;
142 var selections = [];
143 for (var i = 0; i < optionCount; i++) {
144 if (pageSelect.options[i].selected)
145 selections.push(String(i));
146 }
147 chrome.send('removeStartupPages', selections);
148 },
149
150 /**
151 * Set the default search engine based on the popup selection. 98 * Set the default search engine based on the popup selection.
152 */ 99 */
153 setDefaultBrowser: function() { 100 setDefaultBrowser: function() {
154 var engineSelect = $('defaultSearchEngine'); 101 var engineSelect = $('defaultSearchEngine');
155 var selectedIndex = engineSelect.selectedIndex; 102 var selectedIndex = engineSelect.selectedIndex;
156 if (selectedIndex >= 0) { 103 if (selectedIndex >= 0) {
157 var selection = engineSelect.options[selectedIndex]; 104 var selection = engineSelect.options[selectedIndex];
158 chrome.send('setDefaultSearchEngine', [String(selection.value)]); 105 chrome.send('setDefaultSearchEngine', [String(selection.value)]);
159 } 106 }
160 }, 107 },
161 }; 108 };
162 109
163 BrowserOptions.updateDefaultBrowserState = function(statusString, isDefault) { 110 BrowserOptions.updateDefaultBrowserState = function(statusString, isDefault) {
164 BrowserOptions.getInstance().updateDefaultBrowserState_(statusString, 111 BrowserOptions.getInstance().updateDefaultBrowserState_(statusString,
165 isDefault); 112 isDefault);
166 }; 113 }
167 114
168 BrowserOptions.updateSearchEngines = function(engines, defaultValue) { 115 BrowserOptions.updateSearchEngines = function(engines, defaultValue) {
169 BrowserOptions.getInstance().updateSearchEngines_(engines, defaultValue); 116 BrowserOptions.getInstance().updateSearchEngines_(engines, defaultValue);
170 }; 117 }
171
172 BrowserOptions.updateStartupPages = function(pages) {
173 BrowserOptions.getInstance().updateStartupPages_(pages);
174 };
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/browser_options.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698