| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // This file defines the interface that any platform-specific spellchecker | 5 // This file defines the interface that any platform-specific spellchecker |
| 6 // needs to implement in order to be used by the browser. | 6 // needs to implement in order to be used by the browser. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_SPELLCHECKER_PLATFORM_ENGINE_H_ | 8 #ifndef CHROME_BROWSER_SPELLCHECKER_PLATFORM_ENGINE_H_ |
| 9 #define CHROME_BROWSER_SPELLCHECKER_PLATFORM_ENGINE_H_ | 9 #define CHROME_BROWSER_SPELLCHECKER_PLATFORM_ENGINE_H_ |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "chrome/browser/spellchecker_common.h" | 14 #include "chrome/browser/spellchecker_common.h" |
| 15 | 15 |
| 16 namespace SpellCheckerPlatform { | 16 namespace SpellCheckerPlatform { |
| 17 // Get the languages supported by the platform spellchecker and store them in | 17 // Get the languages supported by the platform spellchecker and store them in |
| 18 // |spellcheck_languages|. Note that they must be converted to | 18 // |spellcheck_languages|. Note that they must be converted to |
| 19 // Chromium style codes (en-US not en_US). See spellchecker.cc for a full list. | 19 // Chromium style codes (en-US not en_US). See spellchecker.cc for a full list. |
| 20 void GetAvailableLanguages(std::vector<std::string>* spellcheck_languages); | 20 void GetAvailableLanguages(std::vector<std::string>* spellcheck_languages); |
| 21 | 21 |
| 22 // Returns true if there is a platform-specific spellchecker that can be used. | 22 // Returns true if there is a platform-specific spellchecker that can be used. |
| 23 bool SpellCheckerAvailable(); | 23 bool SpellCheckerAvailable(); |
| 24 | 24 |
| 25 // Returns true if the platform spellchecker has a spelling panel. | 25 // Returns true if the platform spellchecker has a spelling panel. |
| 26 bool SpellCheckerProvidesPanel(); | 26 bool SpellCheckerProvidesPanel(); |
| 27 | 27 |
| 28 // Returns true if the platform spellchecker panel is visible. | 28 // Returns true if the platform spellchecker panel is visible. |
| 29 bool SpellCheckerPanelVisible(); | 29 bool SpellingPanelVisible(); |
| 30 |
| 31 // Shows the spelling panel if |show| is true and hides it if it is not. |
| 32 void ShowSpellingPanel(bool show); |
| 33 |
| 34 // Changes the word show in the spelling panel to be |word|. Note that the |
| 35 // spelling panel need not be displayed for this to work. |
| 36 void UpdateSpellingPanelWithMisspelledWord(const std::wstring& word); |
| 30 | 37 |
| 31 // Do any initialization needed for spellchecker. | 38 // Do any initialization needed for spellchecker. |
| 32 void Init(); | 39 void Init(); |
| 33 // TODO(pwicks): should we add a companion to this, TearDown or something? | 40 // TODO(pwicks): should we add a companion to this, TearDown or something? |
| 34 | 41 |
| 35 // Translates the codes used by chrome to the language codes used by os x | 42 // Translates the codes used by chrome to the language codes used by os x |
| 36 // and checks the given language agains the languages that the current system | 43 // and checks the given language agains the languages that the current system |
| 37 // supports. If the platform-specific spellchecker supports the language, | 44 // supports. If the platform-specific spellchecker supports the language, |
| 38 // then returns true, otherwise false. | 45 // then returns true, otherwise false. |
| 39 bool PlatformSupportsLanguage(const std::string& current_language); | 46 bool PlatformSupportsLanguage(const std::string& current_language); |
| 40 | 47 |
| 41 // Sets the language for the platform-specific spellchecker. | 48 // Sets the language for the platform-specific spellchecker. |
| 42 void SetLanguage(const std::string& lang_to_set); | 49 void SetLanguage(const std::string& lang_to_set); |
| 43 | 50 |
| 44 // Checks the spelling of the given string, using the platform-specific | 51 // Checks the spelling of the given string, using the platform-specific |
| 45 // spellchecker. Returns true if the word is spelled correctly. | 52 // spellchecker. Returns true if the word is spelled correctly. |
| 46 bool CheckSpelling(const std::string& word_to_check); | 53 bool CheckSpelling(const std::string& word_to_check, int tag); |
| 47 | 54 |
| 48 // Fills the given vector |optional_suggestions| with a number (up to | 55 // Fills the given vector |optional_suggestions| with a number (up to |
| 49 // kMaxSuggestions, which is defined in spellchecker_common.h) of suggestions | 56 // kMaxSuggestions, which is defined in spellchecker_common.h) of suggestions |
| 50 // for the string |wrong_word|. | 57 // for the string |wrong_word|. |
| 51 void FillSuggestionList(const std::string& wrong_word, | 58 void FillSuggestionList(const std::string& wrong_word, |
| 52 std::vector<std::wstring>* optional_suggestions); | 59 std::vector<std::wstring>* optional_suggestions); |
| 53 | 60 |
| 54 // Adds the given word to the platform dictionary. | 61 // Adds the given word to the platform dictionary. |
| 55 void AddWord(const std::wstring& word); | 62 void AddWord(const std::wstring& word); |
| 56 | 63 |
| 57 // Remove a given word from the platform dictionary. | 64 // Remove a given word from the platform dictionary. |
| 58 void RemoveWord(const std::wstring& word); | 65 void RemoveWord(const std::wstring& word); |
| 66 |
| 67 // Gets a unique tag to identify a document. Used in ignoring words. |
| 68 int GetDocumentTag(); |
| 69 |
| 70 // Tells the platform spellchecker to ignore a word. This doesn't take a tag |
| 71 // because in most of the situations in which it is called, the only way to know |
| 72 // the tag for sure is to ask the renderer, which would mean blocking in the |
| 73 // browser, so (on the mac, anyway) we remember the most recent tag and use |
| 74 // it, since it should always be from the same document. |
| 75 void IgnoreWord(const std::string& word); |
| 76 |
| 77 // Tells the platform spellchecker that a docuemnt associated with a tag has |
| 78 // closed. Generally, this means that any ignored words associated with that |
| 79 // document can now be forgotten. |
| 80 void CloseDocumentWithTag(int tag); |
| 59 } | 81 } |
| 60 | 82 |
| 61 #endif // CHROME_BROWSER_SPELLCHECKER_PLATFORM_ENGINE_H_ | 83 #endif // CHROME_BROWSER_SPELLCHECKER_PLATFORM_ENGINE_H_ |
| OLD | NEW |