diff options
15 files changed, 221 insertions, 57 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 752a05b..4498ebd 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -6682,6 +6682,9 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_OPTIONS_STARTUP_SHOW_PAGES" desc="The label of the 'Show these pages:' startup option radio button"> Open the following pages: </message> + <message name="IDS_OPTIONS_STARTUP_SHOW_MANY_PAGES" desc="The label of the 'Open several specific pages' startup option radio button"> + Open several specific pages + </message> <message name="IDS_OPTIONS_STARTUP_PAGE_TOOLTIP" desc="A tooltip to display for a page in the list of pages to open on startup"> <ph name="PAGE_TITLE">$1<ex>Google</ex></ph> - <ph name="PAGE_URL">$2<ex>http://www.google.com/</ex></ph> </message> @@ -6691,8 +6694,14 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_OPTIONS_STARTUP_REMOVE_BUTTON" desc="The label of the 'Remove' button for the custom startup urls list"> &Remove </message> + <message name="IDS_OPTIONS_STARTUP_MANAGE_BUTTON" desc="The label of the 'Use Current' button for the custom startup urls list"> + Manage Startup Pages + </message> <message name="IDS_OPTIONS_STARTUP_USE_CURRENT" desc="The label of the 'Use Current' button for the custom startup urls list"> - Use Current + Use Current Pages + </message> + <message name="IDS_STARTUP_PAGE_SUBPAGE_TITLE" desc="Title for startup page management subpage"> + Startup Pages </message> <message name="IDS_OPTIONS_TOOLBAR_GROUP_NAME" desc="The title of the toolbar group"> diff --git a/chrome/browser/dom_ui/options/browser_options_handler.cc b/chrome/browser/dom_ui/options/browser_options_handler.cc index 483e640..03773cb 100644 --- a/chrome/browser/dom_ui/options/browser_options_handler.cc +++ b/chrome/browser/dom_ui/options/browser_options_handler.cc @@ -52,10 +52,8 @@ void BrowserOptionsHandler::GetLocalizedValues( l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_SHOW_LAST_SESSION)); localized_strings->SetString("startupShowPages", l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_SHOW_PAGES)); - localized_strings->SetString("startupAddButton", - l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_ADD_BUTTON)); - localized_strings->SetString("startupRemoveButton", - l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_REMOVE_BUTTON)); + localized_strings->SetString("startupShowManyPages", + l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_SHOW_MANY_PAGES)); localized_strings->SetString("startupUseCurrent", l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_USE_CURRENT)); localized_strings->SetString("homepageGroupName", diff --git a/chrome/browser/dom_ui/options/options_ui.cc b/chrome/browser/dom_ui/options/options_ui.cc index 5a38d84..d298e86 100644 --- a/chrome/browser/dom_ui/options/options_ui.cc +++ b/chrome/browser/dom_ui/options/options_ui.cc @@ -32,6 +32,7 @@ #include "chrome/browser/dom_ui/options/passwords_exceptions_handler.h" #include "chrome/browser/dom_ui/options/personal_options_handler.h" #include "chrome/browser/dom_ui/options/search_engine_manager_handler.h" +#include "chrome/browser/dom_ui/options/startup_page_manager_handler.h" #include "chrome/browser/dom_ui/options/stop_syncing_handler.h" #include "chrome/browser/dom_ui/options/sync_options_handler.h" #include "chrome/browser/metrics/user_metrics.h" @@ -153,6 +154,7 @@ OptionsUI::OptionsUI(TabContents* contents) : DOMUI(contents) { AddOptionsPageUIHandler(localized_strings, new PasswordsExceptionsHandler()); AddOptionsPageUIHandler(localized_strings, new PersonalOptionsHandler()); AddOptionsPageUIHandler(localized_strings, new SearchEngineManagerHandler()); + AddOptionsPageUIHandler(localized_strings, new StartupPageManagerHandler()); AddOptionsPageUIHandler(localized_strings, new ImportDataHandler()); AddOptionsPageUIHandler(localized_strings, new StopSyncingHandler()); AddOptionsPageUIHandler(localized_strings, new SyncOptionsHandler()); diff --git a/chrome/browser/dom_ui/options/startup_page_manager_handler.cc b/chrome/browser/dom_ui/options/startup_page_manager_handler.cc new file mode 100644 index 0000000..f3c5c20 --- /dev/null +++ b/chrome/browser/dom_ui/options/startup_page_manager_handler.cc @@ -0,0 +1,30 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/dom_ui/options/startup_page_manager_handler.h" + +#include "app/l10n_util.h" +#include "base/values.h" +#include "grit/generated_resources.h" +#include "grit/locale_settings.h" + +StartupPageManagerHandler::StartupPageManagerHandler() { +} + +StartupPageManagerHandler::~StartupPageManagerHandler() { +} + +void StartupPageManagerHandler::GetLocalizedValues( + DictionaryValue* localized_strings) { + DCHECK(localized_strings); + + localized_strings->SetString("startupAddButton", + l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_ADD_BUTTON)); + localized_strings->SetString("startupRemoveButton", + l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_REMOVE_BUTTON)); + localized_strings->SetString("startupPageManagerPage", + l10n_util::GetStringUTF16(IDS_STARTUP_PAGE_SUBPAGE_TITLE)); + localized_strings->SetString("startupManagePages", + l10n_util::GetStringUTF16(IDS_OPTIONS_STARTUP_MANAGE_BUTTON)); +} diff --git a/chrome/browser/dom_ui/options/startup_page_manager_handler.h b/chrome/browser/dom_ui/options/startup_page_manager_handler.h new file mode 100644 index 0000000..440e887 --- /dev/null +++ b/chrome/browser/dom_ui/options/startup_page_manager_handler.h @@ -0,0 +1,23 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_DOM_UI_OPTIONS_STARTUP_PAGE_MANAGER_HANDLER_H_ +#define CHROME_BROWSER_DOM_UI_OPTIONS_STARTUP_PAGE_MANAGER_HANDLER_H_ + +#include "chrome/browser/dom_ui/options/options_ui.h" + +class StartupPageManagerHandler : public OptionsPageUIHandler { + public: + StartupPageManagerHandler(); + virtual ~StartupPageManagerHandler(); + + // OptionsUIHandler implementation. + virtual void GetLocalizedValues(DictionaryValue* localized_strings); + + private: + + DISALLOW_COPY_AND_ASSIGN(StartupPageManagerHandler); +}; + +#endif // CHROME_BROWSER_DOM_UI_OPTIONS_STARTUP_PAGE_MANAGER_HANDLER_H_ diff --git a/chrome/browser/resources/options/browser_options.html b/chrome/browser/resources/options/browser_options.html index 383a4aa..7470741 100644 --- a/chrome/browser/resources/options/browser_options.html +++ b/chrome/browser/resources/options/browser_options.html @@ -1,4 +1,4 @@ -<div class="page hidden" id="browserPage"> +<div id="browserPage" class="page hidden"> <h1 i18n-content="browserPage"></h1> <section id="startupSection"> <h3 i18n-content="startupGroupName"></h3> @@ -14,15 +14,14 @@ <label class="radio"><input type="radio" name="startup" id="startupShowPagesButton" pref="session.restore_on_startup" value="4" metric="Options_Startup_Custom"> - <span i18n-content="startupShowPages"></span></label> + <span id="startupShowPagesLabel" + i18n-content="startupShowPages"></span></label> <div class="suboption"> - <div id="startupPageManagement"> - <list id="startupPages"></list> + <div id="startupPageManagement" class="fullView"> + <list id="startupPagesShortList"></list> <div> - <button id="startupAddButton" - i18n-content="startupAddButton"></button> - <button id="startupRemoveButton" - i18n-content="startupRemoveButton"></button> + <button id="startupPageManagerButton" + i18n-content="startupManagePages"></button> <button id="startupUseCurrentButton" i18n-content="startupUseCurrent"></button> </div> diff --git a/chrome/browser/resources/options/browser_options.js b/chrome/browser/resources/options/browser_options.js index 303549f..2d734a9 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) { diff --git a/chrome/browser/resources/options/browser_options_page.css b/chrome/browser/resources/options/browser_options_page.css index 3a8b617..fc44c14 100644 --- a/chrome/browser/resources/options/browser_options_page.css +++ b/chrome/browser/resources/options/browser_options_page.css @@ -1,14 +1,14 @@ -#startupPageManagement { +#startupPageManagement.fullView { border: 1px solid #d9d9d9; border-radius: 2px; } -#startupPages { +#startupPagesShortList { height: auto; padding-bottom: 1px; } -#startupPageManagement > :last-child { +#startupPageManagement.fullView > :last-child { border-top: 1px solid #d9d9d9; padding: 5px 10px; } diff --git a/chrome/browser/resources/options/options.html b/chrome/browser/resources/options/options.html index f04ef75..95935fd 100644 --- a/chrome/browser/resources/options/options.html +++ b/chrome/browser/resources/options/options.html @@ -29,6 +29,7 @@ <link rel="stylesheet" href="import_data_overlay.css"> <link rel="stylesheet" href="search_engine_manager.css"> <link rel="stylesheet" href="search_page.css"> +<link rel="stylesheet" href="startup_page_manager.css"> <link rel="stylesheet" href="subpages_tab_controls.css"> <if expr="pp_ifdef('chromeos')"> <link rel="stylesheet" href="about_page.css"> @@ -125,6 +126,7 @@ <script src="search_engine_manager.js"></script> <script src="search_engine_manager_engine_list.js"></script> <script src="search_page.js"></script> +<script src="startup_page_manager.js"></script> <script src="sync_options.js"></script> <script src="options.js"></script> @@ -201,6 +203,7 @@ <include src="font_settings.html"> <include src="passwords_exceptions.html"> <include src="search_engine_manager.html"> + <include src="startup_page_manager.html"> <include src="sync_options.html"> </div> </div> diff --git a/chrome/browser/resources/options/options.js b/chrome/browser/resources/options/options.js index c4e382d..83b8154 100644 --- a/chrome/browser/resources/options/options.js +++ b/chrome/browser/resources/options/options.js @@ -20,9 +20,10 @@ var OptionsPage = options.OptionsPage; var PasswordsExceptions = options.PasswordsExceptions; var PersonalOptions = options.PersonalOptions; var Preferences = options.Preferences; +var ProxyOptions = options.ProxyOptions; var SearchEngineManager = options.SearchEngineManager; var SearchPage = options.SearchPage; -var ProxyOptions = options.ProxyOptions; +var StartupPageManager = options.StartupPageManager; var SyncOptions = options.SyncOptions; /** @@ -53,6 +54,8 @@ function load() { OptionsPage.register(BrowserOptions.getInstance()); OptionsPage.registerSubPage(SearchEngineManager.getInstance(), BrowserOptions.getInstance()); + OptionsPage.registerSubPage(StartupPageManager.getInstance(), + BrowserOptions.getInstance()); OptionsPage.register(PersonalOptions.getInstance()); OptionsPage.registerSubPage(AutoFillOptions.getInstance(), PersonalOptions.getInstance()); diff --git a/chrome/browser/resources/options/options_page.css b/chrome/browser/resources/options/options_page.css index 441adf9..195c18f 100644 --- a/chrome/browser/resources/options/options_page.css +++ b/chrome/browser/resources/options/options_page.css @@ -278,7 +278,7 @@ html[hide-menu=true] #mainview { } #subpage-sheet .page > h1 { - padding-top: 7px; + padding-top: 4px; } section { diff --git a/chrome/browser/resources/options/startup_page_manager.css b/chrome/browser/resources/options/startup_page_manager.css new file mode 100644 index 0000000..e82169a --- /dev/null +++ b/chrome/browser/resources/options/startup_page_manager.css @@ -0,0 +1,6 @@ +#startupPagesFullList { + border: 1px solid #d9d9d9; + border-radius: 2px; + height: auto; + padding-bottom: 1px; +} diff --git a/chrome/browser/resources/options/startup_page_manager.html b/chrome/browser/resources/options/startup_page_manager.html new file mode 100644 index 0000000..0b469e4 --- /dev/null +++ b/chrome/browser/resources/options/startup_page_manager.html @@ -0,0 +1,6 @@ +<div id="startupPageManagerPage" class="page hidden"> + <h1 i18n-content="startupPageManagerPage"></h1> + <list id="startupPagesFullList"></list> + <button id="startupAddButton" i18n-content="startupAddButton"></button> + <button id="startupRemoveButton" i18n-content="startupRemoveButton"></button> +</div> diff --git a/chrome/browser/resources/options/startup_page_manager.js b/chrome/browser/resources/options/startup_page_manager.js new file mode 100644 index 0000000..54e1148 --- /dev/null +++ b/chrome/browser/resources/options/startup_page_manager.js @@ -0,0 +1,94 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +cr.define('options', function() { + const OptionsPage = options.OptionsPage; + const ArrayDataModel = cr.ui.ArrayDataModel; + const ListSelectionModel = cr.ui.ListSelectionModel; + + /** + * Encapsulated handling of startup page management page. + * @constructor + */ + function StartupPageManager() { + this.activeNavTab = null; + OptionsPage.call(this, 'startupPages', + templateData.StartupPageManagerPage, + 'startupPageManagerPage'); + } + + cr.addSingletonGetter(StartupPageManager); + + StartupPageManager.prototype = { + __proto__: OptionsPage.prototype, + list_: null, + + initializePage: function() { + OptionsPage.prototype.initializePage.call(this); + + var list = $('startupPagesFullList'); + options.browser_options.StartupPageList.decorate(list); + list.autoExpands = true; + list.selectionModel = new ListSelectionModel; + + list.selectionModel.addEventListener( + 'change', this.updateRemoveButtonState_.bind(this)); + + // Wire up controls. + $('startupAddButton').onclick = function(event) { + OptionsPage.showOverlay('addStartupPageOverlay'); + }; + $('startupRemoveButton').onclick = + this.removeSelectedStartupPages_.bind(this); + + // 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'); + }, + + /** + * Updates the startup pages list with the given entries. + * @param {Array} pages List of startup pages. + * @private + */ + updateStartupPages_: function(pages) { + $('startupPagesFullList').dataModel = new ArrayDataModel(pages); + 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() { + $('startupRemoveButton').disabled = + $('startupPagesFullList').selectionModel.selectedIndex == -1; + }, + + /** + * Removes the selected startup pages. + * @private + */ + removeSelectedStartupPages_: function() { + var selections = + $('startupPagesFullList').selectionModel.selectedIndexes.map(String); + chrome.send('removeStartupPages', selections); + }, + }; + + StartupPageManager.updateStartupPages = function(pages) { + StartupPageManager.getInstance().updateStartupPages_(pages); + }; + + // Export + return { + StartupPageManager: StartupPageManager + }; + +}); + diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 1857ede..57df519 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -939,12 +939,14 @@ 'browser/dom_ui/options/passwords_exceptions_handler.h', 'browser/dom_ui/options/personal_options_handler.cc', 'browser/dom_ui/options/personal_options_handler.h', + 'browser/dom_ui/options/search_engine_manager_handler.cc', + 'browser/dom_ui/options/search_engine_manager_handler.h', + 'browser/dom_ui/options/startup_page_manager_handler.cc', + 'browser/dom_ui/options/startup_page_manager_handler.h', 'browser/dom_ui/options/stop_syncing_handler.cc', 'browser/dom_ui/options/stop_syncing_handler.h', 'browser/dom_ui/options/sync_options_handler.cc', 'browser/dom_ui/options/sync_options_handler.h', - 'browser/dom_ui/options/search_engine_manager_handler.cc', - 'browser/dom_ui/options/search_engine_manager_handler.h', 'browser/dom_ui/shared_resources_data_source.cc', 'browser/dom_ui/shared_resources_data_source.h', 'browser/dom_ui/shown_sections_handler.cc', |