diff options
author | yusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-13 00:56:53 +0000 |
---|---|---|
committer | yusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-13 00:56:53 +0000 |
commit | 2f56f91cd78b919a7c04eaafd6fcaf54d886aafe (patch) | |
tree | 7fcbbf2b79e7aef8168a8a711417af172b3b31a6 | |
parent | fb840d23c62b23fd56403068398ff619eebdd957 (diff) | |
download | chromium_src-2f56f91cd78b919a7c04eaafd6fcaf54d886aafe.zip chromium_src-2f56f91cd78b919a7c04eaafd6fcaf54d886aafe.tar.gz chromium_src-2f56f91cd78b919a7c04eaafd6fcaf54d886aafe.tar.bz2 |
Display [x] button in the "language and input" WebUI correctly.
Inline [x] buttons, which replace the "Remove" button, are introduced by r80683 but the change seems not to be working fine on Chrome OS. This change fixes the behavior of [x] buttons on Chrome OS.
http://src.chromium.org/viewvc/chrome?view=rev&revision=80683
* languageIsDeletable() obviously should not update the preload_engines preference. Remove pref manipulations from removePreloadEnginesByLanguageCode_() and renamed the function to canDeleteLanguage_().
* Update 'deletable' flags of menu items (= language names) not only when a new item is added, but also an IME checkbox is clicked. This is necessary because whether a menu item is removable or not can be determined by a set of IMEs enabled.
BUG=chromium-os:14015
BUG=chromium-os:11648
TEST=manually done, ran try bot as well.
Review URL: http://codereview.chromium.org/6826037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81346 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/resources/options/language_list.js | 12 | ||||
-rw-r--r-- | chrome/browser/resources/options/language_options.js | 24 |
2 files changed, 21 insertions, 15 deletions
diff --git a/chrome/browser/resources/options/language_list.js b/chrome/browser/resources/options/language_list.js index 88d3b3c..05846c9 100644 --- a/chrome/browser/resources/options/language_list.js +++ b/chrome/browser/resources/options/language_list.js @@ -152,6 +152,18 @@ cr.define('options', function() { }, /* + * For each item, determines whether it's deletable. + */ + updateDeletable: function() { + for (var i = 0; i < this.dataModel.length; ++i) { + var item = this.getListItemByIndex(i); + var languageCode = item.languageCode; + var languageOptions = options.LanguageOptions.getInstance(); + item.deletable = languageOptions.languageIsDeletable(languageCode); + } + }, + + /* * Adds a language to the language list. * @param {string} languageCode language code (ex. "fr"). */ diff --git a/chrome/browser/resources/options/language_options.js b/chrome/browser/resources/options/language_options.js index 9e96c6a..15cdcae 100644 --- a/chrome/browser/resources/options/language_options.js +++ b/chrome/browser/resources/options/language_options.js @@ -544,7 +544,7 @@ cr.define('options', function() { // Don't allow removing the language if cerntain conditions are met. // See removePreloadEnginesByLanguageCode_() for details. return (!cr.isChromeOS || - this.removePreloadEnginesByLanguageCode_(languageCode)); + this.canDeleteLanguage_(languageCode)); }, /** @@ -574,19 +574,15 @@ cr.define('options', function() { }, /** - * Removes preload engines associated with the given language code. - * However, this function does not remove engines (input methods) that - * are used for other active languages. For instance, if "xkb:us::eng" - * is used for English and Filipino, and the two languages are active, - * this function does not remove "xkb:us::eng" when either of these - * languages is removed. Instead, it'll remove "xkb:us::eng" when the - * both languages are gone. + * Checks whether it's possible to remove the language specified by + * languageCode and returns true if possible. This function returns false + * if the removal causes the number of preload engines to be zero. * * @param {string} languageCode Language code (ex. "fr"). * @return {boolean} Returns true on success. * @private */ - removePreloadEnginesByLanguageCode_: function(languageCode) { + canDeleteLanguage_: function(languageCode) { // First create the set of engines to be removed from input methods // associated with the language code. var enginesToBeRemovedSet = {}; @@ -596,6 +592,7 @@ cr.define('options', function() { } // Then eliminate engines that are also used for other active languages. + // For instance, if "xkb:us::eng" is used for both English and Filipino. var languageCodes = $('language-options-list').getLanguageCodes(); for (var i = 0; i < languageCodes.length; i++) { // Skip the target language code. @@ -624,12 +621,7 @@ cr.define('options', function() { } // Don't allow this operation if it causes the number of preload // engines to be zero. - if (newPreloadEngines.length == 0) { - return false; - } - this.preloadEngines_ = newPreloadEngines; - this.savePreloadEnginesPref_(); - return true; + return (newPreloadEngines.length > 0); }, /** @@ -674,6 +666,8 @@ cr.define('options', function() { this.preloadEngines_.push(checkboxes[i].inputMethodId); } } + var languageOptionsList = $('language-options-list'); + languageOptionsList.updateDeletable(); }, /** |