| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/id_map.h" | 10 #include "base/id_map.h" |
| 11 #include "content/public/renderer/render_view_observer.h" | 11 #include "content/public/renderer/render_view_observer.h" |
| 12 #include "content/public/renderer/render_view_observer_tracker.h" | 12 #include "content/public/renderer/render_view_observer_tracker.h" |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSpellCheckClient.h
" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSpellCheckClient.h
" |
| 14 | 14 |
| 15 class RenderView; | 15 class RenderView; |
| 16 class SpellCheck; | 16 class SpellCheck; |
| 17 struct SpellCheckMarker; |
| 17 struct SpellCheckResult; | 18 struct SpellCheckResult; |
| 18 | 19 |
| 19 namespace WebKit { | 20 namespace WebKit { |
| 20 class WebString; | 21 class WebString; |
| 21 class WebTextCheckingCompletion; | 22 class WebTextCheckingCompletion; |
| 22 struct WebTextCheckingResult; | 23 struct WebTextCheckingResult; |
| 23 } | 24 } |
| 24 | 25 |
| 25 // This class deals with invoking browser-side spellcheck mechanism | 26 // This class deals with invoking browser-side spellcheck mechanism |
| 26 // which is done asynchronously. | 27 // which is done asynchronously. |
| 27 class SpellCheckProvider | 28 class SpellCheckProvider |
| 28 : public content::RenderViewObserver, | 29 : public content::RenderViewObserver, |
| 29 public content::RenderViewObserverTracker<SpellCheckProvider>, | 30 public content::RenderViewObserverTracker<SpellCheckProvider>, |
| 30 public WebKit::WebSpellCheckClient { | 31 public WebKit::WebSpellCheckClient { |
| 31 public: | 32 public: |
| 32 typedef IDMap<WebKit::WebTextCheckingCompletion> WebTextCheckCompletions; | 33 typedef IDMap<WebKit::WebTextCheckingCompletion> WebTextCheckCompletions; |
| 33 | 34 |
| 34 SpellCheckProvider(content::RenderView* render_view, | 35 SpellCheckProvider(content::RenderView* render_view, |
| 35 SpellCheck* spellcheck); | 36 SpellCheck* spellcheck); |
| 36 virtual ~SpellCheckProvider(); | 37 virtual ~SpellCheckProvider(); |
| 37 | 38 |
| 38 // Requests async spell and grammar checker to the platform text | 39 // Requests async spell and grammar checker to the platform text |
| 39 // checker, which is available on the browser process. | 40 // checker, which is available on the browser process. |
| 40 void RequestTextChecking( | 41 void RequestTextChecking( |
| 41 const WebKit::WebString& text, | 42 const WebKit::WebString& text, |
| 42 WebKit::WebTextCheckingCompletion* completion); | 43 WebKit::WebTextCheckingCompletion* completion, |
| 44 const std::vector<SpellCheckMarker>& markers); |
| 43 | 45 |
| 44 // The number of ongoing IPC requests. | 46 // The number of ongoing IPC requests. |
| 45 size_t pending_text_request_size() const { | 47 size_t pending_text_request_size() const { |
| 46 return text_check_completions_.size(); | 48 return text_check_completions_.size(); |
| 47 } | 49 } |
| 48 | 50 |
| 49 // Replace shared spellcheck data. | 51 // Replace shared spellcheck data. |
| 50 void set_spellcheck(SpellCheck* spellcheck) { spellcheck_ = spellcheck; } | 52 void set_spellcheck(SpellCheck* spellcheck) { spellcheck_ = spellcheck; } |
| 51 | 53 |
| 52 // Enables document-wide spellchecking. | 54 // Enables document-wide spellchecking. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // True if the browser is showing the spelling panel for us. | 122 // True if the browser is showing the spelling panel for us. |
| 121 bool spelling_panel_visible_; | 123 bool spelling_panel_visible_; |
| 122 | 124 |
| 123 // Weak pointer to shared (per RenderView) spellcheck data. | 125 // Weak pointer to shared (per RenderView) spellcheck data. |
| 124 SpellCheck* spellcheck_; | 126 SpellCheck* spellcheck_; |
| 125 | 127 |
| 126 DISALLOW_COPY_AND_ASSIGN(SpellCheckProvider); | 128 DISALLOW_COPY_AND_ASSIGN(SpellCheckProvider); |
| 127 }; | 129 }; |
| 128 | 130 |
| 129 #endif // CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_PROVIDER_H_ | 131 #endif // CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_PROVIDER_H_ |
| OLD | NEW |