| 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 // Integration with OS X built-in spellchecker. | 5 // Integration with OS X built-in spellchecker. |
| 6 | 6 |
| 7 #include "chrome/browser/spellchecker/spellcheck_platform.h" | 7 #include "chrome/browser/spellchecker/spellcheck_platform.h" |
| 8 | 8 |
| 9 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/mac/foundation_util.h" | 14 #include "base/mac/foundation_util.h" |
| 15 #include "base/strings/sys_string_conversions.h" | 15 #include "base/strings/sys_string_conversions.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "chrome/common/spellcheck_common.h" | 17 #include "components/spellcheck/common/spellcheck_common.h" |
| 18 #include "chrome/common/spellcheck_result.h" | 18 #include "components/spellcheck/common/spellcheck_result.h" |
| 19 #include "content/public/browser/browser_message_filter.h" | 19 #include "content/public/browser/browser_message_filter.h" |
| 20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 21 | 21 |
| 22 using base::TimeTicks; | 22 using base::TimeTicks; |
| 23 using content::BrowserMessageFilter; | 23 using content::BrowserMessageFilter; |
| 24 using content::BrowserThread; | 24 using content::BrowserThread; |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 // The number of characters in the first part of the language code. | 27 // The number of characters in the first part of the language code. |
| 28 const unsigned int kShortLanguageCodeSize = 2; | 28 const unsigned int kShortLanguageCodeSize = 2; |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 NSSpellChecker* checker = SharedSpellChecker(); | 202 NSSpellChecker* checker = SharedSpellChecker(); |
| 203 NSString* language = [checker language]; | 203 NSString* language = [checker language]; |
| 204 NSArray* guesses = | 204 NSArray* guesses = |
| 205 [checker guessesForWordRange:NSMakeRange(0, [ns_wrong_word length]) | 205 [checker guessesForWordRange:NSMakeRange(0, [ns_wrong_word length]) |
| 206 inString:ns_wrong_word | 206 inString:ns_wrong_word |
| 207 language:language | 207 language:language |
| 208 inSpellDocumentWithTag:last_seen_tag_]; | 208 inSpellDocumentWithTag:last_seen_tag_]; |
| 209 int i = 0; | 209 int i = 0; |
| 210 for (NSString* guess in guesses) { | 210 for (NSString* guess in guesses) { |
| 211 optional_suggestions->push_back(base::SysNSStringToUTF16(guess)); | 211 optional_suggestions->push_back(base::SysNSStringToUTF16(guess)); |
| 212 if (++i >= chrome::spellcheck_common::kMaxSuggestions) | 212 if (++i >= spellcheck::kMaxSuggestions) |
| 213 break; | 213 break; |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 | 216 |
| 217 void AddWord(const base::string16& word) { | 217 void AddWord(const base::string16& word) { |
| 218 NSString* word_to_add = base::SysUTF16ToNSString(word); | 218 NSString* word_to_add = base::SysUTF16ToNSString(word); |
| 219 [SharedSpellChecker() learnWord:word_to_add]; | 219 [SharedSpellChecker() learnWord:word_to_add]; |
| 220 } | 220 } |
| 221 | 221 |
| 222 void RemoveWord(const base::string16& word) { | 222 void RemoveWord(const base::string16& word) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 | 300 |
| 301 ScopedEnglishLanguageForTest::ScopedEnglishLanguageForTest() | 301 ScopedEnglishLanguageForTest::ScopedEnglishLanguageForTest() |
| 302 : state_(new SpellcheckerStateInternal) { | 302 : state_(new SpellcheckerStateInternal) { |
| 303 } | 303 } |
| 304 | 304 |
| 305 ScopedEnglishLanguageForTest::~ScopedEnglishLanguageForTest() { | 305 ScopedEnglishLanguageForTest::~ScopedEnglishLanguageForTest() { |
| 306 delete state_; | 306 delete state_; |
| 307 } | 307 } |
| 308 | 308 |
| 309 } // namespace spellcheck_platform | 309 } // namespace spellcheck_platform |
| OLD | NEW |