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

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

Issue 11293241: Cleaning up the custom dictionary code relative to the SpellcheckService to make the custom diction… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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_custom_dictionary.cc
diff --git a/chrome/browser/spellchecker/spellcheck_custom_dictionary.cc b/chrome/browser/spellchecker/spellcheck_custom_dictionary.cc
index ad91cf677ba2bab29013f51fca8d39d66441c5e7..a67596ebd0a974a6ac0bc09e77bcb6848e6db24a 100644
--- a/chrome/browser/spellchecker/spellcheck_custom_dictionary.cc
+++ b/chrome/browser/spellchecker/spellcheck_custom_dictionary.cc
@@ -9,8 +9,11 @@
#include "base/string_split.h"
#include "base/string_util.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/spellchecker/spellcheck_service.h"
#include "chrome/common/chrome_constants.h"
+#include "chrome/common/spellcheck_messages.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/render_process_host.h"
#include <functional>
@@ -19,7 +22,8 @@ using chrome::spellcheck_common::WordList;
SpellcheckCustomDictionary::SpellcheckCustomDictionary(Profile* profile)
: SpellcheckDictionary(profile),
- custom_dictionary_path_() {
+ custom_dictionary_path_(),
+ weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
DCHECK(profile);
custom_dictionary_path_ =
profile_->GetPath().Append(chrome::kCustomDictionaryFileName);
@@ -86,4 +90,26 @@ const WordList& SpellcheckCustomDictionary::GetCustomWords() const {
return custom_words_;
}
+void SpellcheckCustomDictionary::AddWord(const std::string& word) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ CustomWordAddedLocally(word);
+
+ BrowserThread::PostTaskAndReply(BrowserThread::FILE, FROM_HERE,
+ base::Bind(&SpellcheckCustomDictionary::WriteWordToCustomDictionary,
+ base::Unretained(this), word),
+ base::Bind(&SpellcheckCustomDictionary::AddWordComplete,
+ weak_ptr_factory_.GetWeakPtr(), word));
+}
+
+void SpellcheckCustomDictionary::AddWordComplete(const std::string& word) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ for (content::RenderProcessHost::iterator i(
+ content::RenderProcessHost::AllHostsIterator());
+ !i.IsAtEnd(); i.Advance()) {
+ i.GetCurrentValue()->Send(new SpellCheckMsg_WordAdded(word));
+ }
+}
+

Powered by Google App Engine
This is Rietveld 408576698