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 "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "chrome/browser/spellchecker/spellcheck_platform.h" | 11 #include "chrome/browser/spellchecker/spellcheck_platform.h" |
12 #include "chrome/browser/spellchecker/spellcheck_service.h" | 12 #include "chrome/browser/spellchecker/spellcheck_service.h" |
13 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
14 #include "chrome/common/spellcheck_common.h" | 14 #include "chrome/common/spellcheck_common.h" |
15 #include "components/data_use_measurement/core/data_use_user_data.h" | |
16 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
17 #include "content/public/browser/render_process_host.h" | 16 #include "content/public/browser/render_process_host.h" |
18 #include "net/base/load_flags.h" | 17 #include "net/base/load_flags.h" |
19 #include "net/url_request/url_fetcher.h" | 18 #include "net/url_request/url_fetcher.h" |
20 #include "net/url_request/url_request_context_getter.h" | 19 #include "net/url_request/url_request_context_getter.h" |
21 #include "url/gurl.h" | 20 #include "url/gurl.h" |
22 | 21 |
23 #if !defined(OS_ANDROID) | 22 #if !defined(OS_ANDROID) |
24 #include "base/files/memory_mapped_file.h" | 23 #include "base/files/memory_mapped_file.h" |
25 #include "third_party/hunspell/google/bdict.h" | 24 #include "third_party/hunspell/google/bdict.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 237 |
239 void SpellcheckHunspellDictionary::DownloadDictionary(GURL url) { | 238 void SpellcheckHunspellDictionary::DownloadDictionary(GURL url) { |
240 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 239 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
241 DCHECK(request_context_getter_); | 240 DCHECK(request_context_getter_); |
242 | 241 |
243 download_status_ = DOWNLOAD_IN_PROGRESS; | 242 download_status_ = DOWNLOAD_IN_PROGRESS; |
244 FOR_EACH_OBSERVER(Observer, observers_, | 243 FOR_EACH_OBSERVER(Observer, observers_, |
245 OnHunspellDictionaryDownloadBegin(language_)); | 244 OnHunspellDictionaryDownloadBegin(language_)); |
246 | 245 |
247 fetcher_ = net::URLFetcher::Create(url, net::URLFetcher::GET, this); | 246 fetcher_ = net::URLFetcher::Create(url, net::URLFetcher::GET, this); |
248 data_use_measurement::DataUseUserData::AttachToFetcher( | |
249 fetcher_.get(), data_use_measurement::DataUseUserData::SPELL_CHECKER); | |
250 fetcher_->SetRequestContext(request_context_getter_); | 247 fetcher_->SetRequestContext(request_context_getter_); |
251 fetcher_->SetLoadFlags( | 248 fetcher_->SetLoadFlags( |
252 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES); | 249 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES); |
253 fetcher_->Start(); | 250 fetcher_->Start(); |
254 // Attempt downloading the dictionary only once. | 251 // Attempt downloading the dictionary only once. |
255 request_context_getter_ = NULL; | 252 request_context_getter_ = NULL; |
256 } | 253 } |
257 | 254 |
258 // The default_dictionary_file can either come from the standard list of | 255 // The default_dictionary_file can either come from the standard list of |
259 // hunspell dictionaries (determined in InitializeDictionaryLocation), or it | 256 // hunspell dictionaries (determined in InitializeDictionaryLocation), or it |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 FOR_EACH_OBSERVER(Observer, observers_, | 365 FOR_EACH_OBSERVER(Observer, observers_, |
369 OnHunspellDictionaryInitialized(language_)); | 366 OnHunspellDictionaryInitialized(language_)); |
370 } | 367 } |
371 | 368 |
372 void SpellcheckHunspellDictionary::InformListenersOfDownloadFailure() { | 369 void SpellcheckHunspellDictionary::InformListenersOfDownloadFailure() { |
373 download_status_ = DOWNLOAD_FAILED; | 370 download_status_ = DOWNLOAD_FAILED; |
374 FOR_EACH_OBSERVER(Observer, | 371 FOR_EACH_OBSERVER(Observer, |
375 observers_, | 372 observers_, |
376 OnHunspellDictionaryDownloadFailure(language_)); | 373 OnHunspellDictionaryDownloadFailure(language_)); |
377 } | 374 } |
OLD | NEW |