diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-25 01:55:45 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-25 01:55:45 +0000 |
commit | 3e26719114a404d97e1b979fb8b86f3f3016df29 (patch) | |
tree | c2d1cb3ba190ee97649fc48fb8c86c34069b9bcb /chrome | |
parent | 4e69ec1031ae5a80d0d262e9f43d1af149a8dd42 (diff) | |
download | chromium_src-3e26719114a404d97e1b979fb8b86f3f3016df29.zip chromium_src-3e26719114a404d97e1b979fb8b86f3f3016df29.tar.gz chromium_src-3e26719114a404d97e1b979fb8b86f3f3016df29.tar.bz2 |
Move spellcheck messages into their own file, and dispatch them all in SpellCheckMessageFilter. The next step would be to make WebView have a setter for a WebSpellCheckClient that SpellCheckProvider implements so that spelling can be taken out of RenderView completely.
Review URL: http://codereview.chromium.org/6730045
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79362 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/renderer_host/browser_render_process_host.cc | 12 | ||||
-rw-r--r-- | chrome/browser/renderer_host/chrome_render_message_filter.cc | 15 | ||||
-rw-r--r-- | chrome/browser/renderer_host/chrome_render_message_filter.h | 3 | ||||
-rw-r--r-- | chrome/browser/spellcheck_message_filter.cc | 44 | ||||
-rw-r--r-- | chrome/browser/spellcheck_message_filter.h | 7 | ||||
-rw-r--r-- | chrome/browser/spellcheck_message_filter_browsertest.cc | 6 | ||||
-rw-r--r-- | chrome/browser/spellchecker_mac.mm | 12 | ||||
-rw-r--r-- | chrome/chrome_common.gypi | 1 | ||||
-rw-r--r-- | chrome/common/common_message_generator.h | 1 | ||||
-rw-r--r-- | chrome/common/render_messages.h | 87 | ||||
-rw-r--r-- | chrome/common/spellcheck_messages.h | 96 | ||||
-rw-r--r-- | chrome/renderer/render_thread.cc | 34 | ||||
-rw-r--r-- | chrome/renderer/spellchecker/spellcheck.cc | 11 | ||||
-rw-r--r-- | chrome/renderer/spellchecker/spellcheck_provider.cc | 10 | ||||
-rw-r--r-- | chrome/renderer/spellchecker/spellcheck_provider.h | 4 | ||||
-rw-r--r-- | chrome/renderer/spellchecker/spellcheck_provider_unittest.cc | 15 |
16 files changed, 212 insertions, 146 deletions
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index b6af6e2..2f1ce67 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -56,8 +56,8 @@ #include "chrome/common/net/url_request_context_getter.h" #include "chrome/common/pref_names.h" #include "chrome/common/render_messages.h" -#include "chrome/common/render_messages_params.h" #include "chrome/common/safebrowsing_messages.h" +#include "chrome/common/spellcheck_messages.h" #include "chrome/renderer/render_process_impl.h" #include "chrome/renderer/render_thread.h" #include "content/browser/appcache/appcache_dispatcher_host.h" @@ -1007,7 +1007,7 @@ bool BrowserRenderProcessHost::OnMessageReceived(const IPC::Message& msg) { OnExtensionCloseChannel) IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, OnUserMetricsRecordAction) - IPC_MESSAGE_HANDLER(ViewHostMsg_SpellChecker_RequestDictionary, + IPC_MESSAGE_HANDLER(SpellCheckHostMsg_RequestDictionary, OnSpellCheckerRequestDictionary) IPC_MESSAGE_UNHANDLED_ERROR() IPC_END_MESSAGE_MAP_EX() @@ -1249,7 +1249,7 @@ void BrowserRenderProcessHost::OnSpellCheckerRequestDictionary() { } void BrowserRenderProcessHost::AddSpellCheckWord(const std::string& word) { - Send(new ViewMsg_SpellChecker_WordAdded(word)); + Send(new SpellCheckMsg_WordAdded(word)); } void BrowserRenderProcessHost::InitSpellChecker() { @@ -1273,13 +1273,13 @@ void BrowserRenderProcessHost::InitSpellChecker() { #endif } - Send(new ViewMsg_SpellChecker_Init( + Send(new SpellCheckMsg_Init( file, spellcheck_host->GetCustomWords(), spellcheck_host->GetLanguage(), prefs->GetBoolean(prefs::kEnableAutoSpellCorrect))); } else { - Send(new ViewMsg_SpellChecker_Init( + Send(new SpellCheckMsg_Init( IPC::InvalidPlatformFileForTransit(), std::vector<std::string>(), std::string(), @@ -1288,7 +1288,7 @@ void BrowserRenderProcessHost::InitSpellChecker() { } void BrowserRenderProcessHost::EnableAutoSpellCorrect(bool enable) { - Send(new ViewMsg_SpellChecker_EnableAutoSpellCorrect(enable)); + Send(new SpellCheckMsg_EnableAutoSpellCorrect(enable)); } void BrowserRenderProcessHost::InitClientSidePhishingDetection() { diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.cc b/chrome/browser/renderer_host/chrome_render_message_filter.cc index 8d3f5a2..7c4dcd7 100644 --- a/chrome/browser/renderer_host/chrome_render_message_filter.cc +++ b/chrome/browser/renderer_host/chrome_render_message_filter.cc @@ -5,7 +5,9 @@ #include "chrome/browser/renderer_host/chrome_render_message_filter.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/metrics/histogram_synchronizer.h" #include "chrome/browser/nacl_host/nacl_process_host.h" +#include "chrome/browser/net/predictor_api.h" #include "chrome/common/render_messages.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" @@ -23,6 +25,8 @@ bool ChromeRenderMessageFilter::OnMessageReceived(const IPC::Message& message, bool handled = true; IPC_BEGIN_MESSAGE_MAP_EX(ChromeRenderMessageFilter, message, *message_was_ok) IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_LaunchNaCl, OnLaunchNaCl) + IPC_MESSAGE_HANDLER(ViewHostMsg_DnsPrefetch, OnDnsPrefetch) + IPC_MESSAGE_HANDLER(ViewHostMsg_RendererHistograms, OnRendererHistograms) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -38,3 +42,14 @@ void ChromeRenderMessageFilter::OnLaunchNaCl( NaClProcessHost* host = new NaClProcessHost(resource_dispatcher_host_, url); host->Launch(this, channel_descriptor, reply_msg); } + +void ChromeRenderMessageFilter::OnDnsPrefetch( + const std::vector<std::string>& hostnames) { + chrome_browser_net::DnsPrefetchList(hostnames); +} + +void ChromeRenderMessageFilter::OnRendererHistograms( + int sequence_number, + const std::vector<std::string>& histograms) { + HistogramSynchronizer::DeserializeHistogramList(sequence_number, histograms); +} diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.h b/chrome/browser/renderer_host/chrome_render_message_filter.h index 1ab51fc..78a96f7 100644 --- a/chrome/browser/renderer_host/chrome_render_message_filter.h +++ b/chrome/browser/renderer_host/chrome_render_message_filter.h @@ -30,6 +30,9 @@ class ChromeRenderMessageFilter : public BrowserMessageFilter { void OnLaunchNaCl(const std::wstring& url, int channel_descriptor, IPC::Message* reply_msg); + void OnDnsPrefetch(const std::vector<std::string>& hostnames); + void OnRendererHistograms(int sequence_number, + const std::vector<std::string>& histogram_info); ResourceDispatcherHost* resource_dispatcher_host_; diff --git a/chrome/browser/spellcheck_message_filter.cc b/chrome/browser/spellcheck_message_filter.cc index f2efbf9..1a63117 100644 --- a/chrome/browser/spellcheck_message_filter.cc +++ b/chrome/browser/spellcheck_message_filter.cc @@ -5,7 +5,7 @@ #include "chrome/browser/spellcheck_message_filter.h" #include "chrome/browser/spellchecker_platform_engine.h" -#include "chrome/common/render_messages.h" +#include "chrome/common/spellcheck_messages.h" SpellCheckMessageFilter::SpellCheckMessageFilter() { } @@ -17,13 +17,53 @@ bool SpellCheckMessageFilter::OnMessageReceived(const IPC::Message& message, bool* message_was_ok) { bool handled = true; IPC_BEGIN_MESSAGE_MAP_EX(SpellCheckMessageFilter, message, *message_was_ok) - IPC_MESSAGE_HANDLER(ViewHostMsg_SpellChecker_PlatformRequestTextCheck, + IPC_MESSAGE_HANDLER(SpellCheckHostMsg_PlatformCheckSpelling, + OnPlatformCheckSpelling) + IPC_MESSAGE_HANDLER(SpellCheckHostMsg_PlatformFillSuggestionList, + OnPlatformFillSuggestionList) + IPC_MESSAGE_HANDLER(SpellCheckHostMsg_GetDocumentTag, OnGetDocumentTag) + IPC_MESSAGE_HANDLER(SpellCheckHostMsg_DocumentWithTagClosed, + OnDocumentWithTagClosed) + IPC_MESSAGE_HANDLER(SpellCheckHostMsg_ShowSpellingPanel, + OnShowSpellingPanel) + IPC_MESSAGE_HANDLER(SpellCheckHostMsg_UpdateSpellingPanelWithMisspelledWord, + OnUpdateSpellingPanelWithMisspelledWord) + IPC_MESSAGE_HANDLER(SpellCheckHostMsg_PlatformRequestTextCheck, OnPlatformRequestTextCheck) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; } +void SpellCheckMessageFilter::OnPlatformCheckSpelling(const string16& word, + int tag, + bool* correct) { + *correct = SpellCheckerPlatform::CheckSpelling(word, tag); +} + +void SpellCheckMessageFilter::OnPlatformFillSuggestionList( + const string16& word, + std::vector<string16>* suggestions) { + SpellCheckerPlatform::FillSuggestionList(word, suggestions); +} + +void SpellCheckMessageFilter::OnGetDocumentTag(int* tag) { + *tag = SpellCheckerPlatform::GetDocumentTag(); +} + +void SpellCheckMessageFilter::OnDocumentWithTagClosed(int tag) { + SpellCheckerPlatform::CloseDocumentWithTag(tag); +} + +void SpellCheckMessageFilter::OnShowSpellingPanel(bool show) { + SpellCheckerPlatform::ShowSpellingPanel(show); +} + +void SpellCheckMessageFilter::OnUpdateSpellingPanelWithMisspelledWord( + const string16& word) { + SpellCheckerPlatform::UpdateSpellingPanelWithMisspelledWord(word); +} + void SpellCheckMessageFilter::OnPlatformRequestTextCheck( int route_id, int identifier, diff --git a/chrome/browser/spellcheck_message_filter.h b/chrome/browser/spellcheck_message_filter.h index bd4bafc..9dadd7f 100644 --- a/chrome/browser/spellcheck_message_filter.h +++ b/chrome/browser/spellcheck_message_filter.h @@ -19,6 +19,13 @@ class SpellCheckMessageFilter : public BrowserMessageFilter { bool* message_was_ok); private: + void OnPlatformCheckSpelling(const string16& word, int tag, bool* correct); + void OnPlatformFillSuggestionList(const string16& word, + std::vector<string16>* suggestions); + void OnGetDocumentTag(int* tag); + void OnDocumentWithTagClosed(int tag); + void OnShowSpellingPanel(bool show); + void OnUpdateSpellingPanelWithMisspelledWord(const string16& word); void OnPlatformRequestTextCheck(int route_id, int identifier, int document_tag, diff --git a/chrome/browser/spellcheck_message_filter_browsertest.cc b/chrome/browser/spellcheck_message_filter_browsertest.cc index 979e60c..b981a19 100644 --- a/chrome/browser/spellcheck_message_filter_browsertest.cc +++ b/chrome/browser/spellcheck_message_filter_browsertest.cc @@ -6,7 +6,7 @@ #include "base/message_loop.h" #include "base/utf_string_conversions.h" #include "chrome/browser/spellcheck_message_filter.h" -#include "chrome/common/render_messages.h" +#include "chrome/common/spellcheck_messages.h" #include "chrome/test/in_process_browser_test.h" #include "chrome/test/ui_test_utils.h" #include "testing/gtest/include/gtest/gtest.h" @@ -47,7 +47,7 @@ IN_PROC_BROWSER_TEST_F(SpellCheckMessageFilterBrowserTest, scoped_refptr<TestingSpellCheckMessageFilter> target (new TestingSpellCheckMessageFilter(MessageLoopForUI::current())); - ViewHostMsg_SpellChecker_PlatformRequestTextCheck to_be_received + SpellCheckHostMsg_PlatformRequestTextCheck to_be_received (123, 456, 789, UTF8ToUTF16("zz.")); bool handled = false; target->OnMessageReceived(to_be_received, &handled); @@ -59,7 +59,7 @@ IN_PROC_BROWSER_TEST_F(SpellCheckMessageFilterBrowserTest, int sent_identifier; int sent_tag; std::vector<WebKit::WebTextCheckingResult> sent_results; - bool ok = ViewMsg_SpellChecker_RespondTextCheck::Read( + bool ok = SpellCheckMsg_RespondTextCheck::Read( target->sent_messages_[0], &sent_identifier, &sent_tag, &sent_results); EXPECT_TRUE(ok); EXPECT_EQ(1U, sent_results.size()); diff --git a/chrome/browser/spellchecker_mac.mm b/chrome/browser/spellchecker_mac.mm index 6b22888..ba30547 100644 --- a/chrome/browser/spellchecker_mac.mm +++ b/chrome/browser/spellchecker_mac.mm @@ -14,8 +14,8 @@ #include "base/task.h" #include "base/time.h" #include "base/sys_string_conversions.h" -#include "chrome/common/render_messages.h" #include "chrome/common/spellcheck_common.h" +#include "chrome/common/spellcheck_messages.h" #include "content/browser/browser_thread.h" #include "content/browser/browser_message_filter.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingResult.h" @@ -31,7 +31,7 @@ const unsigned int kShortLanguageCodeSize = 2; // the FILE thread. // // The result of the check is returned back as a -// ViewMsg_SpellChecker_RespondTextCheck message. +// SpellCheckMsg_RespondTextCheck message. class TextCheckingTask : public Task { public: TextCheckingTask(BrowserMessageFilter* destination, @@ -75,10 +75,10 @@ class TextCheckingTask : public Task { NewRunnableMethod( destination_.get(), &BrowserMessageFilter::Send, - new ViewMsg_SpellChecker_RespondTextCheck(route_id_, - identifier_, - document_tag_, - check_results))); + new SpellCheckMsg_RespondTextCheck(route_id_, + identifier_, + document_tag_, + check_results))); } private: diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi index fdbeb6c..3fcb4f4 100644 --- a/chrome/chrome_common.gypi +++ b/chrome/chrome_common.gypi @@ -222,6 +222,7 @@ 'common/service_process_util_win.cc', 'common/spellcheck_common.cc', 'common/spellcheck_common.h', + 'common/spellcheck_messages.h', 'common/sqlite_compiled_statement.cc', 'common/sqlite_compiled_statement.h', 'common/sqlite_utils.cc', diff --git a/chrome/common/common_message_generator.h b/chrome/common/common_message_generator.h index d05d225..6d6dfb5 100644 --- a/chrome/common/common_message_generator.h +++ b/chrome/common/common_message_generator.h @@ -10,4 +10,5 @@ #include "chrome/common/render_messages.h" #include "chrome/common/safebrowsing_messages.h" #include "chrome/common/service_messages.h" +#include "chrome/common/spellcheck_messages.h" #include "chrome/common/utility_messages.h" diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 05eb031..ea5347c 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -42,12 +42,10 @@ #include "ipc/ipc_channel_handle.h" #include "ipc/ipc_message_macros.h" #include "ipc/ipc_message_utils.h" -#include "ipc/ipc_platform_file.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderline.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingResult.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/rect.h" #include "webkit/glue/webcursor.h" @@ -152,7 +150,6 @@ IPC_ENUM_TRAITS(InstantCompleteBehavior) IPC_ENUM_TRAITS(TranslateErrors::Type) IPC_ENUM_TRAITS(ViewType::Type) IPC_ENUM_TRAITS(WebKit::WebConsoleMessage::Level) -IPC_ENUM_TRAITS(WebKit::WebTextCheckingResult::Error) IPC_STRUCT_TRAITS_BEGIN(ThumbnailScore) IPC_STRUCT_TRAITS_MEMBER(boring_score) @@ -200,12 +197,6 @@ IPC_STRUCT_TRAITS_BEGIN(WebKit::WebCache::UsageStats) IPC_STRUCT_TRAITS_MEMBER(deadSize) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(WebKit::WebTextCheckingResult) - IPC_STRUCT_TRAITS_MEMBER(error) - IPC_STRUCT_TRAITS_MEMBER(position) - IPC_STRUCT_TRAITS_MEMBER(length) -IPC_STRUCT_TRAITS_END() - //----------------------------------------------------------------------------- // RenderView messages // These are messages sent from the browser to the renderer process. @@ -435,38 +426,6 @@ IPC_MESSAGE_ROUTED1(ViewMsg_NotifyRenderViewType, IPC_MESSAGE_ROUTED1(ViewMsg_ExecuteCode, ViewMsg_ExecuteCode_Params) -// SpellChecker messages. - -IPC_MESSAGE_ROUTED0(ViewMsg_ToggleSpellCheck) -IPC_MESSAGE_ROUTED1(ViewMsg_ToggleSpellPanel, - bool) -IPC_MESSAGE_ROUTED3(ViewMsg_SpellChecker_RespondTextCheck, - int /* request identifier given by WebKit */, - int /* document tag */, - std::vector<WebKit::WebTextCheckingResult>) - -// This message tells the renderer to advance to the next misspelling. It is -// sent when the user clicks the "Find Next" button on the spelling panel. -IPC_MESSAGE_ROUTED0(ViewMsg_AdvanceToNextMisspelling) - -// Passes some initialization params to the renderer's spellchecker. This can -// be called directly after startup or in (async) response to a -// RequestDictionary ViewHost message. -IPC_MESSAGE_CONTROL4(ViewMsg_SpellChecker_Init, - IPC::PlatformFileForTransit /* bdict_file */, - std::vector<std::string> /* custom_dict_words */, - std::string /* language */, - bool /* auto spell correct */) - -// A word has been added to the custom dictionary; update the local custom -// word list. -IPC_MESSAGE_CONTROL1(ViewMsg_SpellChecker_WordAdded, - std::string /* word */) - -// Toggle the auto spell correct functionality. -IPC_MESSAGE_CONTROL1(ViewMsg_SpellChecker_EnableAutoSpellCorrect, - bool /* enable */) - // Tells the renderer to translate the page contents from one language to // another. IPC_MESSAGE_ROUTED4(ViewMsg_TranslatePage, @@ -494,52 +453,6 @@ IPC_MESSAGE_CONTROL1(ViewMsg_SetIsIncognitoProcess, IPC_MESSAGE_CONTROL1(ViewHostMsg_UpdatedCacheStats, WebKit::WebCache::UsageStats /* stats */) -// Requests spellcheck for a word. -IPC_SYNC_MESSAGE_ROUTED2_2(ViewHostMsg_SpellCheck, - string16 /* word to check */, - int /* document tag*/, - int /* misspell location */, - int /* misspell length */) - -// Asks the browser for a unique document tag. -IPC_SYNC_MESSAGE_ROUTED0_1(ViewHostMsg_GetDocumentTag, - int /* the tag */) - -// This message tells the spellchecker that a document, identified by an int -// tag, has been closed and all of the ignored words for that document can be -// forgotten. -IPC_MESSAGE_ROUTED1(ViewHostMsg_DocumentWithTagClosed, - int /* the tag */) - -// Tells the browser to display or not display the SpellingPanel -IPC_MESSAGE_ROUTED1(ViewHostMsg_ShowSpellingPanel, - bool /* if true, then show it, otherwise hide it*/) - -// Tells the browser to update the spelling panel with the given word. -IPC_MESSAGE_ROUTED1(ViewHostMsg_UpdateSpellingPanelWithMisspelledWord, - string16 /* the word to update the panel with */) - -// The renderer has tried to spell check a word, but couldn't because no -// dictionary was available to load. Request that the browser find an -// appropriate dictionary and return it. -IPC_MESSAGE_CONTROL0(ViewHostMsg_SpellChecker_RequestDictionary) - -IPC_SYNC_MESSAGE_CONTROL2_1(ViewHostMsg_SpellChecker_PlatformCheckSpelling, - string16 /* word */, - int /* document tag */, - bool /* correct */) - -IPC_SYNC_MESSAGE_CONTROL1_1( - ViewHostMsg_SpellChecker_PlatformFillSuggestionList, - string16 /* word */, - std::vector<string16> /* suggestions */) - -IPC_MESSAGE_CONTROL4(ViewHostMsg_SpellChecker_PlatformRequestTextCheck, - int /* route_id for response */, - int /* request identifier given by WebKit */, - int /* document tag */, - string16 /* sentence */) - // Tells the browser that content in the current page was blocked due to the // user's content settings. IPC_MESSAGE_ROUTED2(ViewHostMsg_ContentBlocked, diff --git a/chrome/common/spellcheck_messages.h b/chrome/common/spellcheck_messages.h new file mode 100644 index 0000000..34ccb5c --- /dev/null +++ b/chrome/common/spellcheck_messages.h @@ -0,0 +1,96 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// IPC messages for spellcheck. +// Multiply-included message file, hence no include guard. + +#include "ipc/ipc_message_macros.h" +#include "ipc/ipc_platform_file.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingResult.h" + +#define IPC_MESSAGE_START SpellCheckMsgStart + +IPC_ENUM_TRAITS(WebKit::WebTextCheckingResult::Error) + +IPC_STRUCT_TRAITS_BEGIN(WebKit::WebTextCheckingResult) + IPC_STRUCT_TRAITS_MEMBER(error) + IPC_STRUCT_TRAITS_MEMBER(position) + IPC_STRUCT_TRAITS_MEMBER(length) +IPC_STRUCT_TRAITS_END() + + +// Messages sent from the browser to the renderer. + +IPC_MESSAGE_ROUTED0(SpellCheckMsg_ToggleSpellCheck) + +IPC_MESSAGE_ROUTED1(SpellCheckMsg_ToggleSpellPanel, + bool) + +IPC_MESSAGE_ROUTED3(SpellCheckMsg_RespondTextCheck, + int /* request identifier given by WebKit */, + int /* document tag */, + std::vector<WebKit::WebTextCheckingResult>) + +// This message tells the renderer to advance to the next misspelling. It is +// sent when the user clicks the "Find Next" button on the spelling panel. +IPC_MESSAGE_ROUTED0(SpellCheckMsg_AdvanceToNextMisspelling) + +// Passes some initialization params to the renderer's spellchecker. This can +// be called directly after startup or in (async) response to a +// RequestDictionary ViewHost message. +IPC_MESSAGE_CONTROL4(SpellCheckMsg_Init, + IPC::PlatformFileForTransit /* bdict_file */, + std::vector<std::string> /* custom_dict_words */, + std::string /* language */, + bool /* auto spell correct */) + +// A word has been added to the custom dictionary; update the local custom +// word list. +IPC_MESSAGE_CONTROL1(SpellCheckMsg_WordAdded, + std::string /* word */) + +// Toggle the auto spell correct functionality. +IPC_MESSAGE_CONTROL1(SpellCheckMsg_EnableAutoSpellCorrect, + bool /* enable */) + + +// Messages sent from the renderer to the browser. + +// Asks the browser for a unique document tag. +IPC_SYNC_MESSAGE_ROUTED0_1(SpellCheckHostMsg_GetDocumentTag, + int /* the tag */) + +// This message tells the spellchecker that a document, identified by an int +// tag, has been closed and all of the ignored words for that document can be +// forgotten. +IPC_MESSAGE_ROUTED1(SpellCheckHostMsg_DocumentWithTagClosed, + int /* the tag */) + +// Tells the browser to display or not display the SpellingPanel +IPC_MESSAGE_ROUTED1(SpellCheckHostMsg_ShowSpellingPanel, + bool /* if true, then show it, otherwise hide it*/) + +// Tells the browser to update the spelling panel with the given word. +IPC_MESSAGE_ROUTED1(SpellCheckHostMsg_UpdateSpellingPanelWithMisspelledWord, + string16 /* the word to update the panel with */) + +// The renderer has tried to spell check a word, but couldn't because no +// dictionary was available to load. Request that the browser find an +// appropriate dictionary and return it. +IPC_MESSAGE_CONTROL0(SpellCheckHostMsg_RequestDictionary) + +IPC_SYNC_MESSAGE_CONTROL2_1(SpellCheckHostMsg_PlatformCheckSpelling, + string16 /* word */, + int /* document tag */, + bool /* correct */) + +IPC_SYNC_MESSAGE_CONTROL1_1(SpellCheckHostMsg_PlatformFillSuggestionList, + string16 /* word */, + std::vector<string16> /* suggestions */) + +IPC_MESSAGE_CONTROL4(SpellCheckHostMsg_PlatformRequestTextCheck, + int /* route_id for response */, + int /* request identifier given by WebKit */, + int /* document tag */, + string16 /* sentence */) diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index b66da67..c32c11e 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -28,7 +28,7 @@ #include "chrome/common/extensions/extension_localization_peer.h" #include "chrome/common/extensions/extension_set.h" #include "chrome/common/render_messages.h" -#include "chrome/common/render_messages_params.h" +#include "chrome/common/spellcheck_messages.h" #include "chrome/common/safebrowsing_messages.h" #include "chrome/common/url_constants.h" #include "chrome/renderer/automation/dom_automation_v8_extension.h" @@ -657,45 +657,35 @@ bool RenderThread::OnControlMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView) IPC_MESSAGE_HANDLER(ViewMsg_SetCacheCapacities, OnSetCacheCapacities) IPC_MESSAGE_HANDLER(ViewMsg_ClearCache, OnClearCache) - IPC_MESSAGE_HANDLER(ViewMsg_GetRendererHistograms, - OnGetRendererHistograms) + IPC_MESSAGE_HANDLER(ViewMsg_GetRendererHistograms, OnGetRendererHistograms) #if defined(USE_TCMALLOC) - IPC_MESSAGE_HANDLER(ViewMsg_GetRendererTcmalloc, - OnGetRendererTcmalloc) + IPC_MESSAGE_HANDLER(ViewMsg_GetRendererTcmalloc, OnGetRendererTcmalloc) #endif IPC_MESSAGE_HANDLER(ViewMsg_GetV8HeapStats, OnGetV8HeapStats) - IPC_MESSAGE_HANDLER(ViewMsg_GetCacheResourceStats, - OnGetCacheResourceStats) - IPC_MESSAGE_HANDLER(ViewMsg_UserScripts_UpdatedScripts, - OnUpdateUserScripts) + IPC_MESSAGE_HANDLER(ViewMsg_GetCacheResourceStats, OnGetCacheResourceStats) + IPC_MESSAGE_HANDLER(ViewMsg_UserScripts_UpdatedScripts, OnUpdateUserScripts) // TODO(rafaelw): create an ExtensionDispatcher that handles extension // messages seperates their handling from the RenderThread. IPC_MESSAGE_HANDLER(ViewMsg_ExtensionMessageInvoke, OnExtensionMessageInvoke) IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetFunctionNames, OnSetExtensionFunctionNames) - IPC_MESSAGE_HANDLER(ViewMsg_ExtensionLoaded, - OnExtensionLoaded) - IPC_MESSAGE_HANDLER(ViewMsg_ExtensionUnloaded, - OnExtensionUnloaded) + IPC_MESSAGE_HANDLER(ViewMsg_ExtensionLoaded, OnExtensionLoaded) + IPC_MESSAGE_HANDLER(ViewMsg_ExtensionUnloaded, OnExtensionUnloaded) IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetScriptingWhitelist, OnSetExtensionScriptingWhitelist) IPC_MESSAGE_HANDLER(ViewMsg_PurgeMemory, OnPurgeMemory) - IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, - OnPurgePluginListCache) + IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, OnPurgePluginListCache) IPC_MESSAGE_HANDLER(ViewMsg_Extension_UpdatePageActions, OnPageActionsUpdated) IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetAPIPermissions, OnExtensionSetAPIPermissions) IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetHostPermissions, OnExtensionSetHostPermissions) - IPC_MESSAGE_HANDLER(DOMStorageMsg_Event, - OnDOMStorageEvent) - IPC_MESSAGE_HANDLER(ViewMsg_SpellChecker_Init, - OnInitSpellChecker) - IPC_MESSAGE_HANDLER(ViewMsg_SpellChecker_WordAdded, - OnSpellCheckWordAdded) - IPC_MESSAGE_HANDLER(ViewMsg_SpellChecker_EnableAutoSpellCorrect, + IPC_MESSAGE_HANDLER(DOMStorageMsg_Event, OnDOMStorageEvent) + IPC_MESSAGE_HANDLER(SpellCheckMsg_Init, OnInitSpellChecker) + IPC_MESSAGE_HANDLER(SpellCheckMsg_WordAdded, OnSpellCheckWordAdded) + IPC_MESSAGE_HANDLER(SpellCheckMsg_EnableAutoSpellCorrect, OnSpellCheckEnableAutoSpellCorrect) IPC_MESSAGE_HANDLER(GpuMsg_GpuChannelEstablished, OnGpuChannelEstablished) IPC_MESSAGE_HANDLER(SafeBrowsingMsg_SetPhishingModel, OnSetPhishingModel) diff --git a/chrome/renderer/spellchecker/spellcheck.cc b/chrome/renderer/spellchecker/spellcheck.cc index 4220f4a..9c700ae 100644 --- a/chrome/renderer/spellchecker/spellcheck.cc +++ b/chrome/renderer/spellchecker/spellcheck.cc @@ -8,8 +8,8 @@ #include "base/metrics/histogram.h" #include "base/time.h" #include "base/utf_string_conversions.h" -#include "chrome/common/render_messages.h" #include "chrome/common/spellcheck_common.h" +#include "chrome/common/spellcheck_messages.h" #include "chrome/renderer/render_thread.h" #include "third_party/hunspell/src/hunspell/hunspell.hxx" @@ -198,8 +198,7 @@ bool SpellCheck::InitializeIfNeeded() { return false; if (!initialized_) { - RenderThread::current()->Send( - new ViewHostMsg_SpellChecker_RequestDictionary); + RenderThread::current()->Send(new SpellCheckHostMsg_RequestDictionary); initialized_ = true; return true; } @@ -218,8 +217,8 @@ bool SpellCheck::CheckSpelling(const string16& word_to_check, int tag) { if (is_using_platform_spelling_engine_) { RenderThread::current()->Send( - new ViewHostMsg_SpellChecker_PlatformCheckSpelling(word_to_check, tag, - &word_correct)); + new SpellCheckHostMsg_PlatformCheckSpelling(word_to_check, tag, + &word_correct)); } else { std::string word_to_check_utf8(UTF16ToUTF8(word_to_check)); // Hunspell shouldn't let us exceed its max, but check just in case @@ -244,7 +243,7 @@ void SpellCheck::FillSuggestionList( std::vector<string16>* optional_suggestions) { if (is_using_platform_spelling_engine_) { RenderThread::current()->Send( - new ViewHostMsg_SpellChecker_PlatformFillSuggestionList( + new SpellCheckHostMsg_PlatformFillSuggestionList( wrong_word, optional_suggestions)); return; } diff --git a/chrome/renderer/spellchecker/spellcheck_provider.cc b/chrome/renderer/spellchecker/spellcheck_provider.cc index 779844d..da06c1e 100644 --- a/chrome/renderer/spellchecker/spellcheck_provider.cc +++ b/chrome/renderer/spellchecker/spellcheck_provider.cc @@ -4,9 +4,10 @@ #include "chrome/renderer/spellchecker/spellcheck_provider.h" -#include "chrome/common/render_messages.h" +#include "chrome/common/spellcheck_messages.h" #include "chrome/renderer/render_thread.h" #include "chrome/renderer/spellchecker/spellcheck.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingCompletion.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingResult.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" @@ -38,14 +39,14 @@ void SpellCheckProvider::RequestTextChecking( return; } - Send(new ViewHostMsg_SpellChecker_PlatformRequestTextCheck( + Send(new SpellCheckHostMsg_PlatformRequestTextCheck( routing_id(), text_check_completions_.Add(completion), document_tag, text)); } -void SpellCheckProvider::OnSpellCheckerRespondTextCheck( +void SpellCheckProvider::OnRespondTextCheck( int identifier, int tag, const std::vector<WebTextCheckingResult>& results) { @@ -60,8 +61,7 @@ void SpellCheckProvider::OnSpellCheckerRespondTextCheck( bool SpellCheckProvider::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(SpellCheckProvider, message) - IPC_MESSAGE_HANDLER(ViewMsg_SpellChecker_RespondTextCheck, - OnSpellCheckerRespondTextCheck) + IPC_MESSAGE_HANDLER(SpellCheckMsg_RespondTextCheck, OnRespondTextCheck) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; diff --git a/chrome/renderer/spellchecker/spellcheck_provider.h b/chrome/renderer/spellchecker/spellcheck_provider.h index b774e35..7157f11 100644 --- a/chrome/renderer/spellchecker/spellcheck_provider.h +++ b/chrome/renderer/spellchecker/spellcheck_provider.h @@ -29,7 +29,7 @@ class SpellCheckProvider : public RenderViewObserver { SpellCheckProvider(RenderView* render_view, SpellCheck* spellcheck); virtual ~SpellCheckProvider(); - // Reqeusts async spell and grammar checker to the platform text + // Requests async spell and grammar checker to the platform text // checker, which is available on the browser process. void RequestTextChecking( const WebKit::WebString& text, @@ -50,7 +50,7 @@ class SpellCheckProvider : public RenderViewObserver { private: // A message handler that receives async results for RequestTextChecking(). - void OnSpellCheckerRespondTextCheck( + void OnRespondTextCheck( int identifier, int tag, const std::vector<WebKit::WebTextCheckingResult>& results); diff --git a/chrome/renderer/spellchecker/spellcheck_provider_unittest.cc b/chrome/renderer/spellchecker/spellcheck_provider_unittest.cc index bb63f19..bb6b7ab 100644 --- a/chrome/renderer/spellchecker/spellcheck_provider_unittest.cc +++ b/chrome/renderer/spellchecker/spellcheck_provider_unittest.cc @@ -5,9 +5,10 @@ #include <vector> #include "base/utf_string_conversions.h" -#include "chrome/common/render_messages.h" +#include "chrome/common/spellcheck_messages.h" #include "chrome/renderer/spellchecker/spellcheck_provider.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingCompletion.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingResult.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" @@ -84,7 +85,7 @@ struct MessageParameters { MessageParameters ReadPlatformRequestTextCheck(IPC::Message* message) { MessageParameters parameters; - bool ok = ViewHostMsg_SpellChecker_PlatformRequestTextCheck::Read( + bool ok = SpellCheckHostMsg_PlatformRequestTextCheck::Read( message, ¶meters.router_id, ¶meters.request_id, @@ -98,11 +99,11 @@ void FakeMessageArrival(SpellCheckProvider* provider, const MessageParameters& parameters) { std::vector<WebKit::WebTextCheckingResult> fake_result; bool handled = provider->OnMessageReceived( - ViewMsg_SpellChecker_RespondTextCheck - (0, - parameters.request_id, - parameters.document_tag, - fake_result)); + SpellCheckMsg_RespondTextCheck( + 0, + parameters.request_id, + parameters.document_tag, + fake_result)); EXPECT_TRUE(handled); } |