diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-19 19:17:32 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-19 19:17:32 +0000 |
commit | 2a3a7764dc3343682a888f194c59b9ad48729e4b (patch) | |
tree | a99a6831e8ae561ff3230b254496aa3705684ef2 /chrome/browser/renderer_host | |
parent | 58ce21e623685e1e7b4c97ed7d59fbfb9c8e9801 (diff) | |
download | chromium_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/renderer_host')
12 files changed, 22 insertions, 28 deletions
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index 8ad39ad..7831ab5 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -401,7 +401,7 @@ void BrowserRenderProcessHost::WidgetHidden() { } } -void BrowserRenderProcessHost::AddWord(const std::wstring& word) { +void BrowserRenderProcessHost::AddWord(const string16& word) { base::Thread* io_thread = g_browser_process->io_thread(); SpellChecker* spellchecker = profile()->GetSpellChecker(); if (spellchecker) { diff --git a/chrome/browser/renderer_host/browser_render_process_host.h b/chrome/browser/renderer_host/browser_render_process_host.h index 367b19c..b7c6803 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.h +++ b/chrome/browser/renderer_host/browser_render_process_host.h @@ -65,7 +65,7 @@ class BrowserRenderProcessHost : public RenderProcessHost, virtual void WidgetRestored(); virtual void WidgetHidden(); virtual void ViewCreated(); - virtual void AddWord(const std::wstring& word); + virtual void AddWord(const string16& word); virtual void AddVisitedLinks(const VisitedLinkCommon::Fingerprints& links); virtual void ResetVisitedLinks(); virtual bool FastShutdownIfPossible(); diff --git a/chrome/browser/renderer_host/mock_render_process_host.cc b/chrome/browser/renderer_host/mock_render_process_host.cc index 37c60bf..8e3dd3f 100644 --- a/chrome/browser/renderer_host/mock_render_process_host.cc +++ b/chrome/browser/renderer_host/mock_render_process_host.cc @@ -49,7 +49,7 @@ void MockRenderProcessHost::WidgetHidden() { void MockRenderProcessHost::ViewCreated() { } -void MockRenderProcessHost::AddWord(const std::wstring& word) { +void MockRenderProcessHost::AddWord(const string16& word) { } void MockRenderProcessHost::AddVisitedLinks( diff --git a/chrome/browser/renderer_host/mock_render_process_host.h b/chrome/browser/renderer_host/mock_render_process_host.h index 6d24cf6..e28ac68 100644 --- a/chrome/browser/renderer_host/mock_render_process_host.h +++ b/chrome/browser/renderer_host/mock_render_process_host.h @@ -41,7 +41,7 @@ class MockRenderProcessHost : public RenderProcessHost { virtual void WidgetRestored(); virtual void WidgetHidden(); virtual void ViewCreated(); - virtual void AddWord(const std::wstring& word); + virtual void AddWord(const string16& word); virtual void AddVisitedLinks( const VisitedLinkCommon::Fingerprints& visited_links); virtual void ResetVisitedLinks(); diff --git a/chrome/browser/renderer_host/render_process_host.h b/chrome/browser/renderer_host/render_process_host.h index 4014b63..5c15b1c 100644 --- a/chrome/browser/renderer_host/render_process_host.h +++ b/chrome/browser/renderer_host/render_process_host.h @@ -173,7 +173,7 @@ class RenderProcessHost : public IPC::Channel::Sender, virtual void ViewCreated() = 0; // Add a word in the spellchecker. - virtual void AddWord(const std::wstring& word) = 0; + virtual void AddWord(const string16& word) = 0; // Notify the renderer that a link was visited. virtual void AddVisitedLinks( diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index d8b86a7..8465992 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -530,15 +530,11 @@ void RenderViewHost::Paste() { Send(new ViewMsg_Paste(routing_id())); } -void RenderViewHost::Replace(const std::wstring& text_to_replace) { - Send(new ViewMsg_Replace(routing_id(), text_to_replace)); -} - void RenderViewHost::ToggleSpellCheck() { Send(new ViewMsg_ToggleSpellCheck(routing_id())); } -void RenderViewHost::AddToDictionary(const std::wstring& word) { +void RenderViewHost::AddToDictionary(const string16& word) { process()->AddWord(word); } diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index f6c1733..6d6104a 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -274,9 +274,8 @@ class RenderViewHost : public RenderWidgetHost, void Copy(); void CopyToFindPboard(); void Paste(); - void Replace(const std::wstring& text); void ToggleSpellCheck(); - void AddToDictionary(const std::wstring& word); + void AddToDictionary(const string16& word); void Delete(); void SelectAll(); void ToggleSpellPanel(bool is_currently_visible); diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc index c1ddaef..6d2b4bd 100644 --- a/chrome/browser/renderer_host/render_widget_host.cc +++ b/chrome/browser/renderer_host/render_widget_host.cc @@ -894,7 +894,7 @@ void RenderWidgetHost::ToggleSpellPanel(bool is_currently_visible) { Send(new ViewMsg_ToggleSpellPanel(routing_id(), is_currently_visible)); } -void RenderWidgetHost::ReplaceWord(const std::wstring& word) { +void RenderWidgetHost::Replace(const string16& word) { Send(new ViewMsg_Replace(routing_id_, word)); } diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h index 27bf238..01fce6c 100644 --- a/chrome/browser/renderer_host/render_widget_host.h +++ b/chrome/browser/renderer_host/render_widget_host.h @@ -11,6 +11,7 @@ #include "base/process.h" #include "base/gfx/size.h" #include "base/scoped_ptr.h" +#include "base/string16.h" #include "base/timer.h" #include "chrome/common/edit_command.h" #include "chrome/common/native_web_keyboard_event.h" @@ -334,7 +335,7 @@ class RenderWidgetHost : public IPC::Channel::Listener, void ToggleSpellPanel(bool is_currently_visible); // Makes an IPC call to tell webkit to replace the currently selected word. - void ReplaceWord(const std::wstring& word); + void Replace(const string16& word); // Makes an IPC call to tell webkit to advance to the next misspelling. void AdvanceToNextMisspelling(); diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm index 7709790..4df230e 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm @@ -795,8 +795,8 @@ void RenderWidgetHostViewMac::SetBackground(const SkBitmap& background) { NSString* newWord = [[sender selectedCell] stringValue]; if (newWord != nil) { RenderWidgetHostViewMac* thisHostView = [self renderWidgetHostViewMac]; - thisHostView->GetRenderWidgetHost()->ReplaceWord( - base::SysNSStringToWide(newWord)); + thisHostView->GetRenderWidgetHost()->Replace( + base::SysNSStringToUTF16(newWord)); } } @@ -819,7 +819,7 @@ void RenderWidgetHostViewMac::SetBackground(const SkBitmap& background) { // SpellCheckerPlatform::IgnoreWord assumes that is the correct tag. NSString* wordToIgnore = [sender stringValue]; if (wordToIgnore != nil) { - SpellCheckerPlatform::IgnoreWord(base::SysNSStringToUTF8(wordToIgnore)); + SpellCheckerPlatform::IgnoreWord(base::SysNSStringToUTF16(wordToIgnore)); // Strangely, the spellingPanel doesn't send checkSpelling after a word is // ignored, so we have to explicitly call AdvanceToNextMisspelling here. diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index da1e8ad..5d2efab 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -936,7 +936,7 @@ Clipboard* ResourceMessageFilter::GetClipboard() { // spellings are correct. // // Note: This is called in the IO thread. -void ResourceMessageFilter::OnSpellCheck(const std::wstring& word, int tag, +void ResourceMessageFilter::OnSpellCheck(const string16& word, int tag, IPC::Message* reply_msg) { int misspell_location = 0; int misspell_length = 0; @@ -964,13 +964,12 @@ void ResourceMessageFilter::OnDocumentWithTagClosed(int tag) { SpellCheckerPlatform::CloseDocumentWithTag(tag); } -void ResourceMessageFilter::OnGetAutoCorrectWord(const std::wstring& word, +void ResourceMessageFilter::OnGetAutoCorrectWord(const string16& word, int tag, IPC::Message* reply_msg) { - std::wstring autocorrect_word; - if (spellchecker_ != NULL) { - spellchecker_->GetAutoCorrectionWord(word, tag, &autocorrect_word); - } + string16 autocorrect_word; + if (spellchecker_ != NULL) + autocorrect_word = spellchecker_->GetAutoCorrectionWord(word, tag); ViewHostMsg_GetAutoCorrectWord::WriteReplyParams(reply_msg, autocorrect_word); @@ -983,7 +982,7 @@ void ResourceMessageFilter::OnShowSpellingPanel(bool show) { } void ResourceMessageFilter::OnUpdateSpellingPanelWithMisspelledWord( - const std::wstring& word) { + const string16& word) { SpellCheckerPlatform::UpdateSpellingPanelWithMisspelledWord(word); } diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h index 34a17f3..02c934f 100644 --- a/chrome/browser/renderer_host/resource_message_filter.h +++ b/chrome/browser/renderer_host/resource_message_filter.h @@ -166,14 +166,13 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, void OnDownloadUrl(const IPC::Message& message, const GURL& url, const GURL& referrer); - void OnSpellCheck(const std::wstring& word, int tag, - IPC::Message* reply_msg); + void OnSpellCheck(const string16& word, int tag, IPC::Message* reply_msg); void OnGetDocumentTag(IPC::Message* reply_msg); void OnDocumentWithTagClosed(int tag); - void OnGetAutoCorrectWord(const std::wstring& word, int tag, + void OnGetAutoCorrectWord(const string16& word, int tag, IPC::Message* reply_msg); void OnShowSpellingPanel(bool show); - void OnUpdateSpellingPanelWithMisspelledWord(const std::wstring& word); + void OnUpdateSpellingPanelWithMisspelledWord(const string16& word); void OnDnsPrefetch(const std::vector<std::string>& hostnames); void OnRendererHistograms(int sequence_number, const std::vector<std::string>& histogram_info); |