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/location.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "chrome/browser/spellchecker/spellcheck_service.h" | 18 #include "chrome/browser/spellchecker/spellcheck_service.h" |
19 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
20 #include "components/data_use_measurement/core/data_use_user_data.h" | 20 #include "components/data_use_measurement/core/data_use_user_data.h" |
21 #include "components/spellcheck/browser/spellcheck_platform.h" | 21 #include "components/spellcheck/browser/spellcheck_platform.h" |
22 #include "components/spellcheck/common/spellcheck_common.h" | 22 #include "components/spellcheck/common/spellcheck_common.h" |
| 23 #include "components/spellcheck/spellcheck_build_features.h" |
23 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
24 #include "content/public/browser/render_process_host.h" | 25 #include "content/public/browser/render_process_host.h" |
25 #include "net/base/load_flags.h" | 26 #include "net/base/load_flags.h" |
26 #include "net/url_request/url_fetcher.h" | 27 #include "net/url_request/url_fetcher.h" |
27 #include "net/url_request/url_request_context_getter.h" | 28 #include "net/url_request/url_request_context_getter.h" |
28 #include "url/gurl.h" | 29 #include "url/gurl.h" |
29 | 30 |
30 #if !defined(OS_ANDROID) | 31 #if !defined(OS_ANDROID) |
31 #include "base/files/memory_mapped_file.h" | 32 #include "base/files/memory_mapped_file.h" |
32 #include "third_party/hunspell/google/bdict.h" | 33 #include "third_party/hunspell/google/bdict.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 download_status_(DOWNLOAD_NONE), | 110 download_status_(DOWNLOAD_NONE), |
110 weak_ptr_factory_(this) { | 111 weak_ptr_factory_(this) { |
111 } | 112 } |
112 | 113 |
113 SpellcheckHunspellDictionary::~SpellcheckHunspellDictionary() { | 114 SpellcheckHunspellDictionary::~SpellcheckHunspellDictionary() { |
114 } | 115 } |
115 | 116 |
116 void SpellcheckHunspellDictionary::Load() { | 117 void SpellcheckHunspellDictionary::Load() { |
117 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 118 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
118 | 119 |
119 #if defined(USE_BROWSER_SPELLCHECKER) | 120 #if BUILDFLAG(USE_BROWSER_SPELLCHECKER) |
120 if (spellcheck_platform::SpellCheckerAvailable() && | 121 if (spellcheck_platform::SpellCheckerAvailable() && |
121 spellcheck_platform::PlatformSupportsLanguage(language_)) { | 122 spellcheck_platform::PlatformSupportsLanguage(language_)) { |
122 use_browser_spellchecker_ = true; | 123 use_browser_spellchecker_ = true; |
123 spellcheck_platform::SetLanguage(language_); | 124 spellcheck_platform::SetLanguage(language_); |
124 base::ThreadTaskRunnerHandle::Get()->PostTask( | 125 base::ThreadTaskRunnerHandle::Get()->PostTask( |
125 FROM_HERE, | 126 FROM_HERE, |
126 base::Bind( | 127 base::Bind( |
127 &SpellcheckHunspellDictionary::InformListenersOfInitialization, | 128 &SpellcheckHunspellDictionary::InformListenersOfInitialization, |
128 weak_ptr_factory_.GetWeakPtr())); | 129 weak_ptr_factory_.GetWeakPtr())); |
129 return; | 130 return; |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 void SpellcheckHunspellDictionary::InformListenersOfInitialization() { | 373 void SpellcheckHunspellDictionary::InformListenersOfInitialization() { |
373 for (Observer& observer : observers_) | 374 for (Observer& observer : observers_) |
374 observer.OnHunspellDictionaryInitialized(language_); | 375 observer.OnHunspellDictionaryInitialized(language_); |
375 } | 376 } |
376 | 377 |
377 void SpellcheckHunspellDictionary::InformListenersOfDownloadFailure() { | 378 void SpellcheckHunspellDictionary::InformListenersOfDownloadFailure() { |
378 download_status_ = DOWNLOAD_FAILED; | 379 download_status_ = DOWNLOAD_FAILED; |
379 for (Observer& observer : observers_) | 380 for (Observer& observer : observers_) |
380 observer.OnHunspellDictionaryDownloadFailure(language_); | 381 observer.OnHunspellDictionaryDownloadFailure(language_); |
381 } | 382 } |
OLD | NEW |