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

Unified Diff: chrome/browser/spellcheck_message_filter.cc

Issue 6880320: Move code that talks to spellchecking out of content. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/spellcheck_message_filter.h ('k') | chrome/browser/spellcheck_message_filter_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/spellcheck_message_filter.cc
===================================================================
--- chrome/browser/spellcheck_message_filter.cc (revision 83517)
+++ chrome/browser/spellcheck_message_filter.cc (working copy)
@@ -4,17 +4,28 @@
#include "chrome/browser/spellcheck_message_filter.h"
+#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/spellcheck_host.h"
#include "chrome/browser/spellchecker_platform_engine.h"
#include "chrome/common/spellcheck_messages.h"
+#include "content/browser/renderer_host/render_process_host.h"
-SpellCheckMessageFilter::SpellCheckMessageFilter() {
+SpellCheckMessageFilter::SpellCheckMessageFilter(int render_process_id)
+ : render_process_id_(render_process_id) {
}
SpellCheckMessageFilter::~SpellCheckMessageFilter() {
}
+void SpellCheckMessageFilter::OverrideThreadForMessage(
+ const IPC::Message& message, BrowserThread::ID* thread) {
+ if (message.type() == SpellCheckHostMsg_RequestDictionary::ID)
+ *thread = BrowserThread::UI;
+}
+
bool SpellCheckMessageFilter::OnMessageReceived(const IPC::Message& message,
- bool* message_was_ok) {
+ bool* message_was_ok) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP_EX(SpellCheckMessageFilter, message, *message_was_ok)
IPC_MESSAGE_HANDLER(SpellCheckHostMsg_PlatformCheckSpelling,
@@ -30,6 +41,8 @@
OnUpdateSpellingPanelWithMisspelledWord)
IPC_MESSAGE_HANDLER(SpellCheckHostMsg_PlatformRequestTextCheck,
OnPlatformRequestTextCheck)
+ IPC_MESSAGE_HANDLER(SpellCheckHostMsg_RequestDictionary,
+ OnSpellCheckerRequestDictionary)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -72,3 +85,24 @@
SpellCheckerPlatform::RequestTextCheck(
route_id, identifier, document_tag, text, this);
}
+
+void SpellCheckMessageFilter::OnSpellCheckerRequestDictionary() {
+ RenderProcessHost* host = RenderProcessHost::FromID(render_process_id_);
+ if (!host)
+ return; // Teardown.
+ Profile* profile = host->profile();
+ // The renderer has requested that we initialize its spellchecker. This should
+ // generally only be called once per session, as after the first call, all
+ // future renderers will be passed the initialization information on startup
+ // (or when the dictionary changes in some way).
+ if (profile->GetSpellCheckHost()) {
+ // The spellchecker initialization already started and finished; just send
+ // it to the renderer.
+ profile->GetSpellCheckHost()->InitForRenderer(host);
+ } else {
+ // We may have gotten multiple requests from different renderers. We don't
+ // want to initialize multiple times in this case, so we set |force| to
+ // false.
+ profile->ReinitializeSpellCheckHost(false);
+ }
+}
« no previous file with comments | « chrome/browser/spellcheck_message_filter.h ('k') | chrome/browser/spellcheck_message_filter_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698