| 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_SPELLCHECK_H_ | 5 #ifndef CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_H_ |
| 6 #define CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_H_ | 6 #define CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 namespace WebKit { | 30 namespace WebKit { |
| 31 class WebTextCheckingCompletion; | 31 class WebTextCheckingCompletion; |
| 32 struct WebTextCheckingResult; | 32 struct WebTextCheckingResult; |
| 33 } | 33 } |
| 34 | 34 |
| 35 // TODO(morrita): Needs reorg with SpellCheckProvider. | 35 // TODO(morrita): Needs reorg with SpellCheckProvider. |
| 36 // See http://crbug.com/73699. | 36 // See http://crbug.com/73699. |
| 37 class SpellCheck : public content::RenderProcessObserver, | 37 class SpellCheck : public content::RenderProcessObserver, |
| 38 public base::SupportsWeakPtr<SpellCheck> { | 38 public base::SupportsWeakPtr<SpellCheck> { |
| 39 public: | 39 public: |
| 40 enum ResultFilter { |
| 41 DO_NOT_MODIFY = 1, // Do not modify results. |
| 42 USE_NATIVE_CHECKER, // Use native checker to double-check. |
| 43 }; |
| 44 |
| 40 SpellCheck(); | 45 SpellCheck(); |
| 41 virtual ~SpellCheck(); | 46 virtual ~SpellCheck(); |
| 42 | 47 |
| 43 void Init(base::PlatformFile file, | 48 void Init(base::PlatformFile file, |
| 44 const std::vector<std::string>& custom_words, | 49 const std::vector<std::string>& custom_words, |
| 45 const std::string& language); | 50 const std::string& language); |
| 46 | 51 |
| 47 // SpellCheck a word. | 52 // SpellCheck a word. |
| 48 // Returns true if spelled correctly, false otherwise. | 53 // Returns true if spelled correctly, false otherwise. |
| 49 // If the spellchecker failed to initialize, always returns true. | 54 // If the spellchecker failed to initialize, always returns true. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 void RequestTextChecking(const string16& text, | 87 void RequestTextChecking(const string16& text, |
| 83 int offset, | 88 int offset, |
| 84 WebKit::WebTextCheckingCompletion* completion); | 89 WebKit::WebTextCheckingCompletion* completion); |
| 85 #endif | 90 #endif |
| 86 | 91 |
| 87 // Creates a list of WebTextCheckingResult objects (used by WebKit) from a | 92 // Creates a list of WebTextCheckingResult objects (used by WebKit) from a |
| 88 // list of SpellCheckResult objects (used by Chrome). This function also | 93 // list of SpellCheckResult objects (used by Chrome). This function also |
| 89 // checks misspelled words returned by the Spelling service and changes the | 94 // checks misspelled words returned by the Spelling service and changes the |
| 90 // underline colors of contextually-misspelled words. | 95 // underline colors of contextually-misspelled words. |
| 91 void CreateTextCheckingResults( | 96 void CreateTextCheckingResults( |
| 97 ResultFilter filter, |
| 92 int line_offset, | 98 int line_offset, |
| 93 const string16& line_text, | 99 const string16& line_text, |
| 94 const std::vector<SpellCheckResult>& spellcheck_results, | 100 const std::vector<SpellCheckResult>& spellcheck_results, |
| 95 WebKit::WebVector<WebKit::WebTextCheckingResult>* textcheck_results); | 101 WebKit::WebVector<WebKit::WebTextCheckingResult>* textcheck_results); |
| 96 | 102 |
| 97 private: | 103 private: |
| 104 friend class SpellCheckTest; |
| 98 FRIEND_TEST_ALL_PREFIXES(SpellCheckTest, GetAutoCorrectionWord_EN_US); | 105 FRIEND_TEST_ALL_PREFIXES(SpellCheckTest, GetAutoCorrectionWord_EN_US); |
| 99 FRIEND_TEST_ALL_PREFIXES(SpellCheckTest, | 106 FRIEND_TEST_ALL_PREFIXES(SpellCheckTest, |
| 100 RequestSpellCheckMultipleTimesWithoutInitialization); | 107 RequestSpellCheckMultipleTimesWithoutInitialization); |
| 101 | 108 |
| 102 class SpellcheckRequest; | 109 class SpellcheckRequest; |
| 103 | 110 |
| 104 // RenderProcessObserver implementation: | 111 // RenderProcessObserver implementation: |
| 105 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; | 112 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; |
| 106 | 113 |
| 107 // Message handlers. | 114 // Message handlers. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // hunspell. (When WebKit sends two or more requests, we cancel the previous | 174 // hunspell. (When WebKit sends two or more requests, we cancel the previous |
| 168 // requests so we do not have to use vectors.) | 175 // requests so we do not have to use vectors.) |
| 169 #if !defined (OS_MACOSX) | 176 #if !defined (OS_MACOSX) |
| 170 scoped_ptr<SpellcheckRequest> pending_request_param_; | 177 scoped_ptr<SpellcheckRequest> pending_request_param_; |
| 171 #endif | 178 #endif |
| 172 | 179 |
| 173 DISALLOW_COPY_AND_ASSIGN(SpellCheck); | 180 DISALLOW_COPY_AND_ASSIGN(SpellCheck); |
| 174 }; | 181 }; |
| 175 | 182 |
| 176 #endif // CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_H_ | 183 #endif // CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_H_ |
| OLD | NEW |