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

Side by Side Diff: components/spellcheck/renderer/spellcheck.h

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
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 #ifndef COMPONENTS_SPELLCHECK_RENDERER_SPELLCHECK_H_ 5 #ifndef COMPONENTS_SPELLCHECK_RENDERER_SPELLCHECK_H_
6 #define COMPONENTS_SPELLCHECK_RENDERER_SPELLCHECK_H_ 6 #define COMPONENTS_SPELLCHECK_RENDERER_SPELLCHECK_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/files/file.h" 13 #include "base/files/file.h"
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/scoped_vector.h" 16 #include "base/memory/scoped_vector.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/strings/string16.h" 18 #include "base/strings/string16.h"
19 #include "components/spellcheck/renderer/custom_dictionary_engine.h" 19 #include "components/spellcheck/renderer/custom_dictionary_engine.h"
20 #include "components/spellcheck/spellcheck_build_features.h"
20 #include "content/public/renderer/render_thread_observer.h" 21 #include "content/public/renderer/render_thread_observer.h"
21 22
22 struct SpellCheckBDictLanguage; 23 struct SpellCheckBDictLanguage;
23 class SpellcheckLanguage; 24 class SpellcheckLanguage;
24 struct SpellCheckResult; 25 struct SpellCheckResult;
25 26
26 namespace blink { 27 namespace blink {
27 class WebTextCheckingCompletion; 28 class WebTextCheckingCompletion;
28 struct WebTextCheckingResult; 29 struct WebTextCheckingResult;
29 template <typename T> class WebVector; 30 template <typename T> class WebVector;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 83
83 // SpellCheck a paragraph. 84 // SpellCheck a paragraph.
84 // Returns true if |text| is correctly spelled, false otherwise. 85 // Returns true if |text| is correctly spelled, false otherwise.
85 // If the spellchecker failed to initialize, always returns true. 86 // If the spellchecker failed to initialize, always returns true.
86 bool SpellCheckParagraph( 87 bool SpellCheckParagraph(
87 const base::string16& text, 88 const base::string16& text,
88 blink::WebVector<blink::WebTextCheckingResult>* results); 89 blink::WebVector<blink::WebTextCheckingResult>* results);
89 90
90 // Requests to spellcheck the specified text in the background. This function 91 // Requests to spellcheck the specified text in the background. This function
91 // posts a background task and calls SpellCheckParagraph() in the task. 92 // posts a background task and calls SpellCheckParagraph() in the task.
92 #if !defined (USE_BROWSER_SPELLCHECKER) 93 #if !BUILDFLAG(USE_BROWSER_SPELLCHECKER)
93 void RequestTextChecking(const base::string16& text, 94 void RequestTextChecking(const base::string16& text,
94 blink::WebTextCheckingCompletion* completion); 95 blink::WebTextCheckingCompletion* completion);
95 #endif 96 #endif
96 97
97 // Creates a list of WebTextCheckingResult objects (used by WebKit) from a 98 // Creates a list of WebTextCheckingResult objects (used by WebKit) from a
98 // list of SpellCheckResult objects (used by Chrome). This function also 99 // list of SpellCheckResult objects (used by Chrome). This function also
99 // checks misspelled words returned by the Spelling service and changes the 100 // checks misspelled words returned by the Spelling service and changes the
100 // underline colors of contextually-misspelled words. 101 // underline colors of contextually-misspelled words.
101 void CreateTextCheckingResults( 102 void CreateTextCheckingResults(
102 ResultFilter filter, 103 ResultFilter filter,
(...skipping 22 matching lines...) Expand all
125 bool OnControlMessageReceived(const IPC::Message& message) override; 126 bool OnControlMessageReceived(const IPC::Message& message) override;
126 127
127 // Message handlers. 128 // Message handlers.
128 void OnInit(const std::vector<SpellCheckBDictLanguage>& bdict_languages, 129 void OnInit(const std::vector<SpellCheckBDictLanguage>& bdict_languages,
129 const std::set<std::string>& custom_words); 130 const std::set<std::string>& custom_words);
130 void OnCustomDictionaryChanged(const std::set<std::string>& words_added, 131 void OnCustomDictionaryChanged(const std::set<std::string>& words_added,
131 const std::set<std::string>& words_removed); 132 const std::set<std::string>& words_removed);
132 void OnEnableSpellCheck(bool enable); 133 void OnEnableSpellCheck(bool enable);
133 void OnRequestDocumentMarkers(); 134 void OnRequestDocumentMarkers();
134 135
135 #if !defined (USE_BROWSER_SPELLCHECKER) 136 #if !BUILDFLAG(USE_BROWSER_SPELLCHECKER)
136 // Posts delayed spellcheck task and clear it if any. 137 // Posts delayed spellcheck task and clear it if any.
137 // Takes ownership of |request|. 138 // Takes ownership of |request|.
138 void PostDelayedSpellCheckTask(SpellcheckRequest* request); 139 void PostDelayedSpellCheckTask(SpellcheckRequest* request);
139 140
140 // Performs spell checking from the request queue. 141 // Performs spell checking from the request queue.
141 void PerformSpellCheck(SpellcheckRequest* request); 142 void PerformSpellCheck(SpellcheckRequest* request);
142 143
143 // The parameters of a pending background-spellchecking request. When WebKit 144 // The parameters of a pending background-spellchecking request. When WebKit
144 // sends a background-spellchecking request before initializing hunspell, 145 // sends a background-spellchecking request before initializing hunspell,
145 // we save its parameters and start spellchecking after we finish initializing 146 // we save its parameters and start spellchecking after we finish initializing
146 // hunspell. (When WebKit sends two or more requests, we cancel the previous 147 // hunspell. (When WebKit sends two or more requests, we cancel the previous
147 // requests so we do not have to use vectors.) 148 // requests so we do not have to use vectors.)
148 std::unique_ptr<SpellcheckRequest> pending_request_param_; 149 std::unique_ptr<SpellcheckRequest> pending_request_param_;
149 #endif 150 #endif
150 151
151 // A vector of objects used to actually check spelling, one for each enabled 152 // A vector of objects used to actually check spelling, one for each enabled
152 // language. 153 // language.
153 ScopedVector<SpellcheckLanguage> languages_; 154 ScopedVector<SpellcheckLanguage> languages_;
154 155
155 // Custom dictionary spelling engine. 156 // Custom dictionary spelling engine.
156 CustomDictionaryEngine custom_dictionary_; 157 CustomDictionaryEngine custom_dictionary_;
157 158
158 // Remember state for spellchecking. 159 // Remember state for spellchecking.
159 bool spellcheck_enabled_; 160 bool spellcheck_enabled_;
160 161
161 DISALLOW_COPY_AND_ASSIGN(SpellCheck); 162 DISALLOW_COPY_AND_ASSIGN(SpellCheck);
162 }; 163 };
163 164
164 #endif // COMPONENTS_SPELLCHECK_RENDERER_SPELLCHECK_H_ 165 #endif // COMPONENTS_SPELLCHECK_RENDERER_SPELLCHECK_H_
OLDNEW
« no previous file with comments | « components/spellcheck/renderer/hunspell_engine.cc ('k') | components/spellcheck/renderer/spellcheck.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698