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.
5 #ifndef CHROME_RENDERER_SPELLCHECKER_HUNSPELL_ENGINE_H_
6 #define CHROME_RENDERER_SPELLCHECKER_HUNSPELL_ENGINE_H_
11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string16.h"
13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/common/spellcheck_common.h"
15 #include "chrome/renderer/spellchecker/spelling_engine.h"
20 class MemoryMappedFile;
23 class HunspellEngine : public SpellingEngine {
26 virtual ~HunspellEngine();
28 virtual void Init(base::PlatformFile file) OVERRIDE;
30 virtual bool InitializeIfNeeded() OVERRIDE;
31 virtual bool IsEnabled() OVERRIDE;
32 virtual bool CheckSpelling(const string16& word_to_check, int tag) OVERRIDE;
33 virtual void FillSuggestionList(const string16& wrong_word,
34 std::vector<string16>* optional_suggestions) OVERRIDE;
37 // Initializes the Hunspell dictionary, or does nothing if |hunspell_| is
38 // non-null. This blocks.
39 void InitializeHunspell();
41 // We memory-map the BDict file.
42 scoped_ptr<base::MemoryMappedFile> bdict_file_;
44 // The hunspell dictionary in use.
45 scoped_ptr<Hunspell> hunspell_;
47 base::PlatformFile file_;
49 // This flags is true if we have been initialized.
50 // The value indicates whether we should request a
51 // dictionary from the browser when the render view asks us to check the
52 // spelling of a word.
55 // This flags is true if we have requested dictionary.
56 bool dictionary_requested_;
59 #endif // CHROME_RENDERER_SPELLCHECKER_HUNSPELL_ENGINE_H_