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

Side by Side Diff: chrome/renderer/spellchecker/spellcheck.cc

Issue 11362063: Editing the custom spelling dictionary (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/spellchecker/spellcheck.h" 5 #include "chrome/renderer/spellchecker/spellcheck.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "chrome/common/render_messages.h" 10 #include "chrome/common/render_messages.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } 49 }
50 50
51 SpellCheck::~SpellCheck() { 51 SpellCheck::~SpellCheck() {
52 } 52 }
53 53
54 bool SpellCheck::OnControlMessageReceived(const IPC::Message& message) { 54 bool SpellCheck::OnControlMessageReceived(const IPC::Message& message) {
55 bool handled = true; 55 bool handled = true;
56 IPC_BEGIN_MESSAGE_MAP(SpellCheck, message) 56 IPC_BEGIN_MESSAGE_MAP(SpellCheck, message)
57 IPC_MESSAGE_HANDLER(SpellCheckMsg_Init, OnInit) 57 IPC_MESSAGE_HANDLER(SpellCheckMsg_Init, OnInit)
58 IPC_MESSAGE_HANDLER(SpellCheckMsg_WordAdded, OnWordAdded) 58 IPC_MESSAGE_HANDLER(SpellCheckMsg_WordAdded, OnWordAdded)
59 IPC_MESSAGE_HANDLER(SpellCheckMsg_WordRemoved, OnWordRemoved)
59 IPC_MESSAGE_HANDLER(SpellCheckMsg_EnableAutoSpellCorrect, 60 IPC_MESSAGE_HANDLER(SpellCheckMsg_EnableAutoSpellCorrect,
60 OnEnableAutoSpellCorrect) 61 OnEnableAutoSpellCorrect)
61 IPC_MESSAGE_UNHANDLED(handled = false) 62 IPC_MESSAGE_UNHANDLED(handled = false)
62 IPC_END_MESSAGE_MAP() 63 IPC_END_MESSAGE_MAP()
63 64
64 return handled; 65 return handled;
65 } 66 }
66 67
67 void SpellCheck::OnInit(IPC::PlatformFileForTransit bdict_file, 68 void SpellCheck::OnInit(IPC::PlatformFileForTransit bdict_file,
68 const std::vector<std::string>& custom_words, 69 const std::vector<std::string>& custom_words,
69 const std::string& language, 70 const std::string& language,
70 bool auto_spell_correct) { 71 bool auto_spell_correct) {
71 Init(IPC::PlatformFileForTransitToPlatformFile(bdict_file), 72 Init(IPC::PlatformFileForTransitToPlatformFile(bdict_file),
72 custom_words, language); 73 custom_words, language);
73 auto_spell_correct_turned_on_ = auto_spell_correct; 74 auto_spell_correct_turned_on_ = auto_spell_correct;
74 #if !defined(OS_MACOSX) 75 #if !defined(OS_MACOSX)
75 PostDelayedSpellCheckTask(pending_request_param_.release()); 76 PostDelayedSpellCheckTask(pending_request_param_.release());
76 #endif 77 #endif
77 } 78 }
78 79
79 void SpellCheck::OnWordAdded(const std::string& word) { 80 void SpellCheck::OnWordAdded(const std::string& word) {
80 if (platform_spelling_engine_) 81 if (platform_spelling_engine_.get())
81 platform_spelling_engine_->OnWordAdded(word); 82 platform_spelling_engine_->OnWordAdded(word);
82 } 83 }
83 84
85 void SpellCheck::OnWordRemoved(const std::string& word) {
86 if (platform_spelling_engine_.get())
87 platform_spelling_engine_->OnWordRemoved(word);
88 }
89
84 void SpellCheck::OnEnableAutoSpellCorrect(bool enable) { 90 void SpellCheck::OnEnableAutoSpellCorrect(bool enable) {
85 auto_spell_correct_turned_on_ = enable; 91 auto_spell_correct_turned_on_ = enable;
86 } 92 }
87 93
88 // TODO(groby): Make sure we always have a spelling engine, even before Init() 94 // TODO(groby): Make sure we always have a spelling engine, even before Init()
89 // is called. 95 // is called.
90 void SpellCheck::Init(base::PlatformFile file, 96 void SpellCheck::Init(base::PlatformFile file,
91 const std::vector<std::string>& custom_words, 97 const std::vector<std::string>& custom_words,
92 const std::string& language) { 98 const std::string& language) {
93 bool use_platform_spelling_engine = 99 bool use_platform_spelling_engine =
(...skipping 23 matching lines...) Expand all
117 std::vector<string16>* optional_suggestions) { 123 std::vector<string16>* optional_suggestions) {
118 DCHECK(in_word_len >= 0); 124 DCHECK(in_word_len >= 0);
119 DCHECK(misspelling_start && misspelling_len) << "Out vars must be given."; 125 DCHECK(misspelling_start && misspelling_len) << "Out vars must be given.";
120 126
121 // Do nothing if we need to delay initialization. (Rather than blocking, 127 // Do nothing if we need to delay initialization. (Rather than blocking,
122 // report the word as correctly spelled.) 128 // report the word as correctly spelled.)
123 if (InitializeIfNeeded()) 129 if (InitializeIfNeeded())
124 return true; 130 return true;
125 131
126 // Do nothing if spell checking is disabled. 132 // Do nothing if spell checking is disabled.
127 if (!platform_spelling_engine_ || 133 if (!platform_spelling_engine_ ||
rpetterson 2012/11/14 19:47:09 Can you update this to platform_spelling_engine_.g
please use gerrit instead 2012/11/14 22:54:46 Done.
128 !platform_spelling_engine_->IsEnabled()) 134 !platform_spelling_engine_->IsEnabled())
129 return true; 135 return true;
130 136
131 *misspelling_start = 0; 137 *misspelling_start = 0;
132 *misspelling_len = 0; 138 *misspelling_len = 0;
133 if (in_word_len == 0) 139 if (in_word_len == 0)
134 return true; // No input means always spelled correctly. 140 return true; // No input means always spelled correctly.
135 141
136 string16 word; 142 string16 word;
137 int word_start; 143 int word_start;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 } 390 }
385 } 391 }
386 list[i] = WebKit::WebTextCheckingResult(type, 392 list[i] = WebKit::WebTextCheckingResult(type,
387 word_location + line_offset, 393 word_location + line_offset,
388 word_length, 394 word_length,
389 spellcheck_results[i].replacement); 395 spellcheck_results[i].replacement);
390 } 396 }
391 textcheck_results->swap(list); 397 textcheck_results->swap(list);
392 } 398 }
393 #endif 399 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698