| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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_BROWSER_SPELLCHECKER_H_ | 5 #ifndef CHROME_BROWSER_SPELLCHECKER_H_ |
| 6 #define CHROME_BROWSER_SPELLCHECKER_H_ | 6 #define CHROME_BROWSER_SPELLCHECKER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 bool IsValidContraction(const string16& word); | 140 bool IsValidContraction(const string16& word); |
| 141 | 141 |
| 142 // Return the file name of the dictionary, including the path and the version | 142 // Return the file name of the dictionary, including the path and the version |
| 143 // numbers. | 143 // numbers. |
| 144 FilePath GetVersionedFileName(const std::string& language, | 144 FilePath GetVersionedFileName(const std::string& language, |
| 145 const FilePath& dict_dir); | 145 const FilePath& dict_dir); |
| 146 | 146 |
| 147 static std::string GetCorrespondingSpellCheckLanguage( | 147 static std::string GetCorrespondingSpellCheckLanguage( |
| 148 const std::string& language); | 148 const std::string& language); |
| 149 | 149 |
| 150 // Path to the spellchecker file. | 150 // Start the dictionary download process in the file thread. On completion, |
| 151 FilePath bdict_file_name_; | 151 // this function calls on set_file_is_downloading() in the IO thread to notify |
| 152 // that download has completed. This function has to be called in the IO |
| 153 // thread. |
| 154 void StartDictionaryDownloadInFileThread(const FilePath& file_name); |
| 155 |
| 156 // The given path to the directory whether SpellChecker first tries to |
| 157 // download the spellcheck bdic dictionary file. |
| 158 FilePath given_dictionary_directory_; |
| 152 | 159 |
| 153 // Path to the custom dictionary file. | 160 // Path to the custom dictionary file. |
| 154 FilePath custom_dictionary_file_name_; | 161 FilePath custom_dictionary_file_name_; |
| 155 | 162 |
| 156 // We memory-map the BDict file. | 163 // We memory-map the BDict file. |
| 157 scoped_ptr<file_util::MemoryMappedFile> bdict_file_; | 164 scoped_ptr<file_util::MemoryMappedFile> bdict_file_; |
| 158 | 165 |
| 159 // The hunspell dictionary in use. | 166 // The hunspell dictionary in use. |
| 160 scoped_ptr<Hunspell> hunspell_; | 167 scoped_ptr<Hunspell> hunspell_; |
| 161 | 168 |
| 162 // Represents character attributes used for filtering out characters which | 169 // Represents character attributes used for filtering out characters which |
| 163 // are not supported by this SpellChecker object. | 170 // are not supported by this SpellChecker object. |
| 164 SpellcheckCharAttribute character_attributes_; | 171 SpellcheckCharAttribute character_attributes_; |
| 165 | 172 |
| 166 // Flag indicating whether we've tried to initialize. If we've already | 173 // Flag indicating whether we've tried to initialize. If we've already |
| 167 // attempted initialiation, we won't retry to avoid failure loops. | 174 // attempted initialiation, we won't retry to avoid failure loops. |
| 168 bool tried_to_init_; | 175 bool tried_to_init_; |
| 169 | 176 |
| 177 // The language that this spellchecker works in. |
| 178 std::string language_; |
| 179 |
| 170 #ifndef NDEBUG | 180 #ifndef NDEBUG |
| 171 // This object must only be used on the same thread. However, it is normally | 181 // This object must only be used on the same thread. However, it is normally |
| 172 // created on the UI thread. This checks calls to SpellCheckWord and the | 182 // created on the UI thread. This checks calls to SpellCheckWord and the |
| 173 // destructor to make sure we're only ever running on the same thread. | 183 // destructor to make sure we're only ever running on the same thread. |
| 174 // | 184 // |
| 175 // This will be NULL if it is not initialized yet (not initialized in the | 185 // This will be NULL if it is not initialized yet (not initialized in the |
| 176 // constructor since that's on a different thread. | 186 // constructor since that's on a different thread. |
| 177 MessageLoop* worker_loop_; | 187 MessageLoop* worker_loop_; |
| 178 #endif | 188 #endif |
| 179 | 189 |
| 180 // Flag indicating whether we've tried to download dictionary files. If we've | 190 // Flag indicating whether we tried to download the dictionary file. |
| 181 // already attempted download, we won't retry to avoid failure loops. | 191 bool tried_to_download_dictionary_file_; |
| 182 bool tried_to_download_; | |
| 183 | 192 |
| 184 // File Thread Message Loop. | 193 // File Thread Message Loop. |
| 185 MessageLoop* file_loop_; | 194 MessageLoop* file_loop_; |
| 186 | 195 |
| 187 // UI Thread Message Loop - this will be used as a proxy to access io loop. | 196 // UI Thread Message Loop - this will be used as a proxy to access io loop. |
| 188 MessageLoop* ui_loop_; | 197 MessageLoop* ui_loop_; |
| 189 | 198 |
| 190 // Used for requests. MAY BE NULL which means don't try to download. | 199 // Used for requests. MAY BE NULL which means don't try to download. |
| 191 URLRequestContext* url_request_context_; | 200 URLRequestContext* url_request_context_; |
| 192 | 201 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 205 | 214 |
| 206 // Used for generating callbacks to spellchecker, since spellchecker is a | 215 // Used for generating callbacks to spellchecker, since spellchecker is a |
| 207 // non-reference counted object. The callback is generated by generating tasks | 216 // non-reference counted object. The callback is generated by generating tasks |
| 208 // using NewRunableMethod on these objects. | 217 // using NewRunableMethod on these objects. |
| 209 ScopedRunnableMethodFactory<SpellChecker> dic_download_state_changer_factory_; | 218 ScopedRunnableMethodFactory<SpellChecker> dic_download_state_changer_factory_; |
| 210 | 219 |
| 211 DISALLOW_COPY_AND_ASSIGN(SpellChecker); | 220 DISALLOW_COPY_AND_ASSIGN(SpellChecker); |
| 212 }; | 221 }; |
| 213 | 222 |
| 214 #endif // CHROME_BROWSER_SPELLCHECKER_H_ | 223 #endif // CHROME_BROWSER_SPELLCHECKER_H_ |
| OLD | NEW |