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_custom_dictionary.h" | 5 #include "chrome/browser/spellchecker/spellcheck_custom_dictionary.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <functional> | 8 #include <functional> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 Apply(dictionary_change); | 425 Apply(dictionary_change); |
426 Sync(dictionary_change); | 426 Sync(dictionary_change); |
427 is_loaded_ = true; | 427 is_loaded_ = true; |
428 FOR_EACH_OBSERVER(Observer, observers_, OnCustomDictionaryLoaded()); | 428 FOR_EACH_OBSERVER(Observer, observers_, OnCustomDictionaryLoaded()); |
429 if (!result->is_valid_file) { | 429 if (!result->is_valid_file) { |
430 // Save cleaned up data only after startup. | 430 // Save cleaned up data only after startup. |
431 fix_invalid_file_.Reset( | 431 fix_invalid_file_.Reset( |
432 base::Bind(&SpellcheckCustomDictionary::FixInvalidFile, | 432 base::Bind(&SpellcheckCustomDictionary::FixInvalidFile, |
433 weak_ptr_factory_.GetWeakPtr(), base::Passed(&result))); | 433 weak_ptr_factory_.GetWeakPtr(), base::Passed(&result))); |
434 BrowserThread::PostAfterStartupTask( | 434 BrowserThread::PostAfterStartupTask( |
435 FROM_HERE, | 435 FROM_HERE, BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), |
436 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | |
437 fix_invalid_file_.callback()); | 436 fix_invalid_file_.callback()); |
438 } | 437 } |
439 } | 438 } |
440 | 439 |
441 void SpellcheckCustomDictionary::Apply(const Change& dictionary_change) { | 440 void SpellcheckCustomDictionary::Apply(const Change& dictionary_change) { |
442 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 441 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
443 if (!dictionary_change.to_add().empty()) { | 442 if (!dictionary_change.to_add().empty()) { |
444 words_.insert(dictionary_change.to_add().begin(), | 443 words_.insert(dictionary_change.to_add().begin(), |
445 dictionary_change.to_add().end()); | 444 dictionary_change.to_add().end()); |
446 } | 445 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 } | 521 } |
523 | 522 |
524 void SpellcheckCustomDictionary::Notify(const Change& dictionary_change) { | 523 void SpellcheckCustomDictionary::Notify(const Change& dictionary_change) { |
525 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 524 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
526 if (!IsLoaded() || dictionary_change.empty()) | 525 if (!IsLoaded() || dictionary_change.empty()) |
527 return; | 526 return; |
528 FOR_EACH_OBSERVER(Observer, | 527 FOR_EACH_OBSERVER(Observer, |
529 observers_, | 528 observers_, |
530 OnCustomDictionaryChanged(dictionary_change)); | 529 OnCustomDictionaryChanged(dictionary_change)); |
531 } | 530 } |
OLD | NEW |