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

Unified Diff: chrome/renderer/spellchecker/hunspell_engine.cc

Issue 11362063: Editing the custom spelling dictionary (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Exclude custom dictionary WebUI from mac 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
« no previous file with comments | « chrome/renderer/spellchecker/hunspell_engine.h ('k') | chrome/renderer/spellchecker/spellcheck.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/spellchecker/hunspell_engine.cc
diff --git a/chrome/renderer/spellchecker/hunspell_engine.cc b/chrome/renderer/spellchecker/hunspell_engine.cc
index 9b352d5c88b76ef4c0022d383acdc6a2c099d73f..71a14d2d5228c9cb54f5f0eceb92a77bdf98ed91 100644
--- a/chrome/renderer/spellchecker/hunspell_engine.cc
+++ b/chrome/renderer/spellchecker/hunspell_engine.cc
@@ -56,10 +56,9 @@ void HunspellEngine::InitializeHunspell() {
new Hunspell(bdict_file_->data(), bdict_file_->length()));
// Add custom words to Hunspell.
- for (std::vector<std::string>::iterator it = custom_words_.begin();
- it != custom_words_.end(); ++it) {
+ chrome::spellcheck_common::WordList::iterator it;
+ for (it = custom_words_.begin(); it != custom_words_.end(); ++it)
AddWordToHunspell(*it);
- }
DHISTOGRAM_TIMES("Spellcheck.InitTime",
base::Histogram::DebugNow() - debug_start_time);
@@ -73,6 +72,11 @@ void HunspellEngine::AddWordToHunspell(const std::string& word) {
hunspell_->add(word.c_str());
}
+void HunspellEngine::RemoveWordFromHunspell(const std::string& word) {
+ if (!word.empty() && word.length() < MAXWORDLEN)
+ hunspell_->remove(word.c_str());
+}
+
bool HunspellEngine::CheckSpelling(const string16& word_to_check, int tag) {
bool word_correct = false;
std::string word_to_check_utf8(UTF16ToUTF8(word_to_check));
@@ -124,6 +128,17 @@ void HunspellEngine::OnWordAdded(const std::string& word) {
}
}
+void HunspellEngine::OnWordRemoved(const std::string& word) {
+ if (!hunspell_.get()) {
+ chrome::spellcheck_common::WordList::iterator it = std::find(
+ custom_words_.begin(), custom_words_.end(), word);
+ if (it != custom_words_.end())
+ custom_words_.erase(it);
+ } else {
+ RemoveWordFromHunspell(word);
+ }
+}
+
bool HunspellEngine::InitializeIfNeeded() {
if (!initialized_ && !dictionary_requested_) {
// RenderThread will not exist in test.
« no previous file with comments | « chrome/renderer/spellchecker/hunspell_engine.h ('k') | chrome/renderer/spellchecker/spellcheck.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698