| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/id_map.h" | 13 #include "base/id_map.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "content/public/renderer/render_view_observer.h" | 15 #include "content/public/renderer/render_view_observer.h" |
| 16 #include "content/public/renderer/render_view_observer_tracker.h" | 16 #include "content/public/renderer/render_view_observer_tracker.h" |
| 17 #include "third_party/WebKit/public/web/WebSpellCheckClient.h" | 17 #include "third_party/WebKit/public/web/WebSpellCheckClient.h" |
| 18 | 18 |
| 19 class RenderView; | 19 class RenderView; |
| 20 class SpellCheck; | 20 class SpellCheck; |
| 21 class SpellCheckMarker; | |
| 22 struct SpellCheckResult; | 21 struct SpellCheckResult; |
| 23 | 22 |
| 24 namespace blink { | 23 namespace blink { |
| 25 class WebString; | 24 class WebString; |
| 26 class WebTextCheckingCompletion; | 25 class WebTextCheckingCompletion; |
| 27 struct WebTextCheckingResult; | 26 struct WebTextCheckingResult; |
| 28 } | 27 } |
| 29 | 28 |
| 30 // This class deals with invoking browser-side spellcheck mechanism | 29 // This class deals with invoking browser-side spellcheck mechanism |
| 31 // which is done asynchronously. | 30 // which is done asynchronously. |
| 32 class SpellCheckProvider | 31 class SpellCheckProvider |
| 33 : public content::RenderViewObserver, | 32 : public content::RenderViewObserver, |
| 34 public content::RenderViewObserverTracker<SpellCheckProvider>, | 33 public content::RenderViewObserverTracker<SpellCheckProvider>, |
| 35 public blink::WebSpellCheckClient { | 34 public blink::WebSpellCheckClient { |
| 36 public: | 35 public: |
| 37 typedef IDMap<blink::WebTextCheckingCompletion> WebTextCheckCompletions; | 36 typedef IDMap<blink::WebTextCheckingCompletion> WebTextCheckCompletions; |
| 38 | 37 |
| 39 SpellCheckProvider(content::RenderView* render_view, | 38 SpellCheckProvider(content::RenderView* render_view, |
| 40 SpellCheck* spellcheck); | 39 SpellCheck* spellcheck); |
| 41 ~SpellCheckProvider() override; | 40 ~SpellCheckProvider() override; |
| 42 | 41 |
| 43 // Requests async spell and grammar checker to the platform text | 42 // Requests async spell and grammar checker to the platform text |
| 44 // checker, which is available on the browser process. | 43 // checker, which is available on the browser process. |
| 45 void RequestTextChecking( | 44 void RequestTextChecking( |
| 46 const base::string16& text, | 45 const base::string16& text, |
| 47 blink::WebTextCheckingCompletion* completion, | 46 blink::WebTextCheckingCompletion* completion); |
| 48 const std::vector<SpellCheckMarker>& markers); | |
| 49 | 47 |
| 50 // The number of ongoing IPC requests. | 48 // The number of ongoing IPC requests. |
| 51 size_t pending_text_request_size() const { | 49 size_t pending_text_request_size() const { |
| 52 return text_check_completions_.size(); | 50 return text_check_completions_.size(); |
| 53 } | 51 } |
| 54 | 52 |
| 55 // Replace shared spellcheck data. | 53 // Replace shared spellcheck data. |
| 56 void set_spellcheck(SpellCheck* spellcheck) { spellcheck_ = spellcheck; } | 54 void set_spellcheck(SpellCheck* spellcheck) { spellcheck_ = spellcheck; } |
| 57 | 55 |
| 58 // Enables document-wide spellchecking. | 56 // Enables document-wide spellchecking. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 80 int& offset, | 78 int& offset, |
| 81 int& length, | 79 int& length, |
| 82 blink::WebVector<blink::WebString>* optional_suggestions) override; | 80 blink::WebVector<blink::WebString>* optional_suggestions) override; |
| 83 void checkTextOfParagraph( | 81 void checkTextOfParagraph( |
| 84 const blink::WebString& text, | 82 const blink::WebString& text, |
| 85 blink::WebTextCheckingTypeMask mask, | 83 blink::WebTextCheckingTypeMask mask, |
| 86 blink::WebVector<blink::WebTextCheckingResult>* results) override; | 84 blink::WebVector<blink::WebTextCheckingResult>* results) override; |
| 87 | 85 |
| 88 void requestCheckingOfText( | 86 void requestCheckingOfText( |
| 89 const blink::WebString& text, | 87 const blink::WebString& text, |
| 90 const blink::WebVector<uint32_t>& markers, | |
| 91 const blink::WebVector<unsigned>& marker_offsets, | |
| 92 blink::WebTextCheckingCompletion* completion) override; | 88 blink::WebTextCheckingCompletion* completion) override; |
| 93 | 89 |
| 94 void showSpellingUI(bool show) override; | 90 void showSpellingUI(bool show) override; |
| 95 bool isShowingSpellingUI() override; | 91 bool isShowingSpellingUI() override; |
| 96 void updateSpellingUIWithMisspelledWord( | 92 void updateSpellingUIWithMisspelledWord( |
| 97 const blink::WebString& word) override; | 93 const blink::WebString& word) override; |
| 98 | 94 |
| 99 #if !defined(USE_BROWSER_SPELLCHECKER) | 95 #if !defined(USE_BROWSER_SPELLCHECKER) |
| 100 void OnRespondSpellingService( | 96 void OnRespondSpellingService( |
| 101 int identifier, | 97 int identifier, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 128 // True if the browser is showing the spelling panel for us. | 124 // True if the browser is showing the spelling panel for us. |
| 129 bool spelling_panel_visible_; | 125 bool spelling_panel_visible_; |
| 130 | 126 |
| 131 // Weak pointer to shared (per RenderView) spellcheck data. | 127 // Weak pointer to shared (per RenderView) spellcheck data. |
| 132 SpellCheck* spellcheck_; | 128 SpellCheck* spellcheck_; |
| 133 | 129 |
| 134 DISALLOW_COPY_AND_ASSIGN(SpellCheckProvider); | 130 DISALLOW_COPY_AND_ASSIGN(SpellCheckProvider); |
| 135 }; | 131 }; |
| 136 | 132 |
| 137 #endif // CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_PROVIDER_H_ | 133 #endif // CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_PROVIDER_H_ |
| OLD | NEW |