Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2329)

Unified Diff: chrome/browser/spellchecker/spellcheck_host_impl.cc

Issue 8345034: SpellCheck: the custom dictionary should be per profile. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixed. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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,

Powered by Google App Engine
This is Rietveld 408576698