| OLD | NEW |
| (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 #ifndef CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_PROVIDER_H_ |
| 6 #define CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_PROVIDER_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <vector> |
| 10 |
| 11 #include "base/id_map.h" |
| 12 #include "chrome/renderer/render_view_observer.h" |
| 13 |
| 14 class RenderView; |
| 15 class SpellCheck; |
| 16 |
| 17 namespace WebKit { |
| 18 class WebString; |
| 19 class WebTextCheckingResult; |
| 20 class WebTextCheckingCompletion; |
| 21 } |
| 22 |
| 23 // This class deals with invoking browser-side spellcheck mechanism |
| 24 // which is done asynchronously. |
| 25 class SpellCheckProvider : public RenderViewObserver { |
| 26 public: |
| 27 typedef IDMap<WebKit::WebTextCheckingCompletion> WebTextCheckCompletions; |
| 28 |
| 29 SpellCheckProvider(RenderView* render_view, SpellCheck* spellcheck); |
| 30 virtual ~SpellCheckProvider(); |
| 31 |
| 32 // Reqeusts async spell and grammar checker to the platform text |
| 33 // checker, which is available on the browser process. |
| 34 void RequestTextChecking( |
| 35 const WebKit::WebString& text, |
| 36 int document_tag, |
| 37 WebKit::WebTextCheckingCompletion* completion); |
| 38 |
| 39 // Check the availability of the platform spellchecker. |
| 40 // Makes this virtual for overriding on the unittest. |
| 41 virtual bool is_using_platform_spelling_engine() const; |
| 42 |
| 43 // The number of ongoing IPC requests. |
| 44 size_t pending_text_request_size() const { |
| 45 return text_check_completions_.size(); |
| 46 } |
| 47 |
| 48 // RenderViewObserver implementation. |
| 49 virtual bool OnMessageReceived(const IPC::Message& message); |
| 50 |
| 51 private: |
| 52 // A message handler that receives async results for RequestTextChecking(). |
| 53 void OnSpellCheckerRespondTextCheck( |
| 54 int identifier, |
| 55 int tag, |
| 56 const std::vector<WebKit::WebTextCheckingResult>& results); |
| 57 |
| 58 // Holds ongoing spellchecking operations, assigns IDs for the IPC routing. |
| 59 WebTextCheckCompletions text_check_completions_; |
| 60 // Spellcheck implementation for use. Weak reference. |
| 61 SpellCheck* spellcheck_; |
| 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(SpellCheckProvider); |
| 64 }; |
| 65 |
| 66 #endif // CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_PROVIDER_H_ |
| OLD | NEW |