| Index: chrome/browser/spellchecker_mac.mm
|
| ===================================================================
|
| --- chrome/browser/spellchecker_mac.mm (revision 25643)
|
| +++ chrome/browser/spellchecker_mac.mm (working copy)
|
| @@ -92,11 +92,29 @@
|
| return true;
|
| }
|
|
|
| -bool SpellCheckerPanelVisible() {
|
| - return [[[NSSpellChecker sharedSpellChecker] spellingPanel]
|
| - isVisible] ? true : false;
|
| +bool SpellingPanelVisible() {
|
| + // This should only be called from the main thread.
|
| + return [[[NSSpellChecker sharedSpellChecker] spellingPanel] isVisible];
|
| }
|
|
|
| +void ShowSpellingPanel(bool show) {
|
| + if (show) {
|
| + [[[NSSpellChecker sharedSpellChecker] spellingPanel]
|
| + performSelectorOnMainThread:@selector(makeKeyAndOrderFront:) withObject:nil
|
| + waitUntilDone:YES];
|
| + } else {
|
| + [[[NSSpellChecker sharedSpellChecker] spellingPanel]
|
| + performSelectorOnMainThread:@selector(close) withObject:nil
|
| + waitUntilDone:YES];
|
| + }
|
| +}
|
| +
|
| +void UpdateSpellingPanelWithMisspelledWord(const std::wstring& word) {
|
| + NSString * word_to_display = base::SysWideToNSString(word);
|
| + [[NSSpellChecker sharedSpellChecker]
|
| + updateSpellingPanelWithMisspelledWord:word_to_display];
|
| +}
|
| +
|
| void Init() {
|
| // This call must be made before the call to
|
| // [NSSpellchecker sharedSpellChecker] or it will return nil.
|
| @@ -121,7 +139,11 @@
|
| [[NSSpellChecker sharedSpellChecker] setLanguage:NS_lang_to_set];
|
| }
|
|
|
| -bool CheckSpelling(const std::string& word_to_check) {
|
| +static int last_seen_tag_;
|
| +
|
| +bool CheckSpelling(const std::string& word_to_check, int tag) {
|
| + last_seen_tag_ = tag;
|
| +
|
| // [[NSSpellChecker sharedSpellChecker] checkSpellingOfString] returns an
|
| // NSRange that we can look at to determine if a word is misspelled.
|
| NSRange spell_range = {0,0};
|
| @@ -130,7 +152,9 @@
|
| NSString* NS_word_to_check = base::SysUTF8ToNSString(word_to_check);
|
| // Check the spelling, starting at the beginning of the word.
|
| spell_range = [[NSSpellChecker sharedSpellChecker]
|
| - checkSpellingOfString:NS_word_to_check startingAt:0];
|
| + checkSpellingOfString:NS_word_to_check startingAt:0
|
| + language:nil wrap:NO inSpellDocumentWithTag:tag
|
| + wordCount:NULL];
|
|
|
| // If the length of the misspelled word == 0,
|
| // then there is no misspelled word.
|
| @@ -165,5 +189,20 @@
|
| NSString *word_to_remove = base::SysWideToNSString(word);
|
| [[NSSpellChecker sharedSpellChecker] unlearnWord:word_to_remove];
|
| }
|
| +
|
| +int GetDocumentTag() {
|
| + NSInteger doc_tag = [NSSpellChecker uniqueSpellDocumentTag];
|
| + return static_cast<int>(doc_tag);
|
| +}
|
| +
|
| +void IgnoreWord(const std::string& word) {
|
| + [[NSSpellChecker sharedSpellChecker] ignoreWord:base::SysUTF8ToNSString(word)
|
| + inSpellDocumentWithTag:last_seen_tag_];
|
| +}
|
| +
|
| +void CloseDocumentWithTag(int tag) {
|
| + [[NSSpellChecker sharedSpellChecker]
|
| + closeSpellDocumentWithTag:static_cast<NSInteger>(tag)];
|
| +}
|
| } // namespace SpellCheckerPlatform
|
|
|
|
|