summaryrefslogtreecommitdiffstats
path: root/chrome/browser/spellchecker_mac.mm
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-19 19:17:32 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-19 19:17:32 +0000
commit2a3a7764dc3343682a888f194c59b9ad48729e4b (patch)
treea99a6831e8ae561ff3230b254496aa3705684ef2 /chrome/browser/spellchecker_mac.mm
parent58ce21e623685e1e7b4c97ed7d59fbfb9c8e9801 (diff)
downloadchromium_src-2a3a7764dc3343682a888f194c59b9ad48729e4b.zip
chromium_src-2a3a7764dc3343682a888f194c59b9ad48729e4b.tar.gz
chromium_src-2a3a7764dc3343682a888f194c59b9ad48729e4b.tar.bz2
Convert the spellchecker and associated messages and functions to use string16
for words instead of wstring. I also changed some places where it converted the word to a string to do that conversion at the last possible second before giving it to Hunspell (since this conversion isn't needed for Mac). TEST=Covered by unit tests BUG=none Review URL: http://codereview.chromium.org/274077 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29435 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/spellchecker_mac.mm')
-rw-r--r--chrome/browser/spellchecker_mac.mm29
1 files changed, 15 insertions, 14 deletions
diff --git a/chrome/browser/spellchecker_mac.mm b/chrome/browser/spellchecker_mac.mm
index 0a4d52e..99b20a7 100644
--- a/chrome/browser/spellchecker_mac.mm
+++ b/chrome/browser/spellchecker_mac.mm
@@ -113,8 +113,8 @@ void ShowSpellingPanel(bool show) {
}
}
-void UpdateSpellingPanelWithMisspelledWord(const std::wstring& word) {
- NSString * word_to_display = base::SysWideToNSString(word);
+void UpdateSpellingPanelWithMisspelledWord(const string16& word) {
+ NSString * word_to_display = base::SysUTF16ToNSString(word);
[[NSSpellChecker sharedSpellChecker]
updateSpellingPanelWithMisspelledWord:word_to_display];
}
@@ -142,7 +142,7 @@ void SetLanguage(const std::string& lang_to_set) {
static int last_seen_tag_;
-bool CheckSpelling(const std::string& word_to_check, int tag) {
+bool CheckSpelling(const string16& word_to_check, int tag) {
last_seen_tag_ = tag;
// [[NSSpellChecker sharedSpellChecker] checkSpellingOfString] returns an
@@ -150,7 +150,7 @@ bool CheckSpelling(const std::string& word_to_check, int tag) {
NSRange spell_range = {0,0};
// Convert the word to an NSString.
- NSString* NS_word_to_check = base::SysUTF8ToNSString(word_to_check);
+ NSString* NS_word_to_check = base::SysUTF16ToNSString(word_to_check);
// Check the spelling, starting at the beginning of the word.
spell_range = [[NSSpellChecker sharedSpellChecker]
checkSpellingOfString:NS_word_to_check startingAt:0
@@ -163,9 +163,9 @@ bool CheckSpelling(const std::string& word_to_check, int tag) {
return word_correct;
}
-void FillSuggestionList(const std::string& wrong_word,
- std::vector<std::wstring>* optional_suggestions) {
- NSString* NS_wrong_word = base::SysUTF8ToNSString(wrong_word);
+void FillSuggestionList(const string16& wrong_word,
+ std::vector<string16>* optional_suggestions) {
+ NSString* NS_wrong_word = base::SysUTF16ToNSString(wrong_word);
TimeTicks begin_time = TimeTicks::Now();
// The suggested words for |wrong_word|.
NSArray* guesses =
@@ -175,19 +175,19 @@ void FillSuggestionList(const std::string& wrong_word,
for (int i = 0; i < static_cast<int>([guesses count]); i++) {
if (i < kMaxSuggestions) {
- optional_suggestions->push_back(base::SysNSStringToWide(
+ optional_suggestions->push_back(base::SysNSStringToUTF16(
[guesses objectAtIndex:i]));
}
}
}
-void AddWord(const std::wstring& word) {
- NSString* word_to_add = base::SysWideToNSString(word);
+void AddWord(const string16& word) {
+ NSString* word_to_add = base::SysUTF16ToNSString(word);
[[NSSpellChecker sharedSpellChecker] learnWord:word_to_add];
}
-void RemoveWord(const std::wstring& word) {
- NSString *word_to_remove = base::SysWideToNSString(word);
+void RemoveWord(const string16& word) {
+ NSString *word_to_remove = base::SysUTF16ToNSString(word);
[[NSSpellChecker sharedSpellChecker] unlearnWord:word_to_remove];
}
@@ -196,8 +196,8 @@ int GetDocumentTag() {
return static_cast<int>(doc_tag);
}
-void IgnoreWord(const std::string& word) {
- [[NSSpellChecker sharedSpellChecker] ignoreWord:base::SysUTF8ToNSString(word)
+void IgnoreWord(const string16& word) {
+ [[NSSpellChecker sharedSpellChecker] ignoreWord:base::SysUTF16ToNSString(word)
inSpellDocumentWithTag:last_seen_tag_];
}
@@ -205,5 +205,6 @@ void CloseDocumentWithTag(int tag) {
[[NSSpellChecker sharedSpellChecker]
closeSpellDocumentWithTag:static_cast<NSInteger>(tag)];
}
+
} // namespace SpellCheckerPlatform