Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: chrome/browser/spellchecker/spellcheck_platform_mac.mm

Issue 8890022: Remove Hunspell on OS X - step 2 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix namespace name Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // This file implements the interface defined in spellchecker_platform_engine.h 5 // Integration with OS X native spellchecker.
6 // for the OS X platform.
7 6
8 #include "chrome/browser/spellchecker/spellchecker_platform_engine.h" 7 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h"
9 8
10 #import <Cocoa/Cocoa.h> 9 #import <Cocoa/Cocoa.h>
11 10
12 #include "base/logging.h" 11 #include "base/logging.h"
13 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
14 #include "base/sys_string_conversions.h" 13 #include "base/sys_string_conversions.h"
15 #include "base/task.h" 14 #include "base/task.h"
16 #include "base/time.h" 15 #include "base/time.h"
17 #include "chrome/common/spellcheck_common.h" 16 #include "chrome/common/spellcheck_common.h"
18 #include "chrome/common/spellcheck_messages.h" 17 #include "chrome/common/spellcheck_messages.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 [lang_code characterAtIndex:kShortLanguageCodeSize] == '_') { 141 [lang_code characterAtIndex:kShortLanguageCodeSize] == '_') {
143 return base::SysNSStringToUTF8([NSString stringWithFormat:@"%@-%@", 142 return base::SysNSStringToUTF8([NSString stringWithFormat:@"%@-%@",
144 [lang_code substringToIndex:kShortLanguageCodeSize], 143 [lang_code substringToIndex:kShortLanguageCodeSize],
145 [lang_code substringFromIndex:(kShortLanguageCodeSize + 1)]]); 144 [lang_code substringFromIndex:(kShortLanguageCodeSize + 1)]]);
146 } 145 }
147 return base::SysNSStringToUTF8(lang_code); 146 return base::SysNSStringToUTF8(lang_code);
148 } 147 }
149 148
150 } // namespace 149 } // namespace
151 150
152 namespace SpellCheckerPlatform { 151 namespace spellcheck_mac {
153 152
154 void GetAvailableLanguages(std::vector<std::string>* spellcheck_languages) { 153 void GetAvailableLanguages(std::vector<std::string>* spellcheck_languages) {
155 NSArray* availableLanguages = [[NSSpellChecker sharedSpellChecker] 154 NSArray* availableLanguages = [[NSSpellChecker sharedSpellChecker]
156 availableLanguages]; 155 availableLanguages];
157 for (NSString* lang_code in availableLanguages) { 156 for (NSString* lang_code in availableLanguages) {
158 spellcheck_languages->push_back( 157 spellcheck_languages->push_back(
159 ConvertLanguageCodeFromMac(lang_code)); 158 ConvertLanguageCodeFromMac(lang_code));
160 } 159 }
161 } 160 }
162 161
(...skipping 30 matching lines...) Expand all
193 192
194 void UpdateSpellingPanelWithMisspelledWord(const string16& word) { 193 void UpdateSpellingPanelWithMisspelledWord(const string16& word) {
195 NSString * word_to_display = base::SysUTF16ToNSString(word); 194 NSString * word_to_display = base::SysUTF16ToNSString(word);
196 [[NSSpellChecker sharedSpellChecker] 195 [[NSSpellChecker sharedSpellChecker]
197 performSelectorOnMainThread: 196 performSelectorOnMainThread:
198 @selector(updateSpellingPanelWithMisspelledWord:) 197 @selector(updateSpellingPanelWithMisspelledWord:)
199 withObject:word_to_display 198 withObject:word_to_display
200 waitUntilDone:YES]; 199 waitUntilDone:YES];
201 } 200 }
202 201
203 void Init() {
204 }
205
206 bool PlatformSupportsLanguage(const std::string& current_language) { 202 bool PlatformSupportsLanguage(const std::string& current_language) {
207 // First, convert the language to an OS X language code. 203 // First, convert the language to an OS X language code.
208 NSString* mac_lang_code = ConvertLanguageCodeToMac(current_language); 204 NSString* mac_lang_code = ConvertLanguageCodeToMac(current_language);
209 205
210 // Then grab the languages available. 206 // Then grab the languages available.
211 NSArray* availableLanguages; 207 NSArray* availableLanguages;
212 availableLanguages = [[NSSpellChecker sharedSpellChecker] 208 availableLanguages = [[NSSpellChecker sharedSpellChecker]
213 availableLanguages]; 209 availableLanguages];
214 210
215 // Return true if the given language is supported by OS X. 211 // Return true if the given language is supported by OS X.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 void RequestTextCheck(int route_id, 286 void RequestTextCheck(int route_id,
291 int identifier, 287 int identifier,
292 int document_tag, 288 int document_tag,
293 const string16& text, BrowserMessageFilter* destination) { 289 const string16& text, BrowserMessageFilter* destination) {
294 BrowserThread::PostTask( 290 BrowserThread::PostTask(
295 BrowserThread::FILE, FROM_HERE, 291 BrowserThread::FILE, FROM_HERE,
296 new TextCheckingTask( 292 new TextCheckingTask(
297 destination, route_id, identifier, text, document_tag)); 293 destination, route_id, identifier, text, document_tag));
298 } 294 }
299 295
300 } // namespace SpellCheckerPlatform 296 } // namespace spellcheck_mac
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698