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

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

Issue 1233983004: Remove base/mac/scoped_nsexception_enabler.h. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 5 months 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) 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/mac/scoped_nsexception_enabler.h"
16 #include "base/strings/sys_string_conversions.h" 15 #include "base/strings/sys_string_conversions.h"
17 #include "base/time/time.h" 16 #include "base/time/time.h"
18 #include "chrome/common/spellcheck_common.h" 17 #include "chrome/common/spellcheck_common.h"
19 #include "chrome/common/spellcheck_messages.h" 18 #include "chrome/common/spellcheck_messages.h"
20 #include "chrome/common/spellcheck_result.h" 19 #include "chrome/common/spellcheck_result.h"
21 #include "content/public/browser/browser_message_filter.h" 20 #include "content/public/browser/browser_message_filter.h"
22 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
23 22
24 using base::TimeTicks; 23 using base::TimeTicks;
25 using content::BrowserMessageFilter; 24 using content::BrowserMessageFilter;
26 using content::BrowserThread; 25 using content::BrowserThread;
27 26
28 namespace { 27 namespace {
29 // The number of characters in the first part of the language code. 28 // The number of characters in the first part of the language code.
30 const unsigned int kShortLanguageCodeSize = 2; 29 const unsigned int kShortLanguageCodeSize = 2;
31 30
32 // +[NSSpellChecker sharedSpellChecker] can throw exceptions depending 31 // +[NSSpellChecker sharedSpellChecker] can throw exceptions depending
33 // on the state of the pasteboard, or possibly as a result of 32 // on the state of the pasteboard, or possibly as a result of
34 // third-party code (when setting up services entries). The following 33 // third-party code (when setting up services entries). The following
35 // receives nil if an exception is thrown, in which case 34 // receives nil if an exception is thrown, in which case
36 // spell-checking will not work, but it also will not crash the 35 // spell-checking will not work, but it also will not crash the
37 // browser. 36 // browser.
38 NSSpellChecker* SharedSpellChecker() { 37 NSSpellChecker* SharedSpellChecker() {
39 return base::mac::ObjCCastStrict<NSSpellChecker>( 38 @try {
40 base::mac::RunBlockIgnoringExceptions(^{ 39 return [NSSpellChecker sharedSpellChecker];
41 return [NSSpellChecker sharedSpellChecker]; 40 } @catch (id exception) {
42 })); 41 return nil;
42 }
43 } 43 }
44 44
45 // A private utility function to convert hunspell language codes to OS X 45 // A private utility function to convert hunspell language codes to OS X
46 // language codes. 46 // language codes.
47 NSString* ConvertLanguageCodeToMac(const std::string& hunspell_lang_code) { 47 NSString* ConvertLanguageCodeToMac(const std::string& hunspell_lang_code) {
48 NSString* whole_code = base::SysUTF8ToNSString(hunspell_lang_code); 48 NSString* whole_code = base::SysUTF8ToNSString(hunspell_lang_code);
49 49
50 if ([whole_code length] > kShortLanguageCodeSize) { 50 if ([whole_code length] > kShortLanguageCodeSize) {
51 NSString* lang_code = [whole_code 51 NSString* lang_code = [whole_code
52 substringToIndex:kShortLanguageCodeSize]; 52 substringToIndex:kShortLanguageCodeSize];
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 297
298 ScopedEnglishLanguageForTest::ScopedEnglishLanguageForTest() 298 ScopedEnglishLanguageForTest::ScopedEnglishLanguageForTest()
299 : state_(new SpellcheckerStateInternal) { 299 : state_(new SpellcheckerStateInternal) {
300 } 300 }
301 301
302 ScopedEnglishLanguageForTest::~ScopedEnglishLanguageForTest() { 302 ScopedEnglishLanguageForTest::~ScopedEnglishLanguageForTest() {
303 delete state_; 303 delete state_;
304 } 304 }
305 305
306 } // namespace spellcheck_platform 306 } // namespace spellcheck_platform
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698