summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc60
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.h3
-rw-r--r--chrome/browser/renderer_host/render_process_host.h3
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc4
-rw-r--r--chrome/browser/renderer_host/render_view_host.h1
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc80
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.h11
7 files changed, 33 insertions, 129 deletions
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index 1f630af..e9bfedb 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -40,16 +40,15 @@
#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"
#include "chrome/common/child_process_info.h"
#include "chrome/common/child_process_host.h"
#include "chrome/common/logging_chrome.h"
#include "chrome/common/notification_service.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/common/process_watcher.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/result_codes.h"
#include "chrome/renderer/render_process.h"
@@ -199,15 +198,12 @@ BrowserRenderProcessHost::BrowserRenderProcessHost(Profile* profile)
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
+ registrar_.Add(this, NotificationType::SPELLCHECK_AUTOSPELL_TOGGLED,
+ NotificationService::AllSources());
visited_link_updater_.reset(new VisitedLinkUpdater());
@@ -221,11 +217,6 @@ BrowserRenderProcessHost::BrowserRenderProcessHost(Profile* profile)
}
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());
@@ -277,7 +268,6 @@ bool BrowserRenderProcessHost::Init(bool is_extensions_process,
g_browser_process->print_job_manager(),
profile(),
widget_helper_,
- profile()->GetSpellChecker(),
request_context);
// Find the renderer before creating the channel so if this fails early we
@@ -394,15 +384,6 @@ void BrowserRenderProcessHost::WidgetHidden() {
}
}
-void BrowserRenderProcessHost::AddWord(const string16& word) {
- SpellChecker* spellchecker = profile()->GetSpellChecker();
- if (spellchecker) {
- ChromeThread::PostTask(
- ChromeThread::IO, FROM_HERE,
- NewRunnableMethod(spellchecker, &SpellChecker::AddWord, word));
- }
-}
-
void BrowserRenderProcessHost::SendVisitedLinkTable(
base::SharedMemory* table_memory) {
// Check if the process is still starting and we don't have a handle for it
@@ -762,10 +743,8 @@ void BrowserRenderProcessHost::OnMessageReceived(const IPC::Message& msg) {
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()
@@ -900,7 +879,6 @@ void BrowserRenderProcessHost::Observe(NotificationType type,
}
break;
}
-#if defined(SPELLCHECKER_IN_RENDERER)
case NotificationType::SPELLCHECK_HOST_REINITIALIZED: {
InitSpellChecker();
break;
@@ -911,18 +889,12 @@ void BrowserRenderProcessHost::Observe(NotificationType type,
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.
+ case NotificationType::SPELLCHECK_AUTOSPELL_TOGGLED: {
+ PrefService* prefs = profile()->GetPrefs();
+ EnableAutoSpellCorrect(
+ prefs->GetBoolean(prefs::kEnableAutoSpellCorrect));
+ break;
}
-#endif
default: {
NOTREACHED();
break;
@@ -937,14 +909,12 @@ void BrowserRenderProcessHost::OnProcessLaunched() {
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)
Send(new ViewMsg_SetNextPageID(max_page_id_ + 1));
@@ -981,7 +951,6 @@ void BrowserRenderProcessHost::OnExtensionCloseChannel(int 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.
@@ -997,12 +966,16 @@ void BrowserRenderProcessHost::InitSpellChecker() {
if (spellcheck_host) {
PrefService* prefs = profile()->GetPrefs();
IPC::PlatformFileForTransit file;
+
+ if (spellcheck_host->bdict_file() != base::kInvalidPlatformFileValue) {
#if defined(OS_POSIX)
- file = base::FileDescriptor(spellcheck_host->bdict_file(), false);
+ file = base::FileDescriptor(spellcheck_host->bdict_file(), false);
#elif defined(OS_WIN)
- ::DuplicateHandle(::GetCurrentProcess(), spellcheck_host->bdict_file(),
- GetHandle(), &file, 0, false, DUPLICATE_SAME_ACCESS);
+ ::DuplicateHandle(::GetCurrentProcess(), spellcheck_host->bdict_file(),
+ GetHandle(), &file, 0, false, DUPLICATE_SAME_ACCESS);
#endif
+ }
+
Send(new ViewMsg_SpellChecker_Init(
file,
spellcheck_host->custom_words(),
@@ -1020,4 +993,3 @@ void BrowserRenderProcessHost::InitSpellChecker() {
void BrowserRenderProcessHost::EnableAutoSpellCorrect(bool enable) {
Send(new ViewMsg_SpellChecker_EnableAutoSpellCorrect(enable));
}
-#endif
diff --git a/chrome/browser/renderer_host/browser_render_process_host.h b/chrome/browser/renderer_host/browser_render_process_host.h
index 4ab6c73..fae3145 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.h
+++ b/chrome/browser/renderer_host/browser_render_process_host.h
@@ -70,7 +70,6 @@ class BrowserRenderProcessHost : public RenderProcessHost,
virtual void WidgetRestored();
virtual void WidgetHidden();
virtual void ViewCreated();
- virtual void AddWord(const string16& word);
virtual void SendVisitedLinkTable(base::SharedMemory* table_memory);
virtual void AddVisitedLinks(const VisitedLinkCommon::Fingerprints& links);
virtual void ResetVisitedLinks();
@@ -142,7 +141,6 @@ class BrowserRenderProcessHost : public RenderProcessHost,
// Returns true if the priority is backgrounded; false otherwise.
void SetBackgrounded(bool boost);
-#if defined(SPELLCHECKER_IN_RENDERER)
// 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
@@ -159,7 +157,6 @@ class BrowserRenderProcessHost : public RenderProcessHost,
// Tell the renderer that auto spell correction has been enabled/disabled.
void EnableAutoSpellCorrect(bool enable);
-#endif
NotificationRegistrar registrar_;
diff --git a/chrome/browser/renderer_host/render_process_host.h b/chrome/browser/renderer_host/render_process_host.h
index 0914a52..0edf46c 100644
--- a/chrome/browser/renderer_host/render_process_host.h
+++ b/chrome/browser/renderer_host/render_process_host.h
@@ -173,9 +173,6 @@ class RenderProcessHost : public IPC::Channel::Sender,
// Called when RenderView is created by a listener.
virtual void ViewCreated() = 0;
- // Add a word in the spellchecker.
- virtual void AddWord(const string16& word) = 0;
-
// Informs the renderer about a new visited link table.
virtual void SendVisitedLinkTable(base::SharedMemory* table_memory) = 0;
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 6b3307c..b414aea 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -542,10 +542,6 @@ void RenderViewHost::ToggleSpellCheck() {
Send(new ViewMsg_ToggleSpellCheck(routing_id()));
}
-void RenderViewHost::AddToDictionary(const string16& word) {
- process()->AddWord(word);
-}
-
void RenderViewHost::Delete() {
Send(new ViewMsg_Delete(routing_id()));
}
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 4b03af0..4aae99b 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -277,7 +277,6 @@ class RenderViewHost : public RenderWidgetHost,
void CopyToFindPboard();
void Paste();
void ToggleSpellCheck();
- void AddToDictionary(const string16& word);
void Delete();
void SelectAll();
void ToggleSpellPanel(bool is_currently_visible);
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index 93ee409..b03118d 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -31,7 +31,6 @@
#include "chrome/browser/renderer_host/database_dispatcher_host.h"
#include "chrome/browser/renderer_host/render_widget_helper.h"
#include "chrome/browser/renderer_host/socket_stream_dispatcher_host.h"
-#include "chrome/browser/spellchecker.h"
#include "chrome/browser/spellchecker_platform_engine.h"
#include "chrome/browser/task_manager.h"
#include "chrome/browser/worker_host/message_port_dispatcher.h"
@@ -150,14 +149,12 @@ ResourceMessageFilter::ResourceMessageFilter(
printing::PrintJobManager* print_job_manager,
Profile* profile,
RenderWidgetHelper* render_widget_helper,
- SpellChecker* spellchecker,
URLRequestContextGetter* request_context)
: Receiver(RENDER_PROCESS, child_id),
channel_(NULL),
resource_dispatcher_host_(resource_dispatcher_host),
plugin_service_(plugin_service),
print_job_manager_(print_job_manager),
- spellchecker_(spellchecker),
ALLOW_THIS_IN_INITIALIZER_LIST(resolve_proxy_msg_helper_(this, NULL)),
request_context_(request_context),
media_request_context_(profile->GetRequestContextForMedia()),
@@ -214,8 +211,6 @@ void ResourceMessageFilter::OnFilterAdded(IPC::Channel* channel) {
channel_ = channel;
// Add the observers to intercept.
- registrar_.Add(this, NotificationType::SPELLCHECKER_REINITIALIZED,
- Source<Profile>(static_cast<Profile*>(profile_)));
registrar_.Add(this, NotificationType::BLACKLIST_BLOCKED_RESOURCE,
NotificationService::AllSources());
}
@@ -317,13 +312,14 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& msg) {
OnCancelCreateDedicatedWorker)
IPC_MESSAGE_HANDLER(ViewHostMsg_ForwardToWorker,
OnForwardToWorker)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_SpellCheck, OnSpellCheck)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_SpellChecker_PlatformCheckSpelling,
+ OnPlatformCheckSpelling)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_SpellChecker_PlatformFillSuggestionList,
+ OnPlatformFillSuggestionList)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetDocumentTag,
OnGetDocumentTag)
IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentWithTagClosed,
OnDocumentWithTagClosed)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetAutoCorrectWord,
- OnGetAutoCorrectWord)
IPC_MESSAGE_HANDLER(ViewHostMsg_ShowSpellingPanel, OnShowSpellingPanel)
IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateSpellingPanelWithMisspelledWord,
OnUpdateSpellingPanelWithMisspelledWord)
@@ -420,21 +416,6 @@ void ResourceMessageFilter::OnReceiveContextMenuMsg(const IPC::Message& msg) {
if (!IPC::ParamTraits<ContextMenuParams>::Read(&msg, &iter, &params))
return;
- // Fill in the dictionary suggestions if required.
- if (!params.misspelled_word.empty() &&
- spellchecker_ != NULL && params.spellcheck_enabled) {
- int misspell_location, misspell_length;
- bool is_misspelled = !spellchecker_->SpellCheckWord(
- params.misspelled_word.c_str(),
- static_cast<int>(params.misspelled_word.length()), 0,
- &misspell_location, &misspell_length,
- &params.dictionary_suggestions);
-
- // If not misspelled, make the misspelled_word param empty.
- if (!is_misspelled)
- params.misspelled_word.clear();
- }
-
// Create a new ViewHostMsg_ContextMenu message.
const ViewHostMsg_ContextMenu context_menu_message(msg.routing_id(), params);
ChromeThread::PostTask(
@@ -1010,33 +991,16 @@ ResourceMessageFilter::GetRequestContextForURL(
context_getter->GetURLRequestContext());
}
-// Notes about SpellCheck.
-//
-// Spellchecking generally uses a fair amount of RAM. For this reason, we load
-// the spellcheck dictionaries into the browser process, and all renderers ask
-// the browsers to do SpellChecking.
-//
-// This filter should not try to initialize the spellchecker. It is up to the
-// profile to initialize it when required, and send it here. If |spellchecker_|
-// is made NULL, it corresponds to spellchecker turned off - i.e., all
-// spellings are correct.
-//
-// Note: This is called in the IO thread.
-void ResourceMessageFilter::OnSpellCheck(const string16& word, int tag,
- IPC::Message* reply_msg) {
- int misspell_location = 0;
- int misspell_length = 0;
-
- if (spellchecker_ != NULL) {
- spellchecker_->SpellCheckWord(word.c_str(),
- static_cast<int>(word.length()), tag,
- &misspell_location, &misspell_length, NULL);
- }
+void ResourceMessageFilter::OnPlatformCheckSpelling(const string16& word,
+ int tag,
+ bool* correct) {
+ *correct = SpellCheckerPlatform::CheckSpelling(word, tag);
+}
- ViewHostMsg_SpellCheck::WriteReplyParams(reply_msg, misspell_location,
- misspell_length);
- Send(reply_msg);
- return;
+void ResourceMessageFilter::OnPlatformFillSuggestionList(
+ const string16& word,
+ std::vector<string16>* suggestions) {
+ SpellCheckerPlatform::FillSuggestionList(word, suggestions);
}
void ResourceMessageFilter::OnGetDocumentTag(IPC::Message* reply_msg) {
@@ -1050,19 +1014,6 @@ void ResourceMessageFilter::OnDocumentWithTagClosed(int tag) {
SpellCheckerPlatform::CloseDocumentWithTag(tag);
}
-void ResourceMessageFilter::OnGetAutoCorrectWord(const string16& word,
- int tag,
- IPC::Message* reply_msg) {
- string16 autocorrect_word;
- if (spellchecker_ != NULL)
- autocorrect_word = spellchecker_->GetAutoCorrectionWord(word, tag);
-
- ViewHostMsg_GetAutoCorrectWord::WriteReplyParams(reply_msg,
- autocorrect_word);
- Send(reply_msg);
- return;
-}
-
void ResourceMessageFilter::OnShowSpellingPanel(bool show) {
SpellCheckerPlatform::ShowSpellingPanel(show);
}
@@ -1075,10 +1026,7 @@ void ResourceMessageFilter::OnUpdateSpellingPanelWithMisspelledWord(
void ResourceMessageFilter::Observe(NotificationType type,
const NotificationSource &source,
const NotificationDetails &details) {
- if (type == NotificationType::SPELLCHECKER_REINITIALIZED) {
- spellchecker_ = Details<SpellcheckerReinitializedDetails>
- (details).ptr()->spellchecker;
- } else if (type == NotificationType::BLACKLIST_BLOCKED_RESOURCE) {
+ if (type == NotificationType::BLACKLIST_BLOCKED_RESOURCE) {
BlacklistObserver::ContentBlocked(Details<const URLRequest>(details).ptr());
}
}
diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h
index 50507db..f2cb2df 100644
--- a/chrome/browser/renderer_host/resource_message_filter.h
+++ b/chrome/browser/renderer_host/resource_message_filter.h
@@ -87,7 +87,6 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
printing::PrintJobManager* print_job_manager,
Profile* profile,
RenderWidgetHelper* render_widget_helper,
- SpellChecker* spellchecker,
URLRequestContextGetter* request_context);
// IPC::ChannelProxy::MessageFilter methods:
@@ -104,7 +103,6 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
uint32 request_id,
const ViewHostMsg_Resource_Request& request_data);
- SpellChecker* spellchecker() { return spellchecker_.get(); }
ResourceDispatcherHost* resource_dispatcher_host() {
return resource_dispatcher_host_;
}
@@ -185,11 +183,11 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
void OnDownloadUrl(const IPC::Message& message,
const GURL& url,
const GURL& referrer);
- void OnSpellCheck(const string16& word, int tag, IPC::Message* reply_msg);
+ void OnPlatformCheckSpelling(const string16& word, int tag, bool* correct);
+ void OnPlatformFillSuggestionList(const string16& word,
+ std::vector<string16>* suggestions);
void OnGetDocumentTag(IPC::Message* reply_msg);
void OnDocumentWithTagClosed(int tag);
- void OnGetAutoCorrectWord(const string16& word, int tag,
- IPC::Message* reply_msg);
void OnShowSpellingPanel(bool show);
void OnUpdateSpellingPanelWithMisspelledWord(const string16& word);
void OnDnsPrefetch(const std::vector<std::string>& hostnames);
@@ -349,9 +347,6 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
// before this object, we only hold an ID for lookup.
int child_id_;
- // Our spellchecker object.
- scoped_refptr<SpellChecker> spellchecker_;
-
// Helper class for handling PluginProcessHost_ResolveProxy messages (manages
// the requests to the proxy service).
ResolveProxyMsgHelper resolve_proxy_msg_helper_;