OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_SPELLCHECK_H_ | 5 #ifndef CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_H_ |
6 #define CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_H_ | 6 #define CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/platform_file.h" | 14 #include "base/platform_file.h" |
15 #include "base/string16.h" | 15 #include "base/string16.h" |
16 #include "base/time.h" | 16 #include "base/time.h" |
17 #include "chrome/renderer/spellchecker/spellcheck_worditerator.h" | 17 #include "chrome/renderer/spellchecker/spellcheck_worditerator.h" |
18 #include "content/renderer/render_process_observer.h" | 18 #include "content/renderer/render_process_observer.h" |
19 #include "ipc/ipc_platform_file.h" | 19 #include "ipc/ipc_platform_file.h" |
20 #include "unicode/uscript.h" | 20 #include "unicode/uscript.h" |
21 | 21 |
22 class Hunspell; | 22 class Hunspell; |
23 | 23 |
| 24 namespace chrome { |
| 25 class ChromeContentRendererClient; |
| 26 } |
| 27 |
24 namespace file_util { | 28 namespace file_util { |
25 class MemoryMappedFile; | 29 class MemoryMappedFile; |
26 } | 30 } |
27 | 31 |
28 // TODO(morrita): Needs reorg with SpellCheckProvider. | 32 // TODO(morrita): Needs reorg with SpellCheckProvider. |
29 // See http://crbug.com/73699. | 33 // See http://crbug.com/73699. |
30 class SpellCheck : public RenderProcessObserver { | 34 class SpellCheck : public RenderProcessObserver { |
31 public: | 35 public: |
32 SpellCheck(); | 36 explicit SpellCheck(chrome::ChromeContentRendererClient* renderer_client); |
33 virtual ~SpellCheck(); | 37 virtual ~SpellCheck(); |
34 | 38 |
35 void Init(base::PlatformFile file, | 39 void Init(base::PlatformFile file, |
36 const std::vector<std::string>& custom_words, | 40 const std::vector<std::string>& custom_words, |
37 const std::string& language); | 41 const std::string& language); |
38 | 42 |
39 // SpellCheck a word. | 43 // SpellCheck a word. |
40 // Returns true if spelled correctly, false otherwise. | 44 // Returns true if spelled correctly, false otherwise. |
41 // If the spellchecker failed to initialize, always returns true. | 45 // If the spellchecker failed to initialize, always returns true. |
42 // The |tag| parameter should either be a unique identifier for the document | 46 // The |tag| parameter should either be a unique identifier for the document |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // True if a platform-specific spellchecking engine is being used, | 132 // True if a platform-specific spellchecking engine is being used, |
129 // and False if hunspell is being used. | 133 // and False if hunspell is being used. |
130 bool is_using_platform_spelling_engine_; | 134 bool is_using_platform_spelling_engine_; |
131 | 135 |
132 // This flags whether we have ever been initialized, or have asked the browser | 136 // This flags whether we have ever been initialized, or have asked the browser |
133 // for a dictionary. The value indicates whether we should request a | 137 // for a dictionary. The value indicates whether we should request a |
134 // dictionary from the browser when the render view asks us to check the | 138 // dictionary from the browser when the render view asks us to check the |
135 // spelling of a word. | 139 // spelling of a word. |
136 bool initialized_; | 140 bool initialized_; |
137 | 141 |
| 142 // Reference to the renderer client, for resetting the spellchecker on low-mem |
| 143 // event. Weak reference. |
| 144 chrome::ChromeContentRendererClient* renderer_client_; |
| 145 |
138 DISALLOW_COPY_AND_ASSIGN(SpellCheck); | 146 DISALLOW_COPY_AND_ASSIGN(SpellCheck); |
139 }; | 147 }; |
140 | 148 |
141 #endif // CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_H_ | 149 #endif // CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_H_ |
OLD | NEW |