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