| Index: chrome/browser/renderer_host/browser_render_process_host.cc
|
| ===================================================================
|
| --- chrome/browser/renderer_host/browser_render_process_host.cc (revision 31117)
|
| +++ chrome/browser/renderer_host/browser_render_process_host.cc (working copy)
|
| @@ -40,6 +40,9 @@
|
| #include "chrome/browser/renderer_host/render_widget_host.h"
|
| #include "chrome/browser/renderer_host/resource_message_filter.h"
|
| #include "chrome/browser/renderer_host/web_cache_manager.h"
|
| +#if defined(SPELLCHECKER_IN_RENDERER)
|
| +#include "chrome/browser/spellcheck_host.h"
|
| +#endif
|
| #include "chrome/browser/spellchecker.h"
|
| #include "chrome/browser/visitedlink_master.h"
|
| #include "chrome/common/chrome_switches.h"
|
| @@ -203,6 +206,16 @@
|
|
|
| registrar_.Add(this, NotificationType::USER_SCRIPTS_UPDATED,
|
| NotificationService::AllSources());
|
| +#if defined(SPELLCHECKER_IN_RENDERER)
|
| + registrar_.Add(this, NotificationType::SPELLCHECK_HOST_REINITIALIZED,
|
| + NotificationService::AllSources());
|
| + registrar_.Add(this, NotificationType::SPELLCHECK_WORD_ADDED,
|
| + NotificationService::AllSources());
|
| +
|
| + PrefService* prefs = profile->GetPrefs();
|
| + prefs->AddPrefObserver(prefs::kEnableAutoSpellCorrect, this);
|
| +#endif
|
| +
|
| visited_link_updater_.reset(new VisitedLinkUpdater());
|
|
|
| WebCacheManager::GetInstance()->Add(id());
|
| @@ -215,6 +228,11 @@
|
| }
|
|
|
| BrowserRenderProcessHost::~BrowserRenderProcessHost() {
|
| +#if defined(SPELLCHECKER_IN_RENDERER)
|
| + PrefService* prefs = profile()->GetPrefs();
|
| + prefs->RemovePrefObserver(prefs::kEnableAutoSpellCorrect, this);
|
| +#endif
|
| +
|
| WebCacheManager::GetInstance()->Remove(id());
|
| ChildProcessSecurityPolicy::GetInstance()->Remove(id());
|
|
|
| @@ -348,6 +366,14 @@
|
| InitVisitedLinks();
|
| InitUserScripts();
|
| InitExtensions();
|
| +#if defined(SPELLCHECKER_IN_RENDERER)
|
| + // We don't want to initialize the spellchecker unless SpellCheckHost has been
|
| + // created. In InitSpellChecker(), we know if GetSpellCheckHost() is NULL
|
| + // then the spellchecker has been turned off, but here, we don't know if
|
| + // it's been turned off or just not loaded yet.
|
| + if (profile()->GetSpellCheckHost())
|
| + InitSpellChecker();
|
| +#endif
|
|
|
| if (max_page_id_ != -1)
|
| channel_->Send(new ViewMsg_SetNextPageID(max_page_id_ + 1));
|
| @@ -813,6 +839,10 @@
|
| OnExtensionRemoveListener)
|
| IPC_MESSAGE_HANDLER(ViewHostMsg_ExtensionCloseChannel,
|
| OnExtensionCloseChannel)
|
| +#if defined(SPELLCHECKER_IN_RENDERER)
|
| + IPC_MESSAGE_HANDLER(ViewHostMsg_SpellChecker_RequestDictionary,
|
| + OnSpellCheckerRequestDictionary)
|
| +#endif
|
| IPC_MESSAGE_UNHANDLED_ERROR()
|
| IPC_END_MESSAGE_MAP_EX()
|
|
|
| @@ -1019,6 +1049,29 @@
|
| }
|
| break;
|
| }
|
| +#if defined(SPELLCHECKER_IN_RENDERER)
|
| + case NotificationType::SPELLCHECK_HOST_REINITIALIZED: {
|
| + InitSpellChecker();
|
| + break;
|
| + }
|
| + case NotificationType::SPELLCHECK_WORD_ADDED: {
|
| + AddSpellCheckWord(
|
| + reinterpret_cast<const Source<SpellCheckHost>*>(&source)->
|
| + ptr()->last_added_word());
|
| + break;
|
| + }
|
| + case NotificationType::PREF_CHANGED: {
|
| + std::wstring* pref_name_in = Details<std::wstring>(details).ptr();
|
| + PrefService* prefs = Source<PrefService>(source).ptr();
|
| + DCHECK(pref_name_in && prefs);
|
| + if (*pref_name_in == prefs::kEnableAutoSpellCorrect) {
|
| + EnableAutoSpellCorrect(
|
| + prefs->GetBoolean(prefs::kEnableAutoSpellCorrect));
|
| + break;
|
| + }
|
| + // Fall through.
|
| + }
|
| +#endif
|
| default: {
|
| NOTREACHED();
|
| break;
|
| @@ -1047,3 +1100,34 @@
|
| profile()->GetExtensionMessageService()->CloseChannel(port_id);
|
| }
|
| }
|
| +
|
| +#if defined(SPELLCHECKER_IN_RENDERER)
|
| +void BrowserRenderProcessHost::OnSpellCheckerRequestDictionary() {
|
| + // 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);
|
| +}
|
| +
|
| +void BrowserRenderProcessHost::AddSpellCheckWord(const std::string& word) {
|
| + channel_->Send(new ViewMsg_SpellChecker_WordAdded(word));
|
| +}
|
| +
|
| +void BrowserRenderProcessHost::InitSpellChecker() {
|
| + SpellCheckHost* spellcheck_host = profile()->GetSpellCheckHost();
|
| + if (spellcheck_host) {
|
| + PrefService* prefs = profile()->GetPrefs();
|
| + channel_->Send(new ViewMsg_SpellChecker_Init(
|
| + spellcheck_host->bdict_fd(), spellcheck_host->custom_words(),
|
| + spellcheck_host->language(),
|
| + prefs->GetBoolean(prefs::kEnableAutoSpellCorrect)));
|
| + } else {
|
| + channel_->Send(new ViewMsg_SpellChecker_Init(
|
| + base::FileDescriptor(), std::vector<std::string>(), std::string(),
|
| + false));
|
| + }
|
| +}
|
| +
|
| +void BrowserRenderProcessHost::EnableAutoSpellCorrect(bool enable) {
|
| + channel_->Send(new ViewMsg_SpellChecker_EnableAutoSpellCorrect(enable));
|
| +}
|
| +#endif
|
|
|