OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_PROVIDER_H_ | 5 #ifndef CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_PROVIDER_H_ |
6 #define CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_PROVIDER_H_ | 6 #define CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_PROVIDER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 // This class deals with invoking browser-side spellcheck mechanism | 23 // This class deals with invoking browser-side spellcheck mechanism |
24 // which is done asynchronously. | 24 // which is done asynchronously. |
25 class SpellCheckProvider : public RenderViewObserver { | 25 class SpellCheckProvider : public RenderViewObserver { |
26 public: | 26 public: |
27 typedef IDMap<WebKit::WebTextCheckingCompletion> WebTextCheckCompletions; | 27 typedef IDMap<WebKit::WebTextCheckingCompletion> WebTextCheckCompletions; |
28 | 28 |
29 SpellCheckProvider(RenderView* render_view, SpellCheck* spellcheck); | 29 SpellCheckProvider(RenderView* render_view, SpellCheck* spellcheck); |
30 virtual ~SpellCheckProvider(); | 30 virtual ~SpellCheckProvider(); |
31 | 31 |
32 // Requests 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. | 32 // Check the availability of the platform spellchecker. |
40 // Makes this virtual for overriding on the unittest. | 33 // Makes this virtual for overriding on the unittest. |
41 virtual bool is_using_platform_spelling_engine() const; | 34 virtual bool is_using_platform_spelling_engine() const; |
42 | 35 |
43 // The number of ongoing IPC requests. | 36 // The number of ongoing IPC requests. |
44 size_t pending_text_request_size() const { | 37 size_t pending_text_request_size() const { |
45 return text_check_completions_.size(); | 38 return text_check_completions_.size(); |
46 } | 39 } |
47 | 40 |
48 // RenderViewObserver implementation. | 41 // RenderViewObserver implementation. |
49 virtual bool OnMessageReceived(const IPC::Message& message); | 42 virtual bool OnMessageReceived(const IPC::Message& message); |
50 | 43 |
| 44 // Requests async spell and grammar checker to the platform text |
| 45 // checker, which is available on the browser process. |
| 46 virtual void RequestTextChecking( |
| 47 const WebKit::WebString& text, |
| 48 int document_tag, |
| 49 WebKit::WebTextCheckingCompletion* completion); |
| 50 |
51 private: | 51 private: |
52 // A message handler that receives async results for RequestTextChecking(). | 52 // A message handler that receives async results for RequestTextChecking(). |
53 void OnRespondTextCheck( | 53 void OnRespondTextCheck( |
54 int identifier, | 54 int identifier, |
55 int tag, | 55 int tag, |
56 const std::vector<WebKit::WebTextCheckingResult>& results); | 56 const std::vector<WebKit::WebTextCheckingResult>& results); |
57 | 57 |
58 // Holds ongoing spellchecking operations, assigns IDs for the IPC routing. | 58 // Holds ongoing spellchecking operations, assigns IDs for the IPC routing. |
59 WebTextCheckCompletions text_check_completions_; | 59 WebTextCheckCompletions text_check_completions_; |
60 // Spellcheck implementation for use. Weak reference. | 60 // Spellcheck implementation for use. Weak reference. |
61 SpellCheck* spellcheck_; | 61 SpellCheck* spellcheck_; |
62 | 62 |
63 DISALLOW_COPY_AND_ASSIGN(SpellCheckProvider); | 63 DISALLOW_COPY_AND_ASSIGN(SpellCheckProvider); |
64 }; | 64 }; |
65 | 65 |
66 #endif // CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_PROVIDER_H_ | 66 #endif // CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_PROVIDER_H_ |
OLD | NEW |