Chromium Code Reviews| Index: chrome/renderer/spellchecker/spellcheck_provider.cc |
| diff --git a/chrome/renderer/spellchecker/spellcheck_provider.cc b/chrome/renderer/spellchecker/spellcheck_provider.cc |
| index a523d22e0b0c96c782f65267517c9d9f6411f0c5..706844dc7cf288cc9a67a0063ce9254639a383ad 100644 |
| --- a/chrome/renderer/spellchecker/spellcheck_provider.cc |
| +++ b/chrome/renderer/spellchecker/spellcheck_provider.cc |
| @@ -51,20 +51,36 @@ void SpellCheckProvider::RequestTextChecking( |
| const WebString& text, |
| int document_tag, |
| WebTextCheckingCompletion* completion) { |
| + DCHECK(completion); |
| + if (!completion) |
| + return; |
| + |
| + if (text.isEmpty()) { |
| + completion->didFinishCheckingText(WebVector<WebTextCheckingResult>()); |
| + return; |
| + } |
| + |
| #if defined(OS_MACOSX) |
| - // Text check (unified request for grammar and spell check) is only |
| - // available for browser process, so we ask the system spellchecker |
| - // over IPC or return an empty result if the checker is not |
| - // available. |
| + // SpellChecker on Mac is only available for browser process, so we ask the |
| + // system spellchecker over IPC. |
| Send(new SpellCheckHostMsg_RequestTextCheck( |
| - routing_id(), |
| - text_check_completions_.Add(completion), |
| - document_tag, |
| - text)); |
| + routing_id(), |
|
Hironori Bono
2012/01/27 06:17:41
nit: I do not think we need these space characters
shinyak
2012/01/30 06:53:05
Done. Sorry.
|
| + text_check_completions_.Add(completion), |
| + document_tag, |
| + text)); |
| #else |
| - completion->didFinishCheckingText( |
| - std::vector<WebTextCheckingResult>()); |
| -#endif // !OS_MACOSX |
| + // On the other platforms, currently we don't have a system spellchecker. |
| + // So we post a task to spellcheck. |
| + |
| + // |chrome_content_renderer_client| may be NULL in unit tests. |
| + if (chrome_content_renderer_client_) { |
| + chrome_content_renderer_client_->spellcheck()->RequestTextChecking( |
| + text, document_tag, completion); |
| + return; |
| + } |
| + |
| + completion->didFinishCheckingText(WebVector<WebTextCheckingResult>()); |
| +#endif |
| } |
| bool SpellCheckProvider::OnMessageReceived(const IPC::Message& message) { |