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

Unified Diff: chrome/renderer/render_view.cc

Issue 6392045: Integrating Mac OS Grammar checker into Chromium. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated the patch to catch up WebKit side changes. Created 9 years, 10 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
Index: chrome/renderer/render_view.cc
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index f5c808b5f56893b365d378664b121d7677bce2f1..1b893b08bd1e22b007da680050c2c49c75a54bc3 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -147,6 +147,8 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.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/WebURL.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h"
@@ -260,6 +262,7 @@ using WebKit::WebSize;
using WebKit::WebStorageNamespace;
using WebKit::WebString;
using WebKit::WebTextAffinity;
+using WebKit::WebTextCheckingResult;
using WebKit::WebTextDirection;
using WebKit::WebURL;
using WebKit::WebURLError;
@@ -992,6 +995,8 @@ bool RenderView::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ViewMsg_AdvanceToNextMisspelling,
OnAdvanceToNextMisspelling)
IPC_MESSAGE_HANDLER(ViewMsg_ToggleSpellCheck, OnToggleSpellCheck)
+ IPC_MESSAGE_HANDLER(ViewMsg_SpellChecker_RespondTextCheck,
+ OnRespondTextCheck);
IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete)
IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll)
IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt)
@@ -1595,6 +1600,39 @@ void RenderView::OnToggleSpellPanel(bool is_currently_visible) {
WebString::fromUTF8("ToggleSpellPanel"));
}
+static WebVector<WebTextCheckingResult> toWebResults(
+ const TextCheckingResultList& results) {
+ std::vector<WebTextCheckingResult> webResults;
+ for (size_t i = 0; i < results.size(); ++i) {
+ switch (results[i].type) {
+ case TextCheckingResult::MISSPELLING:
+ webResults.push_back(WebTextCheckingResult(
+ WebTextCheckingResult::ErrorSpelling,
+ results[i].location, results[i].length));
+ break;
+ case TextCheckingResult::BAD_GRAMMAR:
+ webResults.push_back(WebTextCheckingResult(
+ WebTextCheckingResult::ErrorGrammar,
+ results[i].location, results[i].length));
+ break;
+ default:
+ break;
+ }
+ }
+
+ return webResults;
+}
+
+void RenderView::OnRespondTextCheck(
+ int identifier, int tag, const TextCheckingResultList& results) {
+ WebKit::WebTextCheckingCompletion* completion =
+ text_check_completions_.Lookup(identifier);
+ if (!completion)
+ return;
+ text_check_completions_.Remove(identifier);
+ completion->didFinishCheckingText(toWebResults(results));
Hironori Bono 2011/02/09 05:43:51 Out of curiosity, who deletes this 'completion' ob
gmorrita 2011/02/10 02:15:21 didFinishCheckingText() removes |this| at the end
+}
+
void RenderView::OnToggleSpellCheck() {
if (!webview())
return;
@@ -2335,6 +2373,18 @@ void RenderView::spellCheck(const WebString& text,
}
}
+void RenderView::requestCheckingOfText(
+ const WebString& text,
+ WebKit::WebTextCheckingCompletion* completion) {
+ // Text check (unified request for grammar and spell check) is only
Hironori Bono 2011/02/09 05:43:51 it may be a good idea to enclose this block with '
gmorrita 2011/02/10 02:15:21 Absolutely. Moved to spellchecker.cc
+ // available for browser process, so we do IPC instead of
+ // asking the Spellchecker.
+ int32 id = text_check_completions_.Add(completion);
+ Send(new ViewHostMsg_SpellChecker_RequestTextCheck(
+ routing_id_, routing_id_, id, document_tag_,
+ string16(text)));
+}
+
WebString RenderView::autoCorrectWord(const WebKit::WebString& word) {
string16 autocorrect_word;
const CommandLine& command_line = *CommandLine::ForCurrentProcess();

Powered by Google App Engine
This is Rietveld 408576698