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/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/memory_mapped_file.h" | 8 #include "base/files/memory_mapped_file.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 StringToLowerASCII(bdict_file)); | 294 StringToLowerASCII(bdict_file)); |
295 } | 295 } |
296 | 296 |
297 void SpellcheckHunspellDictionary::DownloadDictionary(GURL url) { | 297 void SpellcheckHunspellDictionary::DownloadDictionary(GURL url) { |
298 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 298 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
299 DCHECK(request_context_getter_); | 299 DCHECK(request_context_getter_); |
300 | 300 |
301 download_status_ = DOWNLOAD_IN_PROGRESS; | 301 download_status_ = DOWNLOAD_IN_PROGRESS; |
302 FOR_EACH_OBSERVER(Observer, observers_, OnHunspellDictionaryDownloadBegin()); | 302 FOR_EACH_OBSERVER(Observer, observers_, OnHunspellDictionaryDownloadBegin()); |
303 | 303 |
304 fetcher_.reset(net::URLFetcher::Create(url, net::URLFetcher::GET, | 304 fetcher_.reset(net::URLFetcher::Create(url, net::URLFetcher::GET, this)); |
305 weak_ptr_factory_.GetWeakPtr())); | |
306 fetcher_->SetRequestContext(request_context_getter_); | 305 fetcher_->SetRequestContext(request_context_getter_); |
307 fetcher_->SetLoadFlags( | 306 fetcher_->SetLoadFlags( |
308 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES); | 307 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES); |
309 fetcher_->Start(); | 308 fetcher_->Start(); |
310 // Attempt downloading the dictionary only once. | 309 // Attempt downloading the dictionary only once. |
311 request_context_getter_ = NULL; | 310 request_context_getter_ = NULL; |
312 } | 311 } |
313 | 312 |
314 void SpellcheckHunspellDictionary::InitializeDictionaryLocationComplete( | 313 void SpellcheckHunspellDictionary::InitializeDictionaryLocationComplete( |
315 scoped_ptr<DictionaryFile> file) { | 314 scoped_ptr<DictionaryFile> file) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 void SpellcheckHunspellDictionary::InformListenersOfInitialization() { | 355 void SpellcheckHunspellDictionary::InformListenersOfInitialization() { |
357 FOR_EACH_OBSERVER(Observer, observers_, OnHunspellDictionaryInitialized()); | 356 FOR_EACH_OBSERVER(Observer, observers_, OnHunspellDictionaryInitialized()); |
358 } | 357 } |
359 | 358 |
360 void SpellcheckHunspellDictionary::InformListenersOfDownloadFailure() { | 359 void SpellcheckHunspellDictionary::InformListenersOfDownloadFailure() { |
361 download_status_ = DOWNLOAD_FAILED; | 360 download_status_ = DOWNLOAD_FAILED; |
362 FOR_EACH_OBSERVER(Observer, | 361 FOR_EACH_OBSERVER(Observer, |
363 observers_, | 362 observers_, |
364 OnHunspellDictionaryDownloadFailure()); | 363 OnHunspellDictionaryDownloadFailure()); |
365 } | 364 } |
OLD | NEW |