| 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 |
| 11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "base/location.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/message_loop/message_loop.h" | |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/single_thread_task_runner.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" |
| 15 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 16 #include "chrome/browser/spellchecker/spellcheck_platform.h" | 18 #include "chrome/browser/spellchecker/spellcheck_platform.h" |
| 17 #include "chrome/browser/spellchecker/spellcheck_service.h" | 19 #include "chrome/browser/spellchecker/spellcheck_service.h" |
| 18 #include "chrome/common/chrome_paths.h" | 20 #include "chrome/common/chrome_paths.h" |
| 19 #include "chrome/common/spellcheck_common.h" | 21 #include "chrome/common/spellcheck_common.h" |
| 20 #include "components/data_use_measurement/core/data_use_user_data.h" | 22 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 21 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
| 23 #include "net/base/load_flags.h" | 25 #include "net/base/load_flags.h" |
| 24 #include "net/url_request/url_fetcher.h" | 26 #include "net/url_request/url_fetcher.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } | 114 } |
| 113 | 115 |
| 114 void SpellcheckHunspellDictionary::Load() { | 116 void SpellcheckHunspellDictionary::Load() { |
| 115 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 117 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 116 | 118 |
| 117 #if defined(USE_BROWSER_SPELLCHECKER) | 119 #if defined(USE_BROWSER_SPELLCHECKER) |
| 118 if (spellcheck_platform::SpellCheckerAvailable() && | 120 if (spellcheck_platform::SpellCheckerAvailable() && |
| 119 spellcheck_platform::PlatformSupportsLanguage(language_)) { | 121 spellcheck_platform::PlatformSupportsLanguage(language_)) { |
| 120 use_browser_spellchecker_ = true; | 122 use_browser_spellchecker_ = true; |
| 121 spellcheck_platform::SetLanguage(language_); | 123 spellcheck_platform::SetLanguage(language_); |
| 122 base::MessageLoop::current()->PostTask(FROM_HERE, | 124 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 125 FROM_HERE, |
| 123 base::Bind( | 126 base::Bind( |
| 124 &SpellcheckHunspellDictionary::InformListenersOfInitialization, | 127 &SpellcheckHunspellDictionary::InformListenersOfInitialization, |
| 125 weak_ptr_factory_.GetWeakPtr())); | 128 weak_ptr_factory_.GetWeakPtr())); |
| 126 return; | 129 return; |
| 127 } | 130 } |
| 128 #endif // USE_BROWSER_SPELLCHECKER | 131 #endif // USE_BROWSER_SPELLCHECKER |
| 129 | 132 |
| 130 // Mac falls back on hunspell if its platform spellchecker isn't available. | 133 // Mac falls back on hunspell if its platform spellchecker isn't available. |
| 131 // However, Android does not support hunspell. | 134 // However, Android does not support hunspell. |
| 132 #if !defined(OS_ANDROID) | 135 #if !defined(OS_ANDROID) |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 FOR_EACH_OBSERVER(Observer, observers_, | 374 FOR_EACH_OBSERVER(Observer, observers_, |
| 372 OnHunspellDictionaryInitialized(language_)); | 375 OnHunspellDictionaryInitialized(language_)); |
| 373 } | 376 } |
| 374 | 377 |
| 375 void SpellcheckHunspellDictionary::InformListenersOfDownloadFailure() { | 378 void SpellcheckHunspellDictionary::InformListenersOfDownloadFailure() { |
| 376 download_status_ = DOWNLOAD_FAILED; | 379 download_status_ = DOWNLOAD_FAILED; |
| 377 FOR_EACH_OBSERVER(Observer, | 380 FOR_EACH_OBSERVER(Observer, |
| 378 observers_, | 381 observers_, |
| 379 OnHunspellDictionaryDownloadFailure(language_)); | 382 OnHunspellDictionaryDownloadFailure(language_)); |
| 380 } | 383 } |
| OLD | NEW |