| 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" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 // which is done asynchronously. | 27 // which is done asynchronously. |
| 28 class SpellCheckProvider | 28 class SpellCheckProvider |
| 29 : public content::RenderViewObserver, | 29 : public content::RenderViewObserver, |
| 30 public content::RenderViewObserverTracker<SpellCheckProvider>, | 30 public content::RenderViewObserverTracker<SpellCheckProvider>, |
| 31 public blink::WebSpellCheckClient { | 31 public blink::WebSpellCheckClient { |
| 32 public: | 32 public: |
| 33 typedef IDMap<blink::WebTextCheckingCompletion> WebTextCheckCompletions; | 33 typedef IDMap<blink::WebTextCheckingCompletion> WebTextCheckCompletions; |
| 34 | 34 |
| 35 SpellCheckProvider(content::RenderView* render_view, | 35 SpellCheckProvider(content::RenderView* render_view, |
| 36 SpellCheck* spellcheck); | 36 SpellCheck* spellcheck); |
| 37 virtual ~SpellCheckProvider(); | 37 ~SpellCheckProvider() override; |
| 38 | 38 |
| 39 // Requests async spell and grammar checker to the platform text | 39 // Requests async spell and grammar checker to the platform text |
| 40 // checker, which is available on the browser process. | 40 // checker, which is available on the browser process. |
| 41 void RequestTextChecking( | 41 void RequestTextChecking( |
| 42 const base::string16& text, | 42 const base::string16& text, |
| 43 blink::WebTextCheckingCompletion* completion, | 43 blink::WebTextCheckingCompletion* completion, |
| 44 const std::vector<SpellCheckMarker>& markers); | 44 const std::vector<SpellCheckMarker>& markers); |
| 45 | 45 |
| 46 // The number of ongoing IPC requests. | 46 // The number of ongoing IPC requests. |
| 47 size_t pending_text_request_size() const { | 47 size_t pending_text_request_size() const { |
| 48 return text_check_completions_.size(); | 48 return text_check_completions_.size(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 // Replace shared spellcheck data. | 51 // Replace shared spellcheck data. |
| 52 void set_spellcheck(SpellCheck* spellcheck) { spellcheck_ = spellcheck; } | 52 void set_spellcheck(SpellCheck* spellcheck) { spellcheck_ = spellcheck; } |
| 53 | 53 |
| 54 // Enables document-wide spellchecking. | 54 // Enables document-wide spellchecking. |
| 55 void EnableSpellcheck(bool enabled); | 55 void EnableSpellcheck(bool enabled); |
| 56 | 56 |
| 57 // RenderViewObserver implementation. | 57 // RenderViewObserver implementation. |
| 58 virtual bool OnMessageReceived(const IPC::Message& message) override; | 58 bool OnMessageReceived(const IPC::Message& message) override; |
| 59 virtual void FocusedNodeChanged(const blink::WebNode& node) override; | 59 void FocusedNodeChanged(const blink::WebNode& node) override; |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 friend class TestingSpellCheckProvider; | 62 friend class TestingSpellCheckProvider; |
| 63 | 63 |
| 64 // Tries to satisfy a spell check request from the cache in |last_request_|. | 64 // Tries to satisfy a spell check request from the cache in |last_request_|. |
| 65 // Returns true (and cancels/finishes the completion) if it can, false | 65 // Returns true (and cancels/finishes the completion) if it can, false |
| 66 // if the provider should forward the query on. | 66 // if the provider should forward the query on. |
| 67 bool SatisfyRequestFromCache(const base::string16& text, | 67 bool SatisfyRequestFromCache(const base::string16& text, |
| 68 blink::WebTextCheckingCompletion* completion); | 68 blink::WebTextCheckingCompletion* completion); |
| 69 | 69 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 // True if the browser is showing the spelling panel for us. | 122 // True if the browser is showing the spelling panel for us. |
| 123 bool spelling_panel_visible_; | 123 bool spelling_panel_visible_; |
| 124 | 124 |
| 125 // Weak pointer to shared (per RenderView) spellcheck data. | 125 // Weak pointer to shared (per RenderView) spellcheck data. |
| 126 SpellCheck* spellcheck_; | 126 SpellCheck* spellcheck_; |
| 127 | 127 |
| 128 DISALLOW_COPY_AND_ASSIGN(SpellCheckProvider); | 128 DISALLOW_COPY_AND_ASSIGN(SpellCheckProvider); |
| 129 }; | 129 }; |
| 130 | 130 |
| 131 #endif // CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_PROVIDER_H_ | 131 #endif // CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_PROVIDER_H_ |
| OLD | NEW |