OLD | NEW |
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 "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h" | 5 #include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 } | 299 } |
300 #endif | 300 #endif |
301 | 301 |
302 if (bdict_is_valid) { | 302 if (bdict_is_valid) { |
303 dictionary.file.Initialize(dictionary.path, | 303 dictionary.file.Initialize(dictionary.path, |
304 base::File::FLAG_READ | base::File::FLAG_OPEN); | 304 base::File::FLAG_READ | base::File::FLAG_OPEN); |
305 } else { | 305 } else { |
306 base::DeleteFile(dictionary.path, false); | 306 base::DeleteFile(dictionary.path, false); |
307 } | 307 } |
308 | 308 |
309 return dictionary.Pass(); | 309 return dictionary; |
310 } | 310 } |
311 | 311 |
312 // The default place where the spellcheck dictionary resides is | 312 // The default place where the spellcheck dictionary resides is |
313 // chrome::DIR_APP_DICTIONARIES. | 313 // chrome::DIR_APP_DICTIONARIES. |
314 SpellcheckHunspellDictionary::DictionaryFile | 314 SpellcheckHunspellDictionary::DictionaryFile |
315 SpellcheckHunspellDictionary::InitializeDictionaryLocation( | 315 SpellcheckHunspellDictionary::InitializeDictionaryLocation( |
316 const std::string& language) { | 316 const std::string& language) { |
317 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 317 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
318 | 318 |
319 // Initialize the BDICT path. Initialization should be in the FILE thread | 319 // Initialize the BDICT path. Initialization should be in the FILE thread |
320 // because it checks if there is a "Dictionaries" directory and create it. | 320 // because it checks if there is a "Dictionaries" directory and create it. |
321 base::FilePath dict_dir; | 321 base::FilePath dict_dir; |
322 PathService::Get(chrome::DIR_APP_DICTIONARIES, &dict_dir); | 322 PathService::Get(chrome::DIR_APP_DICTIONARIES, &dict_dir); |
323 base::FilePath dict_path = | 323 base::FilePath dict_path = |
324 chrome::spellcheck_common::GetVersionedFileName(language, dict_dir); | 324 chrome::spellcheck_common::GetVersionedFileName(language, dict_dir); |
325 | 325 |
326 return OpenDictionaryFile(dict_path); | 326 return OpenDictionaryFile(dict_path); |
327 } | 327 } |
328 | 328 |
329 void SpellcheckHunspellDictionary::InitializeDictionaryLocationComplete( | 329 void SpellcheckHunspellDictionary::InitializeDictionaryLocationComplete( |
330 DictionaryFile file) { | 330 DictionaryFile file) { |
331 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 331 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
332 dictionary_file_ = file.Pass(); | 332 dictionary_file_ = std::move(file); |
333 | 333 |
334 if (!dictionary_file_.file.IsValid()) { | 334 if (!dictionary_file_.file.IsValid()) { |
335 // Notify browser tests that this dictionary is corrupted. Skip downloading | 335 // Notify browser tests that this dictionary is corrupted. Skip downloading |
336 // the dictionary in browser tests. | 336 // the dictionary in browser tests. |
337 // TODO(rouslan): Remove this test-only case. | 337 // TODO(rouslan): Remove this test-only case. |
338 if (spellcheck_service_->SignalStatusEvent( | 338 if (spellcheck_service_->SignalStatusEvent( |
339 SpellcheckService::BDICT_CORRUPTED)) { | 339 SpellcheckService::BDICT_CORRUPTED)) { |
340 request_context_getter_ = NULL; | 340 request_context_getter_ = NULL; |
341 } | 341 } |
342 | 342 |
(...skipping 28 matching lines...) Expand all Loading... |
371 FOR_EACH_OBSERVER(Observer, observers_, | 371 FOR_EACH_OBSERVER(Observer, observers_, |
372 OnHunspellDictionaryInitialized(language_)); | 372 OnHunspellDictionaryInitialized(language_)); |
373 } | 373 } |
374 | 374 |
375 void SpellcheckHunspellDictionary::InformListenersOfDownloadFailure() { | 375 void SpellcheckHunspellDictionary::InformListenersOfDownloadFailure() { |
376 download_status_ = DOWNLOAD_FAILED; | 376 download_status_ = DOWNLOAD_FAILED; |
377 FOR_EACH_OBSERVER(Observer, | 377 FOR_EACH_OBSERVER(Observer, |
378 observers_, | 378 observers_, |
379 OnHunspellDictionaryDownloadFailure(language_)); | 379 OnHunspellDictionaryDownloadFailure(language_)); |
380 } | 380 } |
OLD | NEW |