Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: chrome/browser/spellchecker.cc

Issue 155841: Update Hunspell to the latest stable version to use the latest dictionary for... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/spellcheck_unittest.cc ('k') | chrome/third_party/hunspell/README.chromium » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 // This should be done in File Loop, but since Hunspell is in this IO Loop, 606 // This should be done in File Loop, but since Hunspell is in this IO Loop,
607 // this too has to be initialized here. 607 // this too has to be initialized here.
608 // TODO(sidchat): Work out a way to initialize Hunspell in the File Loop. 608 // TODO(sidchat): Work out a way to initialize Hunspell in the File Loop.
609 std::string contents; 609 std::string contents;
610 file_util::ReadFileToString(custom_dictionary_file_name_, &contents); 610 file_util::ReadFileToString(custom_dictionary_file_name_, &contents);
611 std::vector<std::string> list_of_words; 611 std::vector<std::string> list_of_words;
612 SplitString(contents, '\n', &list_of_words); 612 SplitString(contents, '\n', &list_of_words);
613 if (hunspell_.get()) { 613 if (hunspell_.get()) {
614 for (std::vector<std::string>::iterator it = list_of_words.begin(); 614 for (std::vector<std::string>::iterator it = list_of_words.begin();
615 it != list_of_words.end(); ++it) { 615 it != list_of_words.end(); ++it) {
616 hunspell_->put_word(it->c_str()); 616 hunspell_->add(it->c_str());
617 } 617 }
618 } 618 }
619 } 619 }
620 620
621 // Returns whether or not the given string is a valid contraction. 621 // Returns whether or not the given string is a valid contraction.
622 // This function is a fall-back when the SpellcheckWordIterator class 622 // This function is a fall-back when the SpellcheckWordIterator class
623 // returns a concatenated word which is not in the selected dictionary 623 // returns a concatenated word which is not in the selected dictionary
624 // (e.g. "in'n'out") but each word is valid. 624 // (e.g. "in'n'out") but each word is valid.
625 bool SpellChecker::IsValidContraction(const string16& contraction) { 625 bool SpellChecker::IsValidContraction(const string16& contraction) {
626 SpellcheckWordIterator word_iterator; 626 SpellcheckWordIterator word_iterator;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 SpellCheckerPlatform::AddWord(word); 737 SpellCheckerPlatform::AddWord(word);
738 return; 738 return;
739 } 739 }
740 740
741 // Check if the |hunspell_| has been initialized at all. 741 // Check if the |hunspell_| has been initialized at all.
742 Initialize(); 742 Initialize();
743 743
744 // Add the word to hunspell. 744 // Add the word to hunspell.
745 std::string word_to_add = WideToUTF8(word); 745 std::string word_to_add = WideToUTF8(word);
746 if (!word_to_add.empty()) 746 if (!word_to_add.empty())
747 hunspell_->put_word(word_to_add.c_str()); 747 hunspell_->add(word_to_add.c_str());
748 748
749 // Now add the word to the custom dictionary file. 749 // Now add the word to the custom dictionary file.
750 Task* write_word_task = 750 Task* write_word_task =
751 new AddWordToCustomDictionaryTask(custom_dictionary_file_name_, word); 751 new AddWordToCustomDictionaryTask(custom_dictionary_file_name_, word);
752 if (file_loop_) 752 if (file_loop_)
753 file_loop_->PostTask(FROM_HERE, write_word_task); 753 file_loop_->PostTask(FROM_HERE, write_word_task);
754 else 754 else
755 write_word_task->Run(); 755 write_word_task->Run();
756 } 756 }
757 757
(...skipping 29 matching lines...) Expand all
787 787
788 // Populate the vector of WideStrings. 788 // Populate the vector of WideStrings.
789 for (int i = 0; i < number_of_suggestions; i++) { 789 for (int i = 0; i < number_of_suggestions; i++) {
790 if (i < kMaxSuggestions) 790 if (i < kMaxSuggestions)
791 optional_suggestions->push_back(UTF8ToWide(suggestions[i])); 791 optional_suggestions->push_back(UTF8ToWide(suggestions[i]));
792 free(suggestions[i]); 792 free(suggestions[i]);
793 } 793 }
794 if (suggestions != NULL) 794 if (suggestions != NULL)
795 free(suggestions); 795 free(suggestions);
796 } 796 }
OLDNEW
« no previous file with comments | « chrome/browser/spellcheck_unittest.cc ('k') | chrome/third_party/hunspell/README.chromium » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698