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