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

Side by Side Diff: chrome/renderer/spellchecker/spellcheck.h

Issue 11476005: [Spellcheck] Make sure context menu and actual spellcheck state are in sync. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
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 CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_H_ 5 #ifndef CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_H_
6 #define CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_H_ 6 #define CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // list of SpellCheckResult objects (used by Chrome). This function also 93 // list of SpellCheckResult objects (used by Chrome). This function also
94 // checks misspelled words returned by the Spelling service and changes the 94 // checks misspelled words returned by the Spelling service and changes the
95 // underline colors of contextually-misspelled words. 95 // underline colors of contextually-misspelled words.
96 void CreateTextCheckingResults( 96 void CreateTextCheckingResults(
97 ResultFilter filter, 97 ResultFilter filter,
98 int line_offset, 98 int line_offset,
99 const string16& line_text, 99 const string16& line_text,
100 const std::vector<SpellCheckResult>& spellcheck_results, 100 const std::vector<SpellCheckResult>& spellcheck_results,
101 WebKit::WebVector<WebKit::WebTextCheckingResult>* textcheck_results); 101 WebKit::WebVector<WebKit::WebTextCheckingResult>* textcheck_results);
102 102
103 bool is_spellcheck_enabled() { return spellcheck_enabled_; }
104
103 private: 105 private:
104 friend class SpellCheckTest; 106 friend class SpellCheckTest;
105 FRIEND_TEST_ALL_PREFIXES(SpellCheckTest, GetAutoCorrectionWord_EN_US); 107 FRIEND_TEST_ALL_PREFIXES(SpellCheckTest, GetAutoCorrectionWord_EN_US);
106 FRIEND_TEST_ALL_PREFIXES(SpellCheckTest, 108 FRIEND_TEST_ALL_PREFIXES(SpellCheckTest,
107 RequestSpellCheckMultipleTimesWithoutInitialization); 109 RequestSpellCheckMultipleTimesWithoutInitialization);
108 110
109 class SpellcheckRequest; 111 class SpellcheckRequest;
110 112
111 // RenderProcessObserver implementation: 113 // RenderProcessObserver implementation:
112 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; 114 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE;
113 115
114 // Message handlers. 116 // Message handlers.
115 void OnInit(IPC::PlatformFileForTransit bdict_file, 117 void OnInit(IPC::PlatformFileForTransit bdict_file,
116 const std::vector<std::string>& custom_words, 118 const std::vector<std::string>& custom_words,
117 const std::string& language, 119 const std::string& language,
118 bool auto_spell_correct); 120 bool auto_spell_correct);
119 void OnWordAdded(const std::string& word); 121 void OnWordAdded(const std::string& word);
120 void OnWordRemoved(const std::string& word); 122 void OnWordRemoved(const std::string& word);
121 void OnEnableAutoSpellCorrect(bool enable); 123 void OnEnableAutoSpellCorrect(bool enable);
124 void OnEnableSpellCheck(bool enable);
122 125
123 // If there is no dictionary file, then this requests one from the browser 126 // If there is no dictionary file, then this requests one from the browser
124 // and does not block. In this case it returns true. 127 // and does not block. In this case it returns true.
125 // If there is a dictionary file, but Hunspell has not been loaded, then 128 // If there is a dictionary file, but Hunspell has not been loaded, then
126 // this loads Hunspell. 129 // this loads Hunspell.
127 // If Hunspell is already loaded, this does nothing. In both the latter cases 130 // If Hunspell is already loaded, this does nothing. In both the latter cases
128 // it returns false, meaning that it is OK to continue spellchecking. 131 // it returns false, meaning that it is OK to continue spellchecking.
129 bool InitializeIfNeeded(); 132 bool InitializeIfNeeded();
130 133
131 // When called, relays the request to check the spelling to the proper 134 // When called, relays the request to check the spelling to the proper
(...skipping 26 matching lines...) Expand all
158 // splits text provided by WebKit into words, contractions, or concatenated 161 // splits text provided by WebKit into words, contractions, or concatenated
159 // words. The |contraction_iterator_| splits a concatenated word extracted by 162 // words. The |contraction_iterator_| splits a concatenated word extracted by
160 // |text_iterator_| into word components so we can treat a concatenated word 163 // |text_iterator_| into word components so we can treat a concatenated word
161 // consisting only of correct words as a correct word. 164 // consisting only of correct words as a correct word.
162 SpellcheckWordIterator text_iterator_; 165 SpellcheckWordIterator text_iterator_;
163 SpellcheckWordIterator contraction_iterator_; 166 SpellcheckWordIterator contraction_iterator_;
164 167
165 // Remember state for auto spell correct. 168 // Remember state for auto spell correct.
166 bool auto_spell_correct_turned_on_; 169 bool auto_spell_correct_turned_on_;
167 170
171 // Remember state for spellchecking.
172 bool spellcheck_enabled_;
173
168 // Pointer to a platform-specific spelling engine, if it is in use. This 174 // Pointer to a platform-specific spelling engine, if it is in use. This
169 // should only be set if hunspell is not used. (I.e. on OSX, for now) 175 // should only be set if hunspell is not used. (I.e. on OSX, for now)
170 scoped_ptr<SpellingEngine> platform_spelling_engine_; 176 scoped_ptr<SpellingEngine> platform_spelling_engine_;
171 177
172 // The parameters of a pending background-spellchecking request. When WebKit 178 // The parameters of a pending background-spellchecking request. When WebKit
173 // sends a background-spellchecking request before initializing hunspell, 179 // sends a background-spellchecking request before initializing hunspell,
174 // we save its parameters and start spellchecking after we finish initializing 180 // we save its parameters and start spellchecking after we finish initializing
175 // hunspell. (When WebKit sends two or more requests, we cancel the previous 181 // hunspell. (When WebKit sends two or more requests, we cancel the previous
176 // requests so we do not have to use vectors.) 182 // requests so we do not have to use vectors.)
177 #if !defined (OS_MACOSX) 183 #if !defined (OS_MACOSX)
178 scoped_ptr<SpellcheckRequest> pending_request_param_; 184 scoped_ptr<SpellcheckRequest> pending_request_param_;
179 #endif 185 #endif
180 186
181 DISALLOW_COPY_AND_ASSIGN(SpellCheck); 187 DISALLOW_COPY_AND_ASSIGN(SpellCheck);
182 }; 188 };
183 189
184 #endif // CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_H_ 190 #endif // CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698