Index: chrome/browser/spellchecker/spellcheck_host_impl.cc |
diff --git a/chrome/browser/spellchecker/spellcheck_host_impl.cc b/chrome/browser/spellchecker/spellcheck_host_impl.cc |
index d2ab6c329bd0014f113094aa690bb063a8123817..2a32c67b7315a21362561aefb7dd21ef8bd22fe5 100644 |
--- a/chrome/browser/spellchecker/spellcheck_host_impl.cc |
+++ b/chrome/browser/spellchecker/spellcheck_host_impl.cc |
@@ -238,15 +238,8 @@ void SpellCheckHostImpl::InitializeInternal() { |
request_context_getter_ = NULL; |
scoped_ptr<CustomWordList> custom_words(new CustomWordList()); |
- if (file_ != base::kInvalidPlatformFileValue) { |
- // Load custom dictionary. |
- std::string contents; |
- file_util::ReadFileToString(custom_dictionary_file_, &contents); |
- CustomWordList list_of_words; |
- base::SplitString(contents, '\n', &list_of_words); |
- for (size_t i = 0; i < list_of_words.size(); ++i) |
- custom_words->push_back(list_of_words[i]); |
- } |
+ if (file_ != base::kInvalidPlatformFileValue) |
+ LoadCustomDictionary(custom_words.get()); |
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
NewRunnableMethod( |
@@ -309,15 +302,31 @@ void SpellCheckHostImpl::DownloadDictionary() { |
request_context_getter_ = NULL; |
} |
+void SpellCheckHostImpl::LoadCustomDictionary(CustomWordList* custom_words) { |
+ if (!custom_words) |
+ return; |
+ |
+ std::string contents; |
Hironori Bono
2011/10/20 04:48:50
nit: move this declaration above Line 317 "file_ut
shinyak (Google)
2011/10/20 12:04:52
Done.
|
+ CustomWordList list_of_words; |
Hironori Bono
2011/10/20 04:48:50
nit: ditto.
shinyak (Google)
2011/10/20 12:04:52
Done.
|
+ |
+ // Load custom dictionary for profile. |
+ if (profile_) |
+ profile_->LoadCustomDictionary(custom_words); |
+ |
+ // Load custom dictionary. |
+ file_util::ReadFileToString(custom_dictionary_file_, &contents); |
+ base::SplitString(contents, '\n', &list_of_words); |
Hironori Bono
2011/10/20 04:48:50
nit: need 'if (!contents.empty()) {' to avoid call
shinyak (Google)
2011/10/20 12:04:52
Done.
|
+ for (size_t i = 0; i < list_of_words.size(); ++i) { |
+ if (list_of_words[i] != "") |
+ custom_words->push_back(list_of_words[i]); |
+ } |
+} |
+ |
void SpellCheckHostImpl::WriteWordToCustomDictionary(const std::string& word) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
- // Stored in UTF-8. |
- std::string word_to_add(word + "\n"); |
- FILE* f = file_util::OpenFile(custom_dictionary_file_, "a+"); |
- if (f) |
- fputs(word_to_add.c_str(), f); |
- file_util::CloseFile(f); |
+ if (profile_) |
+ profile_->WriteWordToCustomDictionary(word); |
} |
void SpellCheckHostImpl::OnURLFetchComplete(const URLFetcher* source, |