diff options
author | csilv@chromium.org <csilv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-21 02:00:31 +0000 |
---|---|---|
committer | csilv@chromium.org <csilv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-21 02:00:31 +0000 |
commit | 6cd9455e58104831eb1a5a9a1c2288df7b1b0411 (patch) | |
tree | 24857a0202097b00e5d84d3b74145c27cd1c7db0 /chrome | |
parent | c247cab7f2cf58a73b646cc77c02b68b66be2951 (diff) | |
download | chromium_src-6cd9455e58104831eb1a5a9a1c2288df7b1b0411.zip chromium_src-6cd9455e58104831eb1a5a9a1c2288df7b1b0411.tar.gz chromium_src-6cd9455e58104831eb1a5a9a1c2288df7b1b0411.tar.bz2 |
dom-ui settings: enable languages & spell checker settings for all platforms.
BUG=56415,43716
TEST=Verify language & settings panel functionality on dom-ui settings window.
Review URL: http://codereview.chromium.org/6296017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72085 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
15 files changed, 458 insertions, 220 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index f8dbf26..54c7609 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -6360,6 +6360,69 @@ Keep your key file in a safe place. You will need it to create new versions of y Lorem ipsum dolor sit amet, consectetur adipiscing elit. </message> + <!-- Language & spell-checker settings --> + <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_DIALOG_TITLE"> + Languages and Input + </message> + <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_LANGUAGES" desc="The label for the list of languages"> + Languages + </message> + <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_ADD_BUTTON" + desc="The label for the add button for adding a language"> + Add + </message> + <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_REMOVE_BUTTON" + desc="The label for the remove button for removing a language"> + Remove + </message> + <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_ADD_LANGUAGE_INSTRUCTIONS" + desc="Explanatory message about how to add and order languages"> + Add languages and drag to order them based on your preference. + </message> + <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_PLEASE_ADD_ANOTHER_LANGUAGE" + desc="Warning invoked when the user tries to remove the last language"> + Please add another language before removing this one. + </message> + <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_CANNOT_BE_DISPLAYED_IN_THIS_LANGUAGE" + desc="The label for a language that cannot be used for UI"> + <ph name="PRODUCT_NAME">$1<ex>Chrome OS</ex></ph> cannot be displayed in this language + </message> + <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_IS_DISPLAYED_IN_THIS_LANGUAGE" + desc="The label for a language that is currently used for UI"> + <ph name="PRODUCT_NAME">$1<ex>Chrome OS</ex></ph> is displayed in this language + </message> + <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_DISPLAY_IN_THIS_LANGUAGE" + desc="The label is used for a button that changes the UI + language of Chrome OS"> + Display <ph name="PRODUCT_NAME">$1<ex>Chrome OS</ex></ph> in this language + </message> + <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_THIS_LANGUAGE_IS_CURRENTLY_IN_USE" + desc="Warning invoked when the user tries to remove the language used for displaying Chrome OS"> + This language is currently in use for displaying <ph name="PRODUCT_NAME">$1<ex>Chrome OS</ex></ph>. + </message> + <message name="IDS_OPTIONS_SETTINGS_USE_THIS_FOR_SPELL_CHECKING" + desc="The label for a language a button that changes the spell check language of Chrome OS"> + Use this language for spell checking + </message> + <message name="IDS_OPTIONS_SETTINGS_CANNOT_BE_USED_FOR_SPELL_CHECKING" + desc="The label for a language that cannot be used for spell checking"> + This language cannot be used for spell checking + </message> + <message name="IDS_OPTIONS_SETTINGS_IS_USED_FOR_SPELL_CHECKING" + desc="The label for a language that is currently used for spell checking"> + This language is used for spell checking + </message> + <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_RESTART_BUTTON" + desc="The label for the restart button for changing UI language"> + Restart + </message> + <message name="IDS_OPTIONS_LANGUAGES_ADD_TITLE" desc="The title for the add language dialog."> + Add language: + </message> + <message name="IDS_OPTIONS_LANGUAGES_ADD_SELECT_LABEL" desc="The label for the add language select control."> + Language: + </message> + <!-- HTTP POST Warning --> <message name="IDS_HTTP_POST_WARNING_TITLE" desc="Title for dialog that warns users about a navigation that results in a repost"> Confirm Form Resubmission @@ -7782,15 +7845,18 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_OPTIONS_FONT_SIZE_LABEL_CUSTOM" desc="The label of the 'Custom' option"> Custom </message> + <message name="IDS_OPTIONS_LANGUAGE_AND_SPELLCHECK_BUTTON" desc="Button title for invoking the 'Languages and Spell-checker' panel."> + Languages and Spell-checker settings + </message> <message name="IDS_OPTIONS_CHROME_DICTIONARY_LANGUAGE" desc="The documentation string of the 'Spell check dictionary language' preference"> Spell-checker language: </message> <message name="IDS_OPTIONS_ENABLE_SPELLCHECK" desc="The documentation string of the 'Enable spellcheck' option"> - Check spelling: + Enable spell checking </message> <message name="IDS_OPTIONS_ENABLE_AUTO_SPELL_CORRECTION" desc="The documentation string of the 'Enable auto spell correction' option"> - Correct spelling automatically: + Enable automatic spell correction </message> <!-- TODO(kmadhusu): Remove "IDS_OPTIONS_RESET", "IDS_OPTIONS_RESET_OKLABEL", "IDS_OPTIONS_RESET_CANCELLABEL" after platform-specific dialogs are removed.--> @@ -9552,12 +9618,7 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_MODIFIER_KEYS_CUSTOMIZE" desc="In settings system options, the label for the customize button for modifier keys"> Modifier keys... </message> - <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_DIALOG_TITLE"> - Languages and Input - </message> - <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_LANGUAGES" desc="The label for the list of languages"> - Languages - </message> + <message name="IDS_EULA_BACK_BUTTON" desc="Back button shown on EULA screen."> « Back </message> @@ -10070,18 +10131,6 @@ Keep your key file in a safe place. You will need it to create new versions of y desc="The label for the section header for input methods"> Input Method </message> - <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_ADD_LANGUAGE_COMBOBOX" - desc="The label for the add language combobox"> - Add language - </message> - <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_ADD_BUTTON" - desc="The label for the add button for adding a language"> - Add - </message> - <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_REMOVE_BUTTON" - desc="The label for the remove button for removing a language"> - Remove - </message> <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_SIGN_OUT_BUTTON" desc="The label for the sign out button for changing UI language"> Sign out @@ -10090,18 +10139,6 @@ Keep your key file in a safe place. You will need it to create new versions of y desc="Warning invoked when the user tries to remove the last input method"> Please add another input method before removing this one. </message> - <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_PLEASE_ADD_ANOTHER_LANGUAGE" - desc="Warning invoked when the user tries to remove the last language"> - Please add another language before removing this one. - </message> - <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_THIS_LANGUAGE_IS_CURRENTLY_IN_USE" - desc="Warning invoked when the user tries to remove the language used for displaying Chrome OS"> - This language is currently in use for displaying <ph name="PRODUCT_NAME">$1<ex>Chrome OS</ex></ph>. - </message> - <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_ADD_LANGUAGE_INSTRUCTIONS" - desc="Explanatory message about how to add and order languages"> - Add languages and drag to order them based on your preference. - </message> <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_INPUT_METHOD_INSTRUCTIONS" desc="Explanatory message about how to select input methods"> For text input, select a language to see available input methods. @@ -10114,31 +10151,6 @@ Keep your key file in a safe place. You will need it to create new versions of y desc="Explanatory message about how to select the previous input method"> Press <ph name="HOTKEY_NAME">$1<ex>ctrl-space</ex></ph> to select the previous input method. </message> - <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_DISPLAY_IN_THIS_LANGUAGE" - desc="The label is used for a button that changes the UI - language of Chrome OS"> - Display <ph name="PRODUCT_NAME">$1<ex>Chrome OS</ex></ph> in this language - </message> - <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_IS_DISPLAYED_IN_THIS_LANGUAGE" - desc="The label for a language that is currently used for UI"> - <ph name="PRODUCT_NAME">$1<ex>Chrome OS</ex></ph> is displayed in this language - </message> - <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_CANNOT_BE_DISPLAYED_IN_THIS_LANGUAGE" - desc="The label for a language that cannot be used for UI"> - <ph name="PRODUCT_NAME">$1<ex>Chrome OS</ex></ph> cannot be displayed in this language - </message> - <message name="IDS_OPTIONS_SETTINGS_USE_THIS_FOR_SPELL_CHECKING" - desc="The label for a language a button that changes the spell check language of Chrome OS"> - Use this language for spell checking - </message> - <message name="IDS_OPTIONS_SETTINGS_CANNOT_BE_USED_FOR_SPELL_CHECKING" - desc="The label for a language that cannot be used for spell checking"> - This language cannot be used for spell checking - </message> - <message name="IDS_OPTIONS_SETTINGS_IS_USED_FOR_SPELL_CHECKING" - desc="The label for a language that is currently used for spell checking"> - This language is used for spell checking - </message> <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_M17N_STANDARD_INPUT_METHOD" desc="The label for a input method"> Standard input method diff --git a/chrome/browser/dom_ui/options/advanced_options_handler.cc b/chrome/browser/dom_ui/options/advanced_options_handler.cc index c156220..4535300 100644 --- a/chrome/browser/dom_ui/options/advanced_options_handler.cc +++ b/chrome/browser/dom_ui/options/advanced_options_handler.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -140,6 +140,9 @@ void AdvancedOptionsHandler::GetLocalizedValues( localized_strings->SetString("fontSettingsCustomizeFontsButton", l10n_util::GetStringUTF16( IDS_OPTIONS_FONTSETTINGS_CUSTOMIZE_FONTS_BUTTON)); + localized_strings->SetString("languageAndSpellCheckSettingsButton", + l10n_util::GetStringUTF16( + IDS_OPTIONS_LANGUAGE_AND_SPELLCHECK_BUTTON)); localized_strings->SetString("advancedSectionTitlePrivacy", dom_options_util::StripColon( l10n_util::GetStringUTF16( diff --git a/chrome/browser/dom_ui/options/language_options_handler.cc b/chrome/browser/dom_ui/options/language_options_handler.cc index 76966bb..4dd937c 100644 --- a/chrome/browser/dom_ui/options/language_options_handler.cc +++ b/chrome/browser/dom_ui/options/language_options_handler.cc @@ -2,10 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// TODO(csilv): This is for the move CL. Changes to make this cross-platform -// will come in the followup CL. -#if defined(OS_CHROMEOS) - #include "chrome/browser/dom_ui/options/language_options_handler.h" #include <map> @@ -16,23 +12,27 @@ #include "app/l10n_util.h" #include "base/basictypes.h" +#include "base/command_line.h" #include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/app/chrome_command_ids.h" +#include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/chromeos/cros/cros_library.h" -#include "chrome/browser/chromeos/cros/input_method_library.h" -#include "chrome/browser/chromeos/input_method/input_method_util.h" #include "chrome/browser/metrics/user_metrics.h" +#include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/ui/browser.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/common/spellcheck_common.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" -namespace chromeos { +#if defined(OS_CHROMEOS) +#include "chrome/browser/chromeos/cros/cros_library.h" +#include "chrome/browser/chromeos/cros/input_method_library.h" +#endif // defined(OS_CHROMEOS) LanguageOptionsHandler::LanguageOptionsHandler() { } @@ -43,60 +43,42 @@ LanguageOptionsHandler::~LanguageOptionsHandler() { void LanguageOptionsHandler::GetLocalizedValues( DictionaryValue* localized_strings) { DCHECK(localized_strings); + string16 product_name; +#if defined(OS_CHROMEOS) + product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME); +#else + product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); +#endif // defined(OS_CHROMEOS) localized_strings->SetString("languagePage", l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_LANGUAGES_DIALOG_TITLE)); localized_strings->SetString("add_button", l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_LANGUAGES_ADD_BUTTON)); - localized_strings->SetString("configure", - l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_LANGUAGES_CONFIGURE)); - localized_strings->SetString("input_method", - l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_LANGUAGES_INPUT_METHOD)); localized_strings->SetString("languages", l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_LANGUAGES_LANGUAGES)); - localized_strings->SetString("please_add_another_input_method", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_LANGUAGES_PLEASE_ADD_ANOTHER_INPUT_METHOD)); localized_strings->SetString("please_add_another_language", l10n_util::GetStringUTF16( IDS_OPTIONS_SETTINGS_LANGUAGES_PLEASE_ADD_ANOTHER_LANGUAGE)); - localized_strings->SetString("ok_button", l10n_util::GetStringUTF16(IDS_OK)); localized_strings->SetString("remove_button", l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_LANGUAGES_REMOVE_BUTTON)); - localized_strings->SetString("sign_out_button", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_LANGUAGES_SIGN_OUT_BUTTON)); localized_strings->SetString("add_language_instructions", l10n_util::GetStringUTF16( IDS_OPTIONS_SETTINGS_LANGUAGES_ADD_LANGUAGE_INSTRUCTIONS)); - localized_strings->SetString("input_method_instructions", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_LANGUAGES_INPUT_METHOD_INSTRUCTIONS)); - localized_strings->SetString("switch_input_methods_hint", - l10n_util::GetStringFUTF16( - IDS_OPTIONS_SETTINGS_LANGUAGES_SWITCH_INPUT_METHODS_HINT, - ASCIIToUTF16("alt+shift"))); - localized_strings->SetString("select_previous_input_method_hint", - l10n_util::GetStringFUTF16( - IDS_OPTIONS_SETTINGS_LANGUAGES_SELECT_PREVIOUS_INPUT_METHOD_HINT, - ASCIIToUTF16("ctrl+space"))); localized_strings->SetString("cannot_be_displayed_in_this_language", l10n_util::GetStringFUTF16( IDS_OPTIONS_SETTINGS_LANGUAGES_CANNOT_BE_DISPLAYED_IN_THIS_LANGUAGE, - l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME))); + product_name)); localized_strings->SetString("is_displayed_in_this_language", l10n_util::GetStringFUTF16( IDS_OPTIONS_SETTINGS_LANGUAGES_IS_DISPLAYED_IN_THIS_LANGUAGE, - l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME))); + product_name)); localized_strings->SetString("display_in_this_language", l10n_util::GetStringFUTF16( IDS_OPTIONS_SETTINGS_LANGUAGES_DISPLAY_IN_THIS_LANGUAGE, - l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME))); - localized_strings->SetString("sign_out_required", - l10n_util::GetStringUTF16(IDS_OPTIONS_RESTART_REQUIRED)); + product_name)); localized_strings->SetString("this_language_is_currently_in_use", l10n_util::GetStringFUTF16( IDS_OPTIONS_SETTINGS_LANGUAGES_THIS_LANGUAGE_IS_CURRENTLY_IN_USE, - l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME))); + product_name)); localized_strings->SetString("use_this_for_spell_checking", l10n_util::GetStringUTF16( IDS_OPTIONS_SETTINGS_USE_THIS_FOR_SPELL_CHECKING)); @@ -106,23 +88,75 @@ void LanguageOptionsHandler::GetLocalizedValues( localized_strings->SetString("is_used_for_spell_checking", l10n_util::GetStringUTF16( IDS_OPTIONS_SETTINGS_IS_USED_FOR_SPELL_CHECKING)); + localized_strings->SetString("restart_required", + l10n_util::GetStringUTF16(IDS_OPTIONS_RESTART_REQUIRED)); + localized_strings->SetString("enable_spell_check", + l10n_util::GetStringUTF16(IDS_OPTIONS_ENABLE_SPELLCHECK)); + localized_strings->SetString("enable_auto_spell_correction", + l10n_util::GetStringUTF16(IDS_OPTIONS_ENABLE_AUTO_SPELL_CORRECTION)); + localized_strings->SetString("add_language_title", + l10n_util::GetStringUTF16(IDS_OPTIONS_LANGUAGES_ADD_TITLE)); + localized_strings->SetString("add_language_select_label", + l10n_util::GetStringUTF16(IDS_OPTIONS_LANGUAGES_ADD_SELECT_LABEL)); - // GetSupportedInputMethods() never return NULL. - scoped_ptr<InputMethodDescriptors> descriptors( - CrosLibrary::Get()->GetInputMethodLibrary()->GetSupportedInputMethods()); +#if defined(OS_CHROMEOS) + localized_strings->SetString("ok_button", l10n_util::GetStringUTF16(IDS_OK)); + localized_strings->SetString("configure", + l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_LANGUAGES_CONFIGURE)); + localized_strings->SetString("input_method", + l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_LANGUAGES_INPUT_METHOD)); + localized_strings->SetString("please_add_another_input_method", + l10n_util::GetStringUTF16( + IDS_OPTIONS_SETTINGS_LANGUAGES_PLEASE_ADD_ANOTHER_INPUT_METHOD)); + localized_strings->SetString("input_method_instructions", + l10n_util::GetStringUTF16( + IDS_OPTIONS_SETTINGS_LANGUAGES_INPUT_METHOD_INSTRUCTIONS)); + localized_strings->SetString("switch_input_methods_hint", + l10n_util::GetStringFUTF16( + IDS_OPTIONS_SETTINGS_LANGUAGES_SWITCH_INPUT_METHODS_HINT, + ASCIIToUTF16("alt+shift"))); + localized_strings->SetString("select_previous_input_method_hint", + l10n_util::GetStringFUTF16( + IDS_OPTIONS_SETTINGS_LANGUAGES_SELECT_PREVIOUS_INPUT_METHOD_HINT, + ASCIIToUTF16("ctrl+space"))); + localized_strings->SetString("restart_button", + l10n_util::GetStringUTF16( + IDS_OPTIONS_SETTINGS_LANGUAGES_SIGN_OUT_BUTTON)); +#else + localized_strings->SetString("restart_button", + l10n_util::GetStringUTF16( + IDS_OPTIONS_SETTINGS_LANGUAGES_RESTART_BUTTON)); +#endif // defined(OS_CHROMEOS) // The followigns are resources, rather than local strings. localized_strings->SetString("currentUiLanguageCode", - g_browser_process->GetApplicationLocale()); - localized_strings->Set("inputMethodList", GetInputMethodList(*descriptors)); - localized_strings->Set("languageList", GetLanguageList(*descriptors)); + g_browser_process->GetApplicationLocale()); localized_strings->Set("spellCheckLanguageCodeSet", GetSpellCheckLanguageCodeSet()); - localized_strings->Set("uiLanguageCodeSet", GetUiLanguageCodeSet()); + localized_strings->Set("uiLanguageCodeSet", GetUILanguageCodeSet()); + + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + bool experimental_spell_check_features = + command_line.HasSwitch(switches::kExperimentalSpellcheckerFeatures); + localized_strings->SetString("experimentalSpellCheckFeatures", + experimental_spell_check_features ? "true" : "false"); + +#if defined(OS_CHROMEOS) + // GetSupportedInputMethods() never return NULL. + chromeos::InputMethodLibrary *im_library = + chromeos::CrosLibrary::Get()->GetInputMethodLibrary(); + scoped_ptr<chromeos::InputMethodDescriptors> descriptors( + im_library->GetSupportedInputMethods()); + localized_strings->Set("languageList", GetLanguageList(*descriptors)); + localized_strings->Set("inputMethodList", GetInputMethodList(*descriptors)); +#else + localized_strings->Set("languageList", GetLanguageList()); +#endif // defined(OS_CHROMEOS) } void LanguageOptionsHandler::RegisterMessages() { DCHECK(dom_ui_); +#if defined(OS_CHROMEOS) dom_ui_->RegisterMessageCallback("inputMethodDisable", NewCallback(this, &LanguageOptionsHandler::InputMethodDisableCallback)); dom_ui_->RegisterMessageCallback("inputMethodEnable", @@ -130,6 +164,7 @@ void LanguageOptionsHandler::RegisterMessages() { dom_ui_->RegisterMessageCallback("inputMethodOptionsOpen", NewCallback(this, &LanguageOptionsHandler::InputMethodOptionsOpenCallback)); +#endif // defined(OS_CHROMEOS) dom_ui_->RegisterMessageCallback("languageOptionsOpen", NewCallback(this, &LanguageOptionsHandler::LanguageOptionsOpenCallback)); dom_ui_->RegisterMessageCallback("spellCheckLanguageChange", @@ -137,20 +172,21 @@ void LanguageOptionsHandler::RegisterMessages() { &LanguageOptionsHandler::SpellCheckLanguageChangeCallback)); dom_ui_->RegisterMessageCallback("uiLanguageChange", NewCallback(this, &LanguageOptionsHandler::UiLanguageChangeCallback)); - dom_ui_->RegisterMessageCallback("uiLanguageSignOut", - NewCallback(this, &LanguageOptionsHandler::SignOutCallback)); + dom_ui_->RegisterMessageCallback("uiLanguageRestart", + NewCallback(this, &LanguageOptionsHandler::RestartCallback)); } +#if defined(OS_CHROMEOS) ListValue* LanguageOptionsHandler::GetInputMethodList( - const InputMethodDescriptors& descriptors) { + const chromeos::InputMethodDescriptors& descriptors) { ListValue* input_method_list = new ListValue(); for (size_t i = 0; i < descriptors.size(); ++i) { - const InputMethodDescriptor& descriptor = descriptors[i]; + const chromeos::InputMethodDescriptor& descriptor = descriptors[i]; const std::string language_code = - input_method::GetLanguageCodeFromDescriptor(descriptor); + chromeos::input_method::GetLanguageCodeFromDescriptor(descriptor); const std::string display_name = - input_method::GetInputMethodDisplayNameFromId(descriptor.id); + chromeos::input_method::GetInputMethodDisplayNameFromId(descriptor.id); DictionaryValue* dictionary = new DictionaryValue(); dictionary->SetString("id", descriptor.id); @@ -162,11 +198,12 @@ ListValue* LanguageOptionsHandler::GetInputMethodList( language_codes->SetBoolean(language_code, true); // Check kExtraLanguages to see if there are languages associated with // this input method. If these are present, add these. - for (size_t j = 0; j < arraysize(input_method::kExtraLanguages); ++j) { + for (size_t j = 0; j < arraysize(chromeos::input_method::kExtraLanguages); + ++j) { const std::string extra_input_method_id = - input_method::kExtraLanguages[j].input_method_id; + chromeos::input_method::kExtraLanguages[j].input_method_id; const std::string extra_language_code = - input_method::kExtraLanguages[j].language_code; + chromeos::input_method::kExtraLanguages[j].language_code; if (extra_input_method_id == descriptor.id) { language_codes->SetBoolean(extra_language_code, true); } @@ -180,19 +217,20 @@ ListValue* LanguageOptionsHandler::GetInputMethodList( } ListValue* LanguageOptionsHandler::GetLanguageList( - const InputMethodDescriptors& descriptors) { + const chromeos::InputMethodDescriptors& descriptors) { std::set<std::string> language_codes; // Collect the language codes from the supported input methods. for (size_t i = 0; i < descriptors.size(); ++i) { - const InputMethodDescriptor& descriptor = descriptors[i]; + const chromeos::InputMethodDescriptor& descriptor = descriptors[i]; const std::string language_code = - input_method::GetLanguageCodeFromDescriptor(descriptor); + chromeos::input_method::GetLanguageCodeFromDescriptor(descriptor); language_codes.insert(language_code); } // Collect the language codes from kExtraLanguages. - for (size_t i = 0; i < arraysize(input_method::kExtraLanguages); ++i) { + for (size_t i = 0; i < arraysize(chromeos::input_method::kExtraLanguages); + ++i) { const char* language_code = - input_method::kExtraLanguages[i].language_code; + chromeos::input_method::kExtraLanguages[i].language_code; language_codes.insert(language_code); } @@ -210,9 +248,9 @@ ListValue* LanguageOptionsHandler::GetLanguageList( for (std::set<std::string>::const_iterator iter = language_codes.begin(); iter != language_codes.end(); ++iter) { const string16 display_name = - input_method::GetLanguageDisplayNameFromCode(*iter); + chromeos::input_method::GetLanguageDisplayNameFromCode(*iter); const string16 native_display_name = - input_method::GetLanguageNativeDisplayNameFromCode(*iter); + chromeos::input_method::GetLanguageNativeDisplayNameFromCode(*iter); display_names.push_back(display_name); language_map[display_name] = std::make_pair(*iter, native_display_name); @@ -236,8 +274,57 @@ ListValue* LanguageOptionsHandler::GetLanguageList( return language_list; } +#endif // defined(OS_CHROMEOS) + +#if !defined(OS_CHROMEOS) +ListValue* LanguageOptionsHandler::GetLanguageList() { + // Collect the language codes from the supported accept-languages. + const std::string app_locale = g_browser_process->GetApplicationLocale(); + std::vector<std::string> language_codes; + l10n_util::GetAcceptLanguagesForLocale(app_locale, &language_codes); + + // Map of display name -> {language code, native_display_name}. + // In theory, we should be able to create a map that is sorted by + // display names using ICU comparator, but doing it is hard, thus we'll + // use an auxiliary vector to achieve the same result. + typedef std::pair<std::string, string16> LanguagePair; + typedef std::map<string16, LanguagePair> LanguageMap; + LanguageMap language_map; + // The auxiliary vector mentioned above. + std::vector<string16> display_names; -DictionaryValue* LanguageOptionsHandler::GetUiLanguageCodeSet() { + // Build the list of display names, and build the language map. + for (size_t i = 0; i < language_codes.size(); ++i) { + const string16 display_name = + l10n_util::GetDisplayNameForLocale(language_codes[i], app_locale, true); + const string16 native_display_name = + l10n_util::GetDisplayNameForLocale(language_codes[i], language_codes[i], + true); + display_names.push_back(display_name); + language_map[display_name] = + std::make_pair(language_codes[i], native_display_name); + } + DCHECK_EQ(display_names.size(), language_map.size()); + + // Sort display names using locale specific sorter. + l10n_util::SortStrings16(app_locale, &display_names); + + // Build the language list from the language map. + ListValue* language_list = new ListValue(); + for (size_t i = 0; i < display_names.size(); ++i) { + const LanguagePair& pair = language_map[display_names[i]]; + DictionaryValue* dictionary = new DictionaryValue(); + dictionary->SetString("code", pair.first); + dictionary->SetString("displayName", display_names[i]); + dictionary->SetString("nativeDisplayName", pair.second); + language_list->Append(dictionary); + } + + return language_list; +} +#endif // !defined(OS_CHROMEOS) + +DictionaryValue* LanguageOptionsHandler::GetUILanguageCodeSet() { DictionaryValue* dictionary = new DictionaryValue(); const std::vector<std::string>& available_locales = l10n_util::GetAvailableLocales(); @@ -257,6 +344,7 @@ DictionaryValue* LanguageOptionsHandler::GetSpellCheckLanguageCodeSet() { return dictionary; } +#if defined(OS_CHROMEOS) void LanguageOptionsHandler::InputMethodDisableCallback( const ListValue* args) { const std::string input_method_id = WideToASCII(ExtractStringValue(args)); @@ -280,6 +368,7 @@ void LanguageOptionsHandler::InputMethodOptionsOpenCallback( "InputMethodOptions_Open_%s", input_method_id.c_str()); UserMetrics::RecordComputedAction(action); } +#endif // defined(OS_CHROMEOS) void LanguageOptionsHandler::LanguageOptionsOpenCallback( const ListValue* args) { @@ -293,7 +382,12 @@ void LanguageOptionsHandler::UiLanguageChangeCallback( const std::string action = StringPrintf( "LanguageOptions_UiLanguageChange_%s", language_code.c_str()); UserMetrics::RecordComputedAction(action); +#if defined(OS_CHROMEOS) dom_ui_->GetProfile()->ChangeApplicationLocale(language_code, false); +#else + PrefService* prefs = dom_ui_->GetProfile()->GetPrefs(); + prefs->SetString(prefs::kApplicationLocale, language_code); +#endif // defined(OS_CHROMEOS) dom_ui_->CallJavascriptFunction( L"options.LanguageOptions.uiLanguageSaved"); } @@ -307,16 +401,21 @@ void LanguageOptionsHandler::SpellCheckLanguageChangeCallback( UserMetrics::RecordComputedAction(action); } -void LanguageOptionsHandler::SignOutCallback(const ListValue* args) { +void LanguageOptionsHandler::RestartCallback(const ListValue* args) { +#if defined(OS_CHROMEOS) UserMetrics::RecordAction(UserMetricsAction("LanguageOptions_SignOut")); Browser* browser = Browser::GetBrowserForController( &dom_ui_->tab_contents()->controller(), NULL); if (browser) browser->ExecuteCommand(IDC_EXIT); +#else + UserMetrics::RecordAction(UserMetricsAction("LanguageOptions_Restart")); + + // Set the flag to restore state after the restart. + PrefService* pref_service = g_browser_process->local_state(); + pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true); + BrowserList::CloseAllBrowsersAndExit(); +#endif // defined(OS_CHROMEOS) } -} // namespace chromeos - -#endif // OS_CHROMEOS - diff --git a/chrome/browser/dom_ui/options/language_options_handler.h b/chrome/browser/dom_ui/options/language_options_handler.h index 54d7501..f256d7d 100644 --- a/chrome/browser/dom_ui/options/language_options_handler.h +++ b/chrome/browser/dom_ui/options/language_options_handler.h @@ -6,19 +6,16 @@ #define CHROME_BROWSER_DOM_UI_OPTIONS_LANGUAGE_OPTIONS_HANDLER_H_ #pragma once -// TODO(csilv): This is for the move CL. Changes to make this cross-platform -// will come in the followup CL. -#if defined(OS_CHROMEOS) +#include "chrome/browser/dom_ui/options/options_ui.h" +#if defined(OS_CHROMEOS) #include "chrome/browser/chromeos/input_method/input_method_util.h" -#include "chrome/browser/dom_ui/options/options_ui.h" +#endif // defined(OS_CHROMEOS) class DictionaryValue; class ListValue; -namespace chromeos { - -// ChromeOS language options page UI handler. +// Language options page UI handler. class LanguageOptionsHandler : public OptionsPageUIHandler { public: LanguageOptionsHandler(); @@ -39,14 +36,21 @@ class LanguageOptionsHandler : public OptionsPageUIHandler { // // Note that true in languageCodeSet does not mean anything. We just use // the dictionary as a set. +#if defined(OS_CHROMEOS) static ListValue* GetInputMethodList( - const InputMethodDescriptors& descriptors); + const chromeos::InputMethodDescriptors& descriptors); +#endif // defined(OS_CHROMEOS) // Gets the list of languages from the given input descriptors. // The return value will look like: // [{'code': 'fi', 'displayName': 'Finnish', 'nativeDisplayName': 'suomi'}, // ...] - static ListValue* GetLanguageList(const InputMethodDescriptors& descriptors); +#if defined(OS_CHROMEOS) + static ListValue* GetLanguageList( + const chromeos::InputMethodDescriptors& descriptors); +#else + static ListValue* GetLanguageList(); +#endif // defined(OS_CHROMEOS) // Gets the set of language codes that can be used as UI language. // The return value will look like: @@ -54,7 +58,7 @@ class LanguageOptionsHandler : public OptionsPageUIHandler { // // Note that true in values does not mean anything. We just use the // dictionary as a set. - static DictionaryValue* GetUiLanguageCodeSet(); + static DictionaryValue* GetUILanguageCodeSet(); // Gets the set of language codes that can be used for spellchecking. // The return value will look like: @@ -65,6 +69,7 @@ class LanguageOptionsHandler : public OptionsPageUIHandler { static DictionaryValue* GetSpellCheckLanguageCodeSet(); private: +#if defined(OS_CHROMEOS) // Called when the input method is disabled. // |args| will contain the input method ID as string (ex. "mozc"). void InputMethodDisableCallback(const ListValue* args); @@ -76,6 +81,7 @@ class LanguageOptionsHandler : public OptionsPageUIHandler { // Called when the input method options page is opened. // |args| will contain the input method ID as string (ex. "mozc"). void InputMethodOptionsOpenCallback(const ListValue* args); +#endif // defined(OS_CHROMEOS) // Called when the language options is opened. void LanguageOptionsOpenCallback(const ListValue* args); @@ -88,15 +94,10 @@ class LanguageOptionsHandler : public OptionsPageUIHandler { // |args| will contain the language code as string (ex. "fr"). void SpellCheckLanguageChangeCallback(const ListValue* args); - // Called when the sign out button is clicked. - void SignOutCallback(const ListValue* args); + // Called when the restart/sign-out button is clicked. + void RestartCallback(const ListValue* args); DISALLOW_COPY_AND_ASSIGN(LanguageOptionsHandler); }; -} // namespace - -#endif // OS_CHROMEOS - #endif // CHROME_BROWSER_DOM_UI_OPTIONS_LANGUAGE_OPTIONS_HANDLER_H_ - diff --git a/chrome/browser/dom_ui/options/language_options_handler_unittest.cc b/chrome/browser/dom_ui/options/language_options_handler_unittest.cc index 2df1a74..5a73e86 100644 --- a/chrome/browser/dom_ui/options/language_options_handler_unittest.cc +++ b/chrome/browser/dom_ui/options/language_options_handler_unittest.cc @@ -2,45 +2,45 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// TODO(csilv): This is for the move CL. Changes to make this cross-platform -// will come in the followup CL. -#if defined(OS_CHROMEOS) - #include "chrome/browser/dom_ui/options/language_options_handler.h" #include <string> #include "base/scoped_ptr.h" #include "base/values.h" -#include "chrome/browser/chromeos/cros/cros_library.h" -#include "chrome/browser/chromeos/cros/input_method_library.h" #include "testing/gtest/include/gtest/gtest.h" -namespace chromeos { +#if defined(OS_CHROMEOS) +#include "chrome/browser/chromeos/cros/cros_library.h" +#include "chrome/browser/chromeos/cros/input_method_library.h" +#endif // defined(OS_CHROMEOS) -static InputMethodDescriptors CreateInputMethodDescriptors() { - InputMethodDescriptors descriptors; +#if defined(OS_CHROMEOS) +static chromeos::InputMethodDescriptors CreateInputMethodDescriptors() { + chromeos::InputMethodDescriptors descriptors; descriptors.push_back( - InputMethodDescriptor("xkb:us::eng", "USA", "us", "eng")); + chromeos::InputMethodDescriptor("xkb:us::eng", "USA", "us", "eng")); descriptors.push_back( - InputMethodDescriptor("xkb:fr::fra", "France", "fr", "fra")); + chromeos::InputMethodDescriptor("xkb:fr::fra", "France", "fr", "fra")); descriptors.push_back( - InputMethodDescriptor("xkb:be::fra", "Belgium", "be", "fr")); + chromeos::InputMethodDescriptor("xkb:be::fra", "Belgium", "be", "fr")); descriptors.push_back( - InputMethodDescriptor("mozc", "Mozc (US keyboard layout)", "us", "ja")); + chromeos::InputMethodDescriptor("mozc", "Mozc (US keyboard layout)", "us", + "ja")); return descriptors; } TEST(LanguageOptionsHandlerTest, GetInputMethodList) { // Use the stub libcros. The object will take care of the cleanup. - ScopedStubCrosEnabler stub_cros_enabler; + chromeos::ScopedStubCrosEnabler stub_cros_enabler; // Reset the library implementation so it will be initialized // again. Otherwise, non-stub implementation can be reused, if it's // already initialized elsewhere, which results in a crash. - CrosLibrary::Get()->GetTestApi()->SetInputMethodLibrary(NULL, false); + chromeos::CrosLibrary::Get()->GetTestApi()->SetInputMethodLibrary(NULL, + false); - InputMethodDescriptors descriptors = CreateInputMethodDescriptors(); + chromeos::InputMethodDescriptors descriptors = CreateInputMethodDescriptors(); scoped_ptr<ListValue> list( LanguageOptionsHandler::GetInputMethodList(descriptors)); ASSERT_EQ(4U, list->GetSize()); @@ -94,7 +94,7 @@ TEST(LanguageOptionsHandlerTest, GetInputMethodList) { } TEST(LanguageOptionsHandlerTest, GetLanguageList) { - InputMethodDescriptors descriptors = CreateInputMethodDescriptors(); + chromeos::InputMethodDescriptors descriptors = CreateInputMethodDescriptors(); scoped_ptr<ListValue> list( LanguageOptionsHandler::GetLanguageList(descriptors)); ASSERT_EQ(6U, list->GetSize()); @@ -158,23 +158,21 @@ TEST(LanguageOptionsHandlerTest, GetLanguageList) { EXPECT_EQ("espa\u00F1ol (Latinoam\u00E9rica y el Caribe)", native_display_name); } +#endif // defined(OS_CHROMEOS) -TEST(LanguageOptionsHandlerTest, GetUiLanguageCodeSet) { +#if !defined(OS_MACOSX) +TEST(LanguageOptionsHandlerTest, GetUILanguageCodeSet) { scoped_ptr<DictionaryValue> dictionary( - LanguageOptionsHandler::GetUiLanguageCodeSet()); + LanguageOptionsHandler::GetUILanguageCodeSet()); EXPECT_TRUE(dictionary->HasKey("en-US")); // Note that we don't test a false case, as such an expectation will // fail when we add support for the language. // EXPECT_FALSE(dictionary->HasKey("no")); } +#endif // !defined(OS_MACOSX) TEST(LanguageOptionsHandlerTest, GetSpellCheckLanguageCodeSet) { scoped_ptr<DictionaryValue> dictionary( LanguageOptionsHandler::GetSpellCheckLanguageCodeSet()); EXPECT_TRUE(dictionary->HasKey("en-US")); } - -} // namespace chromeos - -#endif // OS_CHROMEOS - diff --git a/chrome/browser/dom_ui/options/options_ui.cc b/chrome/browser/dom_ui/options/options_ui.cc index 06353ac..fcc3b80 100644 --- a/chrome/browser/dom_ui/options/options_ui.cc +++ b/chrome/browser/dom_ui/options/options_ui.cc @@ -153,6 +153,7 @@ OptionsUI::OptionsUI(TabContents* contents) : DOMUI(contents) { AddOptionsPageUIHandler(localized_strings, new ContentSettingsHandler()); AddOptionsPageUIHandler(localized_strings, new CookiesViewHandler()); AddOptionsPageUIHandler(localized_strings, new FontSettingsHandler()); + AddOptionsPageUIHandler(localized_strings, new LanguageOptionsHandler()); AddOptionsPageUIHandler(localized_strings, new PasswordManagerHandler()); AddOptionsPageUIHandler(localized_strings, new PersonalOptionsHandler()); AddOptionsPageUIHandler(localized_strings, new SearchEngineManagerHandler()); @@ -173,8 +174,6 @@ OptionsUI::OptionsUI(TabContents* contents) : DOMUI(contents) { AddOptionsPageUIHandler(localized_strings, new chromeos::LanguageMozcOptionsHandler()); AddOptionsPageUIHandler(localized_strings, - new chromeos::LanguageOptionsHandler()); - AddOptionsPageUIHandler(localized_strings, new chromeos::LanguagePinyinOptionsHandler()); AddOptionsPageUIHandler(localized_strings, new chromeos::ProxyHandler()); AddOptionsPageUIHandler(localized_strings, diff --git a/chrome/browser/resources/options/advanced_options.html b/chrome/browser/resources/options/advanced_options.html index e071fd3..5f6ef49 100644 --- a/chrome/browser/resources/options/advanced_options.html +++ b/chrome/browser/resources/options/advanced_options.html @@ -95,6 +95,12 @@ </select> </label> </div> +<if expr="not pp_ifdef('chromeos')"> + <div> + <button id="language-button" + i18n-content="languageAndSpellCheckSettingsButton"></button> + </div> +</if> <if expr="os == 'win32'"> <div> <label style="display:inline;"> diff --git a/chrome/browser/resources/options/advanced_options.js b/chrome/browser/resources/options/advanced_options.js index dd622eb..3291fa6 100644 --- a/chrome/browser/resources/options/advanced_options.js +++ b/chrome/browser/resources/options/advanced_options.js @@ -60,6 +60,11 @@ var OptionsPage = options.OptionsPage; chrome.send('defaultFontSizeAction', [String(event.target.options[event.target.selectedIndex].value)]); }; + $('language-button').onclick = function(event) { + OptionsPage.showPageByName('language'); + chrome.send('coreOptionsUserMetricsAction', + ['Options_LanuageAndSpellCheckSettings']); + }; if (cr.isWindows || cr.isMac) { $('certificatesManageButton').onclick = function(event) { diff --git a/chrome/browser/resources/options/language_add_language_overlay.html b/chrome/browser/resources/options/language_add_language_overlay.html index 78747a1..714da12 100644 --- a/chrome/browser/resources/options/language_add_language_overlay.html +++ b/chrome/browser/resources/options/language_add_language_overlay.html @@ -1,6 +1,22 @@ <div class="page hidden" id="add-language-overlay-page"> +<if expr="pp_ifdef('chromeos')"> <ul id="add-language-overlay-language-list"> </ul> <button id="add-language-overlay-cancel-button" i18n-content="cancel"></button> +</if> +<if expr="not pp_ifdef('chromeos')"> + <h1 i18n-content="add_language_title"></h1> + <label> + <span i18n-content="add_language_select_label"></span> + <select id="add-language-overlay-language-list"></select> + </label> + <div class="action-area"> + <div class="button-strip"> + <button id="add-language-overlay-cancel-button" i18n-content="cancel"> + </button> + <button id="add-language-overlay-ok-button" i18n-content="ok"></button> + </div> + </div> +</if> </div> diff --git a/chrome/browser/resources/options/language_add_language_overlay.js b/chrome/browser/resources/options/language_add_language_overlay.js index b86e1cc..807b7f4 100644 --- a/chrome/browser/resources/options/language_add_language_overlay.js +++ b/chrome/browser/resources/options/language_add_language_overlay.js @@ -39,23 +39,30 @@ cr.define('options.language', function() { }; // Create the language list with which users can add a language. - // Note that we have about 40 languages. var addLanguageList = $('add-language-overlay-language-list'); var languageListData = templateData.languageList; for (var i = 0; i < languageListData.length; i++) { var language = languageListData[i]; - var button = document.createElement('button'); - button.className = 'link-button'; - button.textContent = language.displayName; + var displayText = language.displayName; // If the native name is different, add it. if (language.displayName != language.nativeDisplayName) { - button.textContent += ' - ' + language.nativeDisplayName; + displayText += ' - ' + language.nativeDisplayName; + } + if (cr.isChromeOS) { + var button = document.createElement('button'); + button.className = 'link-button'; + button.textContent = displayText; + button.languageCode = language.code; + var li = document.createElement('li'); + li.languageCode = language.code; + li.appendChild(button); + addLanguageList.appendChild(li); + } else { + var option = document.createElement('option'); + option.value = language.code; + option.textContent = displayText; + addLanguageList.appendChild(option); } - button.languageCode = language.code; - var li = document.createElement('li'); - li.languageCode = language.code; - li.appendChild(button); - addLanguageList.appendChild(li); } }, }; diff --git a/chrome/browser/resources/options/language_list.js b/chrome/browser/resources/options/language_list.js index df47550..6f29782 100644 --- a/chrome/browser/resources/options/language_list.js +++ b/chrome/browser/resources/options/language_list.js @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -92,8 +92,13 @@ cr.define('options.language', function() { window.addEventListener('resize', this.redraw.bind(this)); // Listen to pref change. - Preferences.getInstance().addEventListener(this.preferredLanguagesPref, - this.handlePreferredLanguagesPrefChange_.bind(this)); + if (cr.isChromeOS) { + Preferences.getInstance().addEventListener(this.preferredLanguagesPref, + this.handlePreferredLanguagesPrefChange_.bind(this)); + } else { + Preferences.getInstance().addEventListener(this.acceptLanguagesPref, + this.handleAcceptLanguagesPrefChange_.bind(this)); + } // Listen to drag and drop events. this.addEventListener('dragstart', this.handleDragStart_.bind(this)); @@ -184,6 +189,10 @@ cr.define('options.language', function() { if (target instanceof ListItem) { this.draggedItem = target; e.dataTransfer.effectAllowed = 'move'; + // We need to put some kind of data in the drag or it will be + // ignored. Use the display name in case the user drags to a text + // field or the desktop. + e.dataTransfer.setData('text/plain', target.title); } }, @@ -256,6 +265,18 @@ cr.define('options.language', function() { }, /** + * Handles accept languages pref change. + * @param {Event} e The change event object. + * @private + */ + handleAcceptLanguagesPrefChange_: function(e) { + var languageCodesInCsv = e.value.value; + var languageCodes = this.filterBadLanguageCodes_( + languageCodesInCsv.split(',')); + this.load_(languageCodes); + }, + + /** * Loads given language list. * @param {Array} languageCodes List of language codes. * @private @@ -286,8 +307,9 @@ cr.define('options.language', function() { */ savePreference_: function() { // Encode the language codes into a CSV string. - Preferences.setStringPref(this.preferredLanguagesPref, - this.dataModel.slice().join(',')); + if (cr.isChromeOS) + Preferences.setStringPref(this.preferredLanguagesPref, + this.dataModel.slice().join(',')); // Save the same language list as accept languages preference as // well, but we need to expand the language list, to make it more // acceptable. For instance, some web sites don't understand 'en-US' diff --git a/chrome/browser/resources/options/language_options.css b/chrome/browser/resources/options/language_options.css index 53dfdca..fad9d53 100644 --- a/chrome/browser/resources/options/language_options.css +++ b/chrome/browser/resources/options/language_options.css @@ -9,7 +9,7 @@ .language-options h3 { -webkit-margin-start: 12px; - font-size: 75%; + font-size: 100%; font-weight: bold; margin-top: 12px; } @@ -73,7 +73,7 @@ #language-options-list { -webkit-box-flex: 1; - padding: 0; + padding: 1px 0 0; width: 100%; } @@ -87,31 +87,32 @@ margin-top: 12px; } -#add-language-overlay-language-list { +#add-language-overlay-language-list[os=chromeos] { -webkit-column-count: 2; -webkit-column-gap: 20px; } -#add-language-overlay-cancel-button { +#add-language-overlay-cancel-button[os=chromeos] { /* Place the button in the center. */ display: block; margin: auto; margin-top: 15px; } -#add-language-overlay-page { +#add-language-overlay-page[os=chromeos] { width: 800px; } -#add-language-overlay-page button { +#add-language-overlay-page[os=chromeos] button { padding: 0; text-align: left; } -#add-language-overlay-page ul { +#add-language-overlay-page[os=chromeos] ul { padding: 0; margin: 0; } + /* TODO(kochi): This is temporary copy from new_new_tab.css */ /* Notification */ diff --git a/chrome/browser/resources/options/language_options.html b/chrome/browser/resources/options/language_options.html index be7ea29..528542b 100644 --- a/chrome/browser/resources/options/language_options.html +++ b/chrome/browser/resources/options/language_options.html @@ -6,7 +6,9 @@ </div> <div class="language-options-header"> <div i18n-content="add_language_instructions"></div> +<if expr="pp_ifdef('chromeos')"> <div i18n-content="input_method_instructions"></div> +</if> </div> <div class="language-options"> <div class="language-options-left"> @@ -21,26 +23,49 @@ </div> <div class="language-options-right"> <h3 id="language-options-language-name"></h3> +<if expr="os != 'darwin'"> <div class="language-options-contents"> <button id="language-options-ui-language-button"></button> </div> +</if> <div class="language-options-contents"> <button id="language-options-spell-check-language-button"></button> </div> <div id="language-options-ui-notification-bar" class="language-options-notification"> - <div i18n-content="sign_out_required"></div> - <button id="language-options-ui-sign-out-button" - i18n-content="sign_out_button"></button> + <div i18n-content="restart_required"></div> + <button id="language-options-ui-restart-button" + i18n-content="restart_button"></button> </div> +<if expr="pp_ifdef('chromeos')"> <h3 i18n-content="input_method"></h3> <div id="language-options-input-method-list" class="language-options-contents"> </div> +</if> </div> </div> <div class="language-options-footer"> +<if expr="pp_ifdef('chromeos')"> <div i18n-content="switch_input_methods_hint"></div> <div i18n-content="select_previous_input_method_hint"></div> +</if> +<if expr="not pp_ifdef('chromeos')"> + <div id="spell-check-option"> + <label class="checkbox"> + <input id="enable-spell-check" pref="browser.enable_spellchecking" + metric="Options_SpellCheck" type="checkbox"> + <span i18n-content="enable_spell_check"></span> + </label> + </div> + <div id="auto-spell-correction-option" class="hidden"> + <label class="checkbox"> + <input id="enable-auto-spell-correction" + pref="browser.enable_autospellcorrect" + metric="Options_AutoSpellCorrection" type="checkbox"> + <span i18n-content="enable_auto_spell_correction"></span> + </label> + </div> +</if> </div> </div> diff --git a/chrome/browser/resources/options/language_options.js b/chrome/browser/resources/options/language_options.js index af09401..9f6e793 100644 --- a/chrome/browser/resources/options/language_options.js +++ b/chrome/browser/resources/options/language_options.js @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -58,8 +58,12 @@ cr.define('options', function() { this.addEventListener('visibleChange', this.handleVisibleChange_.bind(this)); - this.initializeInputMethodList_(); - this.initializeLanguageCodeToInputMehotdIdsMap_(); + if (cr.isChromeOS) { + this.initializeInputMethodList_(); + this.initializeLanguageCodeToInputMehotdIdsMap_(); + } + Preferences.getInstance().addEventListener(this.spellCheckDictionaryPref, + this.handleSpellCheckDictionaryPrefChange_.bind(this)); // Set up add button. $('language-options-add-button').onclick = function(e) { @@ -80,10 +84,22 @@ cr.define('options', function() { // Setup add language overlay page. OptionsPage.registerOverlay(AddLanguageOverlay.getInstance()); - // Listen to user clicks on the add language list. - var addLanguageList = $('add-language-overlay-language-list'); - addLanguageList.addEventListener('click', - this.handleAddLanguageListClick_.bind(this)); + if (cr.isChromeOS) { + // Listen to user clicks on the add language list. + var addLanguageList = $('add-language-overlay-language-list'); + addLanguageList.addEventListener('click', + this.handleAddLanguageListClick_.bind(this)); + } else { + // Listen to add language dialog ok button. + var addLanguageOkButton = $('add-language-overlay-ok-button'); + addLanguageOkButton.addEventListener('click', + this.handleAddLanguageOkButtonClick_.bind(this)); + + // Show experimental features if enabled. + if (templateData.experimentalSpellCheckFeatures == 'true') { + $('auto-spell-correction-option').classList.remove('hidden'); + } + } }, // The preference is a CSV string that describes preload engines @@ -137,8 +153,6 @@ cr.define('options', function() { // Listen to pref change once the input method list is initialized. Preferences.getInstance().addEventListener(this.preloadEnginesPref, this.handlePreloadEnginesPrefChange_.bind(this)); - Preferences.getInstance().addEventListener(this.spellCheckDictionaryPref, - this.handleSpellCheckDictionaryPrefChange_.bind(this)); }, /** @@ -191,9 +205,11 @@ cr.define('options', function() { } } this.updateSelectedLanguageName_(languageCode); - this.updateUiLanguageButton_(languageCode); + if (!cr.isMac) + this.updateUiLanguageButton_(languageCode); this.updateSpellCheckLanguageButton_(languageCode); - this.updateInputMethodList_(languageCode); + if (cr.isChromeOS) + this.updateInputMethodList_(languageCode); this.updateLanguageListInAddLanguageOverlay_(); }, @@ -203,9 +219,11 @@ cr.define('options', function() { * @private */ handleLanguageOptionsListSave_: function(e) { - // Sort the preload engines per the saved languages before save. - this.preloadEngines_ = this.sortPreloadEngines_(this.preloadEngines_); - this.savePreloadEnginesPref_(); + if (cr.isChromeOS) { + // Sort the preload engines per the saved languages before save. + this.preloadEngines_ = this.sortPreloadEngines_(this.preloadEngines_); + this.savePreloadEnginesPref_(); + } }, /** @@ -321,8 +339,8 @@ cr.define('options', function() { uiLanguageButton.onclick = function(e) { chrome.send('uiLanguageChange', [languageCode]); } - $('language-options-ui-sign-out-button').onclick = function(e) { - chrome.send('uiLanguageSignOut'); + $('language-options-ui-restart-button').onclick = function(e) { + chrome.send('uiLanguageRestart'); } } else { // If the language is not supported as UI language, the button @@ -507,6 +525,19 @@ cr.define('options', function() { }, /** + * Handles add language dialog ok button. + */ + handleAddLanguageOkButtonClick_ : function() { + var languagesSelect = $('add-language-overlay-language-list'); + var selectedIndex = languagesSelect.selectedIndex; + if (selectedIndex >= 0) { + var selection = languagesSelect.options[selectedIndex]; + $('language-options-list').addLanguage(String(selection.value)); + OptionsPage.clearOverlays(); + } + }, + + /** * Handles remove button's click event. * @param {Event} e Click event. */ @@ -520,14 +551,16 @@ cr.define('options', function() { localStrings.getString('ok_button')); return; } - // Disable input methods associated with |languageCode|. - // Don't allow removing the language if cerntain conditions are met. - // See removePreloadEnginesByLanguageCode_() for details. - if (!this.removePreloadEnginesByLanguageCode_(languageCode)) { - this.showNotification_( - localStrings.getString('please_add_another_language'), - localStrings.getString('ok_button')); - return; + if (cr.isChromeOS) { + // Disable input methods associated with |languageCode|. + // Don't allow removing the language if cerntain conditions are met. + // See removePreloadEnginesByLanguageCode_() for details. + if (!this.removePreloadEnginesByLanguageCode_(languageCode)) { + this.showNotification_( + localStrings.getString('please_add_another_language'), + localStrings.getString('ok_button')); + return; + } } languageOptionsList.removeSelectedLanguage(); }, diff --git a/chrome/browser/resources/options/options.js b/chrome/browser/resources/options/options.js index 0e4ba44..f488b2b 100644 --- a/chrome/browser/resources/options/options.js +++ b/chrome/browser/resources/options/options.js @@ -75,22 +75,22 @@ function load() { new OptionsPage('languageChewing', localStrings.getString('languageChewingPage'), 'languageChewingPage'), - SystemOptions.getInstance()); + LanguageOptions.getInstance()); OptionsPage.registerSubPage( new OptionsPage('languageHangul', localStrings.getString('languageHangulPage'), 'languageHangulPage'), - SystemOptions.getInstance()); + LanguageOptions.getInstance()); OptionsPage.registerSubPage( new OptionsPage('languageMozc', localStrings.getString('languageMozcPage'), 'languageMozcPage'), - SystemOptions.getInstance()); + LanguageOptions.getInstance()); OptionsPage.registerSubPage( new OptionsPage('languagePinyin', localStrings.getString('languagePinyinPage'), 'languagePinyinPage'), - SystemOptions.getInstance()); + LanguageOptions.getInstance()); OptionsPage.register(InternetOptions.getInstance()); } OptionsPage.register(AdvancedOptions.getInstance()); @@ -106,6 +106,11 @@ function load() { OptionsPage.registerSubPage(FontSettings.getInstance(), AdvancedOptions.getInstance(), [$('fontSettingsCustomizeFontsButton')]); + if (!cr.isChromeOS) { + OptionsPage.registerSubPage(LanguageOptions.getInstance(), + AdvancedOptions.getInstance(), + [$('language-button')]); + } if (!cr.isWindows && !cr.isMac) { OptionsPage.registerSubPage(CertificateManager.getInstance(), AdvancedOptions.getInstance(), @@ -167,8 +172,14 @@ function load() { // Allow platform specific CSS rules. if (cr.isMac) document.documentElement.setAttribute('os', 'mac'); - if (cr.isLinux) + if (cr.isWindows) + document.documentElement.setAttribute('os', 'windows'); + if (cr.isChromeOS) + document.documentElement.setAttribute('os', 'chromeos'); + if (cr.isLinux) { + document.documentElement.setAttribute('os', 'linux'); document.documentElement.setAttribute('toolkit', 'gtk'); + } if (cr.isViews) document.documentElement.setAttribute('toolkit', 'views'); |