diff options
author | morrita@chromium.org <morrita@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-22 09:00:13 +0000 |
---|---|---|
committer | morrita@chromium.org <morrita@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-22 09:00:13 +0000 |
commit | 5efcef635ea9483b64d4ba096ae3b922b2fa4ec2 (patch) | |
tree | a634f4704419113d707e25925e2076d238c62327 /chrome/renderer/spellchecker/spellcheck_provider.h | |
parent | 71bb51210b29a5546679b9c8be2990f3254f3d08 (diff) | |
download | chromium_src-5efcef635ea9483b64d4ba096ae3b922b2fa4ec2.zip chromium_src-5efcef635ea9483b64d4ba096ae3b922b2fa4ec2.tar.gz chromium_src-5efcef635ea9483b64d4ba096ae3b922b2fa4ec2.tar.bz2 |
Integrating Mac OS Grammar checker into Chromium.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6392045
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75577 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/spellchecker/spellcheck_provider.h')
-rw-r--r-- | chrome/renderer/spellchecker/spellcheck_provider.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/chrome/renderer/spellchecker/spellcheck_provider.h b/chrome/renderer/spellchecker/spellcheck_provider.h new file mode 100644 index 0000000..9496dda --- /dev/null +++ b/chrome/renderer/spellchecker/spellcheck_provider.h @@ -0,0 +1,66 @@ +// 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. + +#ifndef CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_PROVIDER_H_ +#define CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_PROVIDER_H_ +#pragma once + +#include <vector> + +#include "base/id_map.h" +#include "chrome/renderer/render_view_observer.h" + +class RenderView; +class SpellCheck; + +namespace WebKit { +class WebString; +class WebTextCheckingResult; +class WebTextCheckingCompletion; +} + +// This class deals with invoking browser-side spellcheck mechanism +// which is done asynchronously. +class SpellCheckProvider : public RenderViewObserver { + public: + typedef IDMap<WebKit::WebTextCheckingCompletion> WebTextCheckCompletions; + + SpellCheckProvider(RenderView* render_view, SpellCheck* spellcheck); + virtual ~SpellCheckProvider(); + + // Reqeusts async spell and grammar checker to the platform text + // checker, which is available on the browser process. + void RequestTextChecking( + const WebKit::WebString& text, + int document_tag, + WebKit::WebTextCheckingCompletion* completion); + + // Check the availability of the platform spellchecker. + // Makes this virtual for overriding on the unittest. + virtual bool is_using_platform_spelling_engine() const; + + // The number of ongoing IPC requests. + size_t pending_text_request_size() const { + return text_check_completions_.size(); + } + + // RenderViewObserver implementation. + virtual bool OnMessageReceived(const IPC::Message& message); + + private: + // A message handler that receives async results for RequestTextChecking(). + void OnSpellCheckerRespondTextCheck( + int identifier, + int tag, + const std::vector<WebKit::WebTextCheckingResult>& results); + + // Holds ongoing spellchecking operations, assigns IDs for the IPC routing. + WebTextCheckCompletions text_check_completions_; + // Spellcheck implementation for use. Weak reference. + SpellCheck* spellcheck_; + + DISALLOW_COPY_AND_ASSIGN(SpellCheckProvider); +}; + +#endif // CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_PROVIDER_H_ |