summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorrouslan@chromium.org <rouslan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-02 02:04:20 +0000
committerrouslan@chromium.org <rouslan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-02 02:04:20 +0000
commit633210c8a8e9c6cd698a854f760651bd568c9a40 (patch)
treee1c1cd028e093797c289944d6f3ae27c12212b69 /chrome/renderer
parent15a6a6a4fbfa3542bd936ab55cc0cf2719e35c48 (diff)
downloadchromium_src-633210c8a8e9c6cd698a854f760651bd568c9a40.zip
chromium_src-633210c8a8e9c6cd698a854f760651bd568c9a40.tar.gz
chromium_src-633210c8a8e9c6cd698a854f760651bd568c9a40.tar.bz2
Periodically request a list of spellcheck markers in all renderers for feedback
This CL adds a class SpellingServiceFeedback that will be used for sending feedback to the spelling service. There's one instance of this class per profile. SpellcheckService owns the SpellingServiceFeedback instance. SpellingServiceFeedback periodically requests a list of all document markers in the renderers. It will use the list to determine the kinds of feedback to send to the spelling service. BUG=170514 Review URL: https://chromiumcodereview.appspot.com/14126015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@197779 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/spellchecker/spellcheck.cc35
-rw-r--r--chrome/renderer/spellchecker/spellcheck.h2
2 files changed, 36 insertions, 1 deletions
diff --git a/chrome/renderer/spellchecker/spellcheck.cc b/chrome/renderer/spellchecker/spellcheck.cc
index da4fbde..8ae805f 100644
--- a/chrome/renderer/spellchecker/spellcheck.cc
+++ b/chrome/renderer/spellchecker/spellcheck.cc
@@ -13,10 +13,12 @@
#include "chrome/common/spellcheck_result.h"
#include "chrome/renderer/spellchecker/spellcheck_language.h"
#include "chrome/renderer/spellchecker/spellcheck_provider.h"
+#include "content/public/renderer/render_thread.h"
#include "content/public/renderer/render_view.h"
#include "content/public/renderer/render_view_visitor.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/WebView.h"
using WebKit::WebVector;
using WebKit::WebTextCheckingResult;
@@ -41,6 +43,30 @@ bool UpdateSpellcheckEnabled::Visit(content::RenderView* render_view) {
return true;
}
+class DocumentMarkersCollector : public content::RenderViewVisitor {
+ public:
+ DocumentMarkersCollector() {}
+ virtual ~DocumentMarkersCollector() {}
+ const std::vector<uint32>& markers() const { return markers_; }
+ virtual bool Visit(content::RenderView* render_view) OVERRIDE;
+
+ private:
+ std::vector<uint32> markers_;
+ DISALLOW_COPY_AND_ASSIGN(DocumentMarkersCollector);
+};
+
+bool DocumentMarkersCollector::Visit(content::RenderView* render_view) {
+ if (!render_view || !render_view->GetWebView())
+ return true;
+ WebVector<uint32> markers;
+ // TODO(rouslan): Call spellingMarkers() after Blink DEPS roll:
+ // render_view->GetWebView()->spellingMarkers(&markers);
+ for (size_t i = 0; i < markers.size(); ++i)
+ markers_.push_back(markers[i]);
+ // Visit all render views.
+ return true;
+}
+
} // namespace
class SpellCheck::SpellcheckRequest {
@@ -96,6 +122,8 @@ bool SpellCheck::OnControlMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(SpellCheckMsg_EnableAutoSpellCorrect,
OnEnableAutoSpellCorrect)
IPC_MESSAGE_HANDLER(SpellCheckMsg_EnableSpellCheck, OnEnableSpellCheck)
+ IPC_MESSAGE_HANDLER(SpellCheckMsg_RequestDocumentMarkers,
+ OnRequestDocumentMarkers)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -130,6 +158,13 @@ void SpellCheck::OnEnableSpellCheck(bool enable) {
content::RenderView::ForEach(&updater);
}
+void SpellCheck::OnRequestDocumentMarkers() {
+ DocumentMarkersCollector collector;
+ content::RenderView::ForEach(&collector);
+ content::RenderThread::Get()->Send(
+ new SpellCheckHostMsg_RespondDocumentMarkers(collector.markers()));
+}
+
// TODO(groby): Make sure we always have a spelling engine, even before Init()
// is called.
void SpellCheck::Init(base::PlatformFile file,
diff --git a/chrome/renderer/spellchecker/spellcheck.h b/chrome/renderer/spellchecker/spellcheck.h
index 3e14b2f..58032be 100644
--- a/chrome/renderer/spellchecker/spellcheck.h
+++ b/chrome/renderer/spellchecker/spellcheck.h
@@ -127,7 +127,7 @@ class SpellCheck : public content::RenderProcessObserver,
const std::vector<std::string>& words_removed);
void OnEnableAutoSpellCorrect(bool enable);
void OnEnableSpellCheck(bool enable);
-
+ void OnRequestDocumentMarkers();
#if !defined (OS_MACOSX)
// Posts delayed spellcheck task and clear it if any.