| 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);
|
| + }
|
| +}
|
|
|