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
3 // found in the LICENSE file.
4
5 #include "cocoa_spelling_engine_mac.h"
6
7 #include "chrome/common/spellcheck_messages.h"
8 #include "content/public/renderer/render_thread.h"
9
10 using content::RenderThread;
11
CreateNativeSpellingEngine()12 SpellingEngine* CreateNativeSpellingEngine() {
13 return new CocoaSpellingEngine();
14 }
15
Init(base::File bdict_file)16 void CocoaSpellingEngine::Init(base::File bdict_file) {
17 DCHECK(!bdict_file.IsValid());
18 }
19
InitializeIfNeeded()20 bool CocoaSpellingEngine::InitializeIfNeeded() {
21 return false; // We never need to initialize.
22 }
23
IsEnabled()24 bool CocoaSpellingEngine::IsEnabled() {
25 return true; // OSX is always enabled.
26 }
27
28 // Synchronously query against NSSpellCheck.
29 // TODO(groby): We might want async support here, too. Ideally,
30 // all engines share a similar path for async requests.
CheckSpelling(const base::string16 & word_to_check,int tag)31 bool CocoaSpellingEngine::CheckSpelling(const base::string16& word_to_check,
32 int tag) {
33 bool word_correct = false;
34 RenderThread::Get()->Send(new SpellCheckHostMsg_CheckSpelling(
35 word_to_check, tag, &word_correct));
36 return word_correct;
37 }
38
39 // Synchronously query against NSSpellCheck.
40 // TODO(groby): We might want async support here, too. Ideally,
41 // all engines share a similar path for async requests.
FillSuggestionList(const base::string16 & wrong_word,std::vector<base::string16> * optional_suggestions)42 void CocoaSpellingEngine::FillSuggestionList(
43 const base::string16& wrong_word,
44 std::vector<base::string16>* optional_suggestions) {
45 RenderThread::Get()->Send(new SpellCheckHostMsg_FillSuggestionList(
46 wrong_word, optional_suggestions));
47 }
48