| Index: chrome/browser/spellchecker/spellcheck_custom_dictionary.cc
|
| diff --git a/chrome/browser/spellchecker/spellcheck_custom_dictionary.cc b/chrome/browser/spellchecker/spellcheck_custom_dictionary.cc
|
| index f9e2941406768f9f6d9e0894877cf1689b698893..4510332e59e3032ee7b35bf26f640ff6f3f2885c 100644
|
| --- a/chrome/browser/spellchecker/spellcheck_custom_dictionary.cc
|
| +++ b/chrome/browser/spellchecker/spellcheck_custom_dictionary.cc
|
| @@ -57,9 +57,27 @@ void SpellcheckCustomDictionary::LoadDictionaryIntoCustomWordList(
|
| }
|
|
|
| base::SplitString(contents, '\n', custom_words);
|
| +
|
| + // Erase duplicates.
|
| + std::sort(custom_words->begin(), custom_words->end());
|
| + custom_words->erase(std::unique(custom_words->begin(), custom_words->end()),
|
| + custom_words->end());
|
| +
|
| // Clear out empty words.
|
| custom_words->erase(remove_if(custom_words->begin(), custom_words->end(),
|
| mem_fun_ref(&std::string::empty)), custom_words->end());
|
| +
|
| + // Write out the clean file.
|
| + std::stringstream ss;
|
| + for (WordList::iterator it = custom_words->begin();
|
| + it != custom_words->end();
|
| + ++it) {
|
| + ss << *it << '\n';
|
| + }
|
| + contents = ss.str();
|
| + file_util::WriteFile(custom_dictionary_path_,
|
| + contents.c_str(),
|
| + contents.length());
|
| }
|
|
|
| void SpellcheckCustomDictionary::SetCustomWordList(WordList* custom_words) {
|
| @@ -170,8 +188,8 @@ void SpellcheckCustomDictionary::EraseWordFromCustomDictionary(
|
| WordList custom_words;
|
| LoadDictionaryIntoCustomWordList(&custom_words);
|
|
|
| - char empty[] = {'\0'};
|
| - char separator[] = {'\n', '\0'};
|
| + const char empty[] = {'\0'};
|
| + const char separator[] = {'\n', '\0'};
|
| file_util::WriteFile(custom_dictionary_path_, empty, 0);
|
| for (WordList::iterator it = custom_words.begin();
|
| it != custom_words.end();
|
|
|