OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "app/l10n_util.h" | 5 #include "app/l10n_util.h" |
6 #include "chrome/browser/spellchecker.h" | 6 #include "chrome/browser/spellchecker.h" |
7 #include "chrome/browser/spellchecker_common.h" | 7 #include "chrome/browser/spellchecker_common.h" |
8 #include "chrome/browser/spellchecker_platform_engine.h" | 8 #include "chrome/browser/spellchecker_platform_engine.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 // This should be done in File Loop, but since Hunspell is in this IO Loop, | 588 // This should be done in File Loop, but since Hunspell is in this IO Loop, |
589 // this too has to be initialized here. | 589 // this too has to be initialized here. |
590 // TODO(sidchat): Work out a way to initialize Hunspell in the File Loop. | 590 // TODO(sidchat): Work out a way to initialize Hunspell in the File Loop. |
591 std::string contents; | 591 std::string contents; |
592 file_util::ReadFileToString(custom_dictionary_file_name_, &contents); | 592 file_util::ReadFileToString(custom_dictionary_file_name_, &contents); |
593 std::vector<std::string> list_of_words; | 593 std::vector<std::string> list_of_words; |
594 SplitString(contents, '\n', &list_of_words); | 594 SplitString(contents, '\n', &list_of_words); |
595 if (hunspell_.get()) { | 595 if (hunspell_.get()) { |
596 for (std::vector<std::string>::iterator it = list_of_words.begin(); | 596 for (std::vector<std::string>::iterator it = list_of_words.begin(); |
597 it != list_of_words.end(); ++it) { | 597 it != list_of_words.end(); ++it) { |
598 hunspell_->put_word(it->c_str()); | 598 hunspell_->add(it->c_str()); |
599 } | 599 } |
600 } | 600 } |
601 } | 601 } |
602 | 602 |
603 // Returns whether or not the given string is a valid contraction. | 603 // Returns whether or not the given string is a valid contraction. |
604 // This function is a fall-back when the SpellcheckWordIterator class | 604 // This function is a fall-back when the SpellcheckWordIterator class |
605 // returns a concatenated word which is not in the selected dictionary | 605 // returns a concatenated word which is not in the selected dictionary |
606 // (e.g. "in'n'out") but each word is valid. | 606 // (e.g. "in'n'out") but each word is valid. |
607 bool SpellChecker::IsValidContraction(const string16& contraction) { | 607 bool SpellChecker::IsValidContraction(const string16& contraction) { |
608 SpellcheckWordIterator word_iterator; | 608 SpellcheckWordIterator word_iterator; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 SpellCheckerPlatform::AddWord(word); | 721 SpellCheckerPlatform::AddWord(word); |
722 return; | 722 return; |
723 } | 723 } |
724 | 724 |
725 // Check if the |hunspell_| has been initialized at all. | 725 // Check if the |hunspell_| has been initialized at all. |
726 Initialize(); | 726 Initialize(); |
727 | 727 |
728 // Add the word to hunspell. | 728 // Add the word to hunspell. |
729 std::string word_to_add = WideToUTF8(word); | 729 std::string word_to_add = WideToUTF8(word); |
730 if (!word_to_add.empty()) | 730 if (!word_to_add.empty()) |
731 hunspell_->put_word(word_to_add.c_str()); | 731 hunspell_->add(word_to_add.c_str()); |
732 | 732 |
733 // Now add the word to the custom dictionary file. | 733 // Now add the word to the custom dictionary file. |
734 Task* write_word_task = | 734 Task* write_word_task = |
735 new AddWordToCustomDictionaryTask(custom_dictionary_file_name_, word); | 735 new AddWordToCustomDictionaryTask(custom_dictionary_file_name_, word); |
736 if (file_loop_) | 736 if (file_loop_) |
737 file_loop_->PostTask(FROM_HERE, write_word_task); | 737 file_loop_->PostTask(FROM_HERE, write_word_task); |
738 else | 738 else |
739 write_word_task->Run(); | 739 write_word_task->Run(); |
740 } | 740 } |
741 | 741 |
(...skipping 29 matching lines...) Expand all Loading... |
771 | 771 |
772 // Populate the vector of WideStrings. | 772 // Populate the vector of WideStrings. |
773 for (int i = 0; i < number_of_suggestions; i++) { | 773 for (int i = 0; i < number_of_suggestions; i++) { |
774 if (i < kMaxSuggestions) | 774 if (i < kMaxSuggestions) |
775 optional_suggestions->push_back(UTF8ToWide(suggestions[i])); | 775 optional_suggestions->push_back(UTF8ToWide(suggestions[i])); |
776 free(suggestions[i]); | 776 free(suggestions[i]); |
777 } | 777 } |
778 if (suggestions != NULL) | 778 if (suggestions != NULL) |
779 free(suggestions); | 779 free(suggestions); |
780 } | 780 } |
OLD | NEW |