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

Unified Diff: chrome/renderer/spellchecker/spellcheck_provider.cc

Issue 6392045: Integrating Mac OS Grammar checker into Chromium. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated to ToT 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/spellchecker/spellcheck_provider.cc
diff --git a/chrome/renderer/spellchecker/spellcheck_provider.cc b/chrome/renderer/spellchecker/spellcheck_provider.cc
new file mode 100644
index 0000000000000000000000000000000000000000..779844dd3b62e158ed20f110404a3b8f21bbbf39
--- /dev/null
+++ b/chrome/renderer/spellchecker/spellcheck_provider.cc
@@ -0,0 +1,72 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/spellchecker/spellcheck_provider.h"
+
+#include "chrome/common/render_messages.h"
+#include "chrome/renderer/render_thread.h"
+#include "chrome/renderer/spellchecker/spellcheck.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/WebVector.h"
+
+using WebKit::WebString;
+using WebKit::WebTextCheckingCompletion;
+using WebKit::WebTextCheckingResult;
+
+SpellCheckProvider::SpellCheckProvider(RenderView* render_view,
+ SpellCheck* spellcheck)
+ : RenderViewObserver(render_view),
+ spellcheck_(spellcheck) {
+}
+
+SpellCheckProvider::~SpellCheckProvider() {
+}
+
+void SpellCheckProvider::RequestTextChecking(
+ const WebString& text,
+ int document_tag,
+ WebTextCheckingCompletion* completion) {
+ // Text check (unified request for grammar and spell check) is only
+ // available for browser process, so we ask the system sellchecker
+ // over IPC or return an empty result if the checker is not
+ // available.
+ if (!is_using_platform_spelling_engine()) {
+ completion->didFinishCheckingText
+ (std::vector<WebTextCheckingResult>());
+ return;
+ }
+
+ Send(new ViewHostMsg_SpellChecker_PlatformRequestTextCheck(
+ routing_id(),
+ text_check_completions_.Add(completion),
+ document_tag,
+ text));
+}
+
+void SpellCheckProvider::OnSpellCheckerRespondTextCheck(
+ int identifier,
+ int tag,
+ const std::vector<WebTextCheckingResult>& results) {
+ WebKit::WebTextCheckingCompletion* completion =
+ text_check_completions_.Lookup(identifier);
+ if (!completion)
+ return;
+ text_check_completions_.Remove(identifier);
+ completion->didFinishCheckingText(results);
+}
+
+bool SpellCheckProvider::OnMessageReceived(const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(SpellCheckProvider, message)
+ IPC_MESSAGE_HANDLER(ViewMsg_SpellChecker_RespondTextCheck,
+ OnSpellCheckerRespondTextCheck)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+bool SpellCheckProvider::is_using_platform_spelling_engine() const {
+ return spellcheck_ && spellcheck_->is_using_platform_spelling_engine();
+}
« no previous file with comments | « chrome/renderer/spellchecker/spellcheck_provider.h ('k') | chrome/renderer/spellchecker/spellcheck_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698