Index: chrome/browser/resources/options/browser_options.js |
diff --git a/chrome/browser/resources/options/browser_options.js b/chrome/browser/resources/options/browser_options.js |
index 303549fdf86653e9d7d5bdf6a27e72ab1734ac1b..2d734a9706d61481a5e4dbdb57bb8d4b3399727b 100644 |
--- a/chrome/browser/resources/options/browser_options.js |
+++ b/chrome/browser/resources/options/browser_options.js |
@@ -41,14 +41,12 @@ cr.define('options', function() { |
OptionsPage.prototype.initializePage.call(this); |
// Wire up controls. |
- $('startupAddButton').onclick = function(event) { |
- OptionsPage.showOverlay('addStartupPageOverlay'); |
- }; |
- $('startupRemoveButton').onclick = |
- this.removeSelectedStartupPages_.bind(this); |
$('startupUseCurrentButton').onclick = function(event) { |
chrome.send('setStartupPagesToCurrentPages'); |
}; |
+ $('startupPageManagerButton').onclick = function(event) { |
+ OptionsPage.showPageByName('startupPages'); |
+ }; |
$('defaultSearchManageEnginesButton').onclick = function(event) { |
OptionsPage.showPageByName('searchEngines'); |
chrome.send('coreOptionsUserMetricsAction', |
@@ -85,18 +83,16 @@ cr.define('options', function() { |
}; |
} |
- var list = $('startupPages'); |
+ var list = $('startupPagesShortList'); |
options.browser_options.StartupPageList.decorate(list); |
list.autoExpands = true; |
list.selectionModel = new ListSelectionModel; |
- list.selectionModel.addEventListener( |
- 'change', this.updateRemoveButtonState_.bind(this)); |
- |
// Check if we are in the guest mode. |
if (cr.commandLine.options['--bwsi']) { |
- // Disable input and button elements under the startup section. |
- var elements = $('startupSection').querySelectorAll('input, button'); |
+ // Disable all controls under the startup section. |
+ var elements = |
+ $('startupSection').querySelectorAll('input, button, list'); |
for (var i = 0; i < elements.length; i++) { |
elements[i].disabled = true; |
elements[i].manually_disabled = true; |
@@ -112,13 +108,6 @@ cr.define('options', function() { |
this.updateCustomStartupPageControlStates_(); |
} |
- |
- // Remove Windows-style accelerators from button labels. |
- // TODO(stuartmorgan): Remove this once the strings are updated. |
- $('startupAddButton').textContent = |
- localStrings.getStringWithoutAccelerator('startupAddButton'); |
- $('startupRemoveButton').textContent = |
- localStrings.getStringWithoutAccelerator('startupRemoveButton'); |
}, |
/** |
@@ -184,9 +173,19 @@ cr.define('options', function() { |
* @param {Array} pages List of startup pages. |
*/ |
updateStartupPages_: function(pages) { |
- // TODO(stuartmorgan): Once the sub-page is done, handle 0 and > 10 pages. |
- $('startupPages').dataModel = new ArrayDataModel(pages); |
- this.updateRemoveButtonState_(); |
+ var list = $('startupPagesShortList'); |
+ list.dataModel = new ArrayDataModel(pages); |
+ if (pages.length > 0 && pages.length <= 10) { |
+ list.classList.remove("hidden"); |
+ $('startupPageManagement').classList.add('fullView'); |
+ $('startupShowPagesLabel').textContent = |
+ localStrings.getStringWithoutAccelerator('startupShowPages'); |
+ } else { |
+ list.classList.add("hidden"); |
+ $('startupPageManagement').classList.remove('fullView'); |
+ $('startupShowPagesLabel').textContent = |
+ localStrings.getStringWithoutAccelerator('startupShowManyPages'); |
+ } |
}, |
/** |
@@ -348,21 +347,9 @@ cr.define('options', function() { |
*/ |
updateCustomStartupPageControlStates_: function() { |
var disable = !this.shouldEnableCustomStartupPageControls_(); |
- $('startupPages').disabled = disable; |
- $('startupAddButton').disabled = disable; |
+ $('startupPagesShortList').disabled = disable; |
$('startupUseCurrentButton').disabled = disable; |
- this.updateRemoveButtonState_(); |
- }, |
- |
- /** |
- * Sets the enabled state of the startup page Remove button based on |
- * the current selection in the startup pages list. |
- * @private |
- */ |
- updateRemoveButtonState_: function() { |
- var groupEnabled = this.shouldEnableCustomStartupPageControls_(); |
- $('startupRemoveButton').disabled = !groupEnabled || |
- ($('startupPages').selectionModel.selectedIndex == -1); |
+ $('startupPageManagerButton').disabled = disable; |
}, |
/** |
@@ -371,7 +358,7 @@ cr.define('options', function() { |
*/ |
removeSelectedStartupPages_: function() { |
var selections = |
- $('startupPages').selectionModel.selectedIndexes.map(String); |
+ $('startupPagesShortList').selectionModel.selectedIndexes.map(String); |
chrome.send('removeStartupPages', selections); |
}, |
@@ -380,7 +367,8 @@ cr.define('options', function() { |
* @private |
*/ |
addStartupPage_: function(url) { |
- var firstSelection = $('startupPages').selectionModel.selectedIndex; |
+ var firstSelection = |
+ $('startupPagesShortList').selectionModel.selectedIndex; |
chrome.send('addStartupPage', [url, String(firstSelection)]); |
}, |
@@ -412,6 +400,7 @@ cr.define('options', function() { |
BrowserOptions.updateStartupPages = function(pages) { |
BrowserOptions.getInstance().updateStartupPages_(pages); |
+ StartupPageManager.getInstance().updateStartupPages_(pages); |
}; |
BrowserOptions.addStartupPage = function(url) { |