| 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" |
| 15 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/browser/render_process_host.h" | 17 #include "content/public/browser/render_process_host.h" |
| 17 #include "net/base/load_flags.h" | 18 #include "net/base/load_flags.h" |
| 18 #include "net/url_request/url_fetcher.h" | 19 #include "net/url_request/url_fetcher.h" |
| 19 #include "net/url_request/url_request_context_getter.h" | 20 #include "net/url_request/url_request_context_getter.h" |
| 20 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 21 | 22 |
| 22 #if !defined(OS_ANDROID) | 23 #if !defined(OS_ANDROID) |
| 23 #include "base/files/memory_mapped_file.h" | 24 #include "base/files/memory_mapped_file.h" |
| 24 #include "third_party/hunspell/google/bdict.h" | 25 #include "third_party/hunspell/google/bdict.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 } | 233 } |
| 233 | 234 |
| 234 void SpellcheckHunspellDictionary::DownloadDictionary(GURL url) { | 235 void SpellcheckHunspellDictionary::DownloadDictionary(GURL url) { |
| 235 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 236 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 236 DCHECK(request_context_getter_); | 237 DCHECK(request_context_getter_); |
| 237 | 238 |
| 238 download_status_ = DOWNLOAD_IN_PROGRESS; | 239 download_status_ = DOWNLOAD_IN_PROGRESS; |
| 239 FOR_EACH_OBSERVER(Observer, observers_, OnHunspellDictionaryDownloadBegin()); | 240 FOR_EACH_OBSERVER(Observer, observers_, OnHunspellDictionaryDownloadBegin()); |
| 240 | 241 |
| 241 fetcher_ = net::URLFetcher::Create(url, net::URLFetcher::GET, this); | 242 fetcher_ = net::URLFetcher::Create(url, net::URLFetcher::GET, this); |
| 243 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 244 fetcher_.get(), data_use_measurement::DataUseUserData::SPELL_CHECKER); |
| 242 fetcher_->SetRequestContext(request_context_getter_); | 245 fetcher_->SetRequestContext(request_context_getter_); |
| 243 fetcher_->SetLoadFlags( | 246 fetcher_->SetLoadFlags( |
| 244 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES); | 247 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES); |
| 245 fetcher_->Start(); | 248 fetcher_->Start(); |
| 246 // Attempt downloading the dictionary only once. | 249 // Attempt downloading the dictionary only once. |
| 247 request_context_getter_ = NULL; | 250 request_context_getter_ = NULL; |
| 248 } | 251 } |
| 249 | 252 |
| 250 // The default_dictionary_file can either come from the standard list of | 253 // The default_dictionary_file can either come from the standard list of |
| 251 // hunspell dictionaries (determined in InitializeDictionaryLocation), or it | 254 // hunspell dictionaries (determined in InitializeDictionaryLocation), or it |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 void SpellcheckHunspellDictionary::InformListenersOfInitialization() { | 362 void SpellcheckHunspellDictionary::InformListenersOfInitialization() { |
| 360 FOR_EACH_OBSERVER(Observer, observers_, OnHunspellDictionaryInitialized()); | 363 FOR_EACH_OBSERVER(Observer, observers_, OnHunspellDictionaryInitialized()); |
| 361 } | 364 } |
| 362 | 365 |
| 363 void SpellcheckHunspellDictionary::InformListenersOfDownloadFailure() { | 366 void SpellcheckHunspellDictionary::InformListenersOfDownloadFailure() { |
| 364 download_status_ = DOWNLOAD_FAILED; | 367 download_status_ = DOWNLOAD_FAILED; |
| 365 FOR_EACH_OBSERVER(Observer, | 368 FOR_EACH_OBSERVER(Observer, |
| 366 observers_, | 369 observers_, |
| 367 OnHunspellDictionaryDownloadFailure()); | 370 OnHunspellDictionaryDownloadFailure()); |
| 368 } | 371 } |
| OLD | NEW |