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

Side by Side Diff: components/spellcheck/renderer/hunspell_engine.cc

Issue 2495193003: Convert spellcheck to a buildflag header. (Closed)
Patch Set: Comment Created 4 years, 1 month 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
« no previous file with comments | « components/spellcheck/renderer/BUILD.gn ('k') | components/spellcheck/renderer/spellcheck.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "components/spellcheck/renderer/hunspell_engine.h" 5 #include "components/spellcheck/renderer/hunspell_engine.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <iterator> 9 #include <iterator>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/files/memory_mapped_file.h" 12 #include "base/files/memory_mapped_file.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "components/spellcheck/common/spellcheck_common.h" 14 #include "components/spellcheck/common/spellcheck_common.h"
15 #include "components/spellcheck/common/spellcheck_messages.h" 15 #include "components/spellcheck/common/spellcheck_messages.h"
16 #include "components/spellcheck/spellcheck_build_features.h"
16 #include "content/public/renderer/render_thread.h" 17 #include "content/public/renderer/render_thread.h"
17 #include "third_party/hunspell/src/hunspell/hunspell.hxx" 18 #include "third_party/hunspell/src/hunspell/hunspell.hxx"
18 19
19 using content::RenderThread; 20 using content::RenderThread;
20 21
21 namespace { 22 namespace {
22 // Maximum length of words we actually check. 23 // Maximum length of words we actually check.
23 // 64 is the observed limits for OSX system checker. 24 // 64 is the observed limits for OSX system checker.
24 const size_t kMaxCheckedLen = 64; 25 const size_t kMaxCheckedLen = 64;
25 26
26 // Maximum length of words we provide suggestions for. 27 // Maximum length of words we provide suggestions for.
27 // 24 is the observed limits for OSX system checker. 28 // 24 is the observed limits for OSX system checker.
28 const size_t kMaxSuggestLen = 24; 29 const size_t kMaxSuggestLen = 24;
29 30
30 static_assert(kMaxCheckedLen <= size_t(MAXWORDLEN), 31 static_assert(kMaxCheckedLen <= size_t(MAXWORDLEN),
31 "MaxCheckedLen too long"); 32 "MaxCheckedLen too long");
32 static_assert(kMaxSuggestLen <= kMaxCheckedLen, 33 static_assert(kMaxSuggestLen <= kMaxCheckedLen,
33 "MaxSuggestLen too long"); 34 "MaxSuggestLen too long");
34 } // namespace 35 } // namespace
35 36
36 #if !defined(USE_BROWSER_SPELLCHECKER) 37 #if !BUILDFLAG(USE_BROWSER_SPELLCHECKER)
37 SpellingEngine* CreateNativeSpellingEngine() { 38 SpellingEngine* CreateNativeSpellingEngine() {
38 return new HunspellEngine(); 39 return new HunspellEngine();
39 } 40 }
40 #endif 41 #endif
41 42
42 HunspellEngine::HunspellEngine() 43 HunspellEngine::HunspellEngine()
43 : hunspell_enabled_(false), 44 : hunspell_enabled_(false),
44 initialized_(false), 45 initialized_(false),
45 dictionary_requested_(false) { 46 dictionary_requested_(false) {
46 // Wait till we check the first word before doing any initializing. 47 // Wait till we check the first word before doing any initializing.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // Don't initialize if hunspell is disabled. 132 // Don't initialize if hunspell is disabled.
132 if (file_.IsValid()) 133 if (file_.IsValid())
133 InitializeHunspell(); 134 InitializeHunspell();
134 135
135 return !initialized_; 136 return !initialized_;
136 } 137 }
137 138
138 bool HunspellEngine::IsEnabled() { 139 bool HunspellEngine::IsEnabled() {
139 return hunspell_enabled_; 140 return hunspell_enabled_;
140 } 141 }
OLDNEW
« no previous file with comments | « components/spellcheck/renderer/BUILD.gn ('k') | components/spellcheck/renderer/spellcheck.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698