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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/renderer/spellchecker/spellcheck_provider.h"
6
7 #include "chrome/common/render_messages.h"
8 #include "chrome/renderer/render_thread.h"
9 #include "chrome/renderer/spellchecker/spellcheck.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingComple tion.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingResult .h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h"
13
14 using WebKit::WebString;
15 using WebKit::WebTextCheckingCompletion;
16 using WebKit::WebTextCheckingResult;
17
18 SpellCheckProvider::SpellCheckProvider(RenderView* render_view,
19 SpellCheck* spellcheck)
20 : RenderViewObserver(render_view),
21 spellcheck_(spellcheck) {
22 }
23
24 SpellCheckProvider::~SpellCheckProvider() {
25 }
26
27 void SpellCheckProvider::RequestTextChecking(
28 const WebString& text,
29 int document_tag,
30 WebTextCheckingCompletion* completion) {
31 // Text check (unified request for grammar and spell check) is only
32 // available for browser process, so we ask the system sellchecker
33 // over IPC or return an empty result if the checker is not
34 // available.
35 if (!is_using_platform_spelling_engine()) {
36 completion->didFinishCheckingText
37 (std::vector<WebTextCheckingResult>());
38 return;
39 }
40
41 Send(new ViewHostMsg_SpellChecker_PlatformRequestTextCheck(
42 routing_id(),
43 text_check_completions_.Add(completion),
44 document_tag,
45 text));
46 }
47
48 void SpellCheckProvider::OnSpellCheckerRespondTextCheck(
49 int identifier,
50 int tag,
51 const std::vector<WebTextCheckingResult>& results) {
52 WebKit::WebTextCheckingCompletion* completion =
53 text_check_completions_.Lookup(identifier);
54 if (!completion)
55 return;
56 text_check_completions_.Remove(identifier);
57 completion->didFinishCheckingText(results);
58 }
59
60 bool SpellCheckProvider::OnMessageReceived(const IPC::Message& message) {
61 bool handled = true;
62 IPC_BEGIN_MESSAGE_MAP(SpellCheckProvider, message)
63 IPC_MESSAGE_HANDLER(ViewMsg_SpellChecker_RespondTextCheck,
64 OnSpellCheckerRespondTextCheck)
65 IPC_MESSAGE_UNHANDLED(handled = false)
66 IPC_END_MESSAGE_MAP()
67 return handled;
68 }
69
70 bool SpellCheckProvider::is_using_platform_spelling_engine() const {
71 return spellcheck_ && spellcheck_->is_using_platform_spelling_engine();
72 }
OLDNEW
« 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