| Index: chrome/browser/resources/options/language_dictionary_overlay_word_list.js
|
| diff --git a/chrome/browser/resources/options/language_dictionary_overlay_word_list.js b/chrome/browser/resources/options/language_dictionary_overlay_word_list.js
|
| index b1bff432ec30906a46c89874f9075ac023d3cc48..6ae61410aa5bc8e128b0017315c57e5dfdd67873 100644
|
| --- a/chrome/browser/resources/options/language_dictionary_overlay_word_list.js
|
| +++ b/chrome/browser/resources/options/language_dictionary_overlay_word_list.js
|
| @@ -98,6 +98,15 @@ cr.define('options.dictionary_words', function() {
|
| allWordsList_: null,
|
|
|
| /**
|
| + * The list of words that have been removed from the dictionary, but we have
|
| + * not received a notification of their removal yet. Once we're notified of
|
| + * a word removal, we remove it from this list.
|
| + * @type {Array}
|
| + * @private
|
| + */
|
| + removedWordsList_: [],
|
| +
|
| + /**
|
| * Add a dictionary word.
|
| * @param {string} dictionaryWord The word to add.
|
| * @private
|
| @@ -136,6 +145,55 @@ cr.define('options.dictionary_words', function() {
|
| },
|
|
|
| /**
|
| + * Add non-duplicate dictionary words.
|
| + * @param {Array} entries The list of dictionary words.
|
| + */
|
| + addWords: function(entries) {
|
| + var to_add = [];
|
| + for (var i in entries) {
|
| + if (this.allWordsList_.indexOf(entries[i]) == -1) {
|
| + this.allWordsList_.push(entries[i]);
|
| + to_add.push(entries[i]);
|
| + }
|
| + }
|
| + if (to_add.length == 0)
|
| + return;
|
| + for (var i in to_add)
|
| + this.dataModel.splice(this.dataModel.length - 1, 0, to_add[i]);
|
| + this.onWordListChanged();
|
| + },
|
| +
|
| + /**
|
| + * Removes dictionary words that are not in |removedWordsList_|. If a word
|
| + * is in |removedWordsList_|, then removes the word from there instead.
|
| + * @param {Array} entries The list of dictionary words.
|
| + */
|
| + removeWords: function(entries) {
|
| + var index;
|
| + var to_remove = [];
|
| + for (var i in entries) {
|
| + index = this.removedWordsList_.indexOf(entries[i]);
|
| + if (index > -1) {
|
| + this.removedWordsList_.splice(index, 1);
|
| + } else {
|
| + index = this.allWordsList_.indexOf(entries[i]);
|
| + if (index > -1) {
|
| + this.allWordsList_.splice(index, 1);
|
| + to_remove.push(entries[i]);
|
| + }
|
| + }
|
| + }
|
| + if (to_remove.length == 0)
|
| + return;
|
| + for (var i in to_remove) {
|
| + index = this.dataModel.indexOf(to_remove[i]);
|
| + if (index > -1)
|
| + this.dataModel.splice(index, 1);
|
| + }
|
| + this.onWordListChanged();
|
| + },
|
| +
|
| + /**
|
| * True if the data model contains no words, otherwise false.
|
| * @type {boolean}
|
| */
|
| @@ -162,6 +220,7 @@ cr.define('options.dictionary_words', function() {
|
| assert(allWordsListIndex > -1);
|
| this.allWordsList_.splice(allWordsListIndex, 1);
|
| this.dataModel.splice(index, 1);
|
| + this.removedWordsList_.push(item);
|
| this.onWordListChanged();
|
| chrome.send('removeDictionaryWord', [item]);
|
| },
|
|
|