Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(545)

Side by Side Diff: components/spellcheck/renderer/spellcheck_provider.h

Issue 2791753003: Split WebTextCheckClient off WebSpellCheckClient (Closed)
Patch Set: Add TODOs for class renaming Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 COMPONENTS_SPELLCHECK_RENDERER_SPELLCHECK_PROVIDER_H_ 5 #ifndef COMPONENTS_SPELLCHECK_RENDERER_SPELLCHECK_PROVIDER_H_
6 #define COMPONENTS_SPELLCHECK_RENDERER_SPELLCHECK_PROVIDER_H_ 6 #define COMPONENTS_SPELLCHECK_RENDERER_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 "components/spellcheck/spellcheck_build_features.h" 15 #include "components/spellcheck/spellcheck_build_features.h"
16 #include "content/public/renderer/render_view_observer.h" 16 #include "content/public/renderer/render_view_observer.h"
17 #include "content/public/renderer/render_view_observer_tracker.h" 17 #include "content/public/renderer/render_view_observer_tracker.h"
18 #include "third_party/WebKit/public/web/WebSpellCheckClient.h" 18 #include "third_party/WebKit/public/web/WebSpellCheckClient.h"
19 #include "third_party/WebKit/public/web/WebTextCheckClient.h"
19 20
20 class RenderView; 21 class RenderView;
21 class SpellCheck; 22 class SpellCheck;
22 struct SpellCheckResult; 23 struct SpellCheckResult;
23 24
24 namespace blink { 25 namespace blink {
25 class WebString;
26 class WebTextCheckingCompletion; 26 class WebTextCheckingCompletion;
27 struct WebTextCheckingResult; 27 struct WebTextCheckingResult;
28 } 28 }
29 29
30 // This class deals with invoking browser-side spellcheck mechanism 30 // This class deals with invoking browser-side spellcheck mechanism
31 // which is done asynchronously. 31 // which is done asynchronously.
32 // TODO(xiaochengh): Split this class to implement WebSpellCheckClient and
33 // WebTextCheckClient separately.
32 class SpellCheckProvider 34 class SpellCheckProvider
33 : public content::RenderViewObserver, 35 : public content::RenderViewObserver,
34 public content::RenderViewObserverTracker<SpellCheckProvider>, 36 public content::RenderViewObserverTracker<SpellCheckProvider>,
35 public blink::WebSpellCheckClient { 37 public blink::WebSpellCheckClient,
38 public blink::WebTextCheckClient {
36 public: 39 public:
37 using WebTextCheckCompletions = IDMap<blink::WebTextCheckingCompletion*>; 40 using WebTextCheckCompletions = IDMap<blink::WebTextCheckingCompletion*>;
38 41
39 SpellCheckProvider(content::RenderView* render_view, 42 SpellCheckProvider(content::RenderView* render_view,
40 SpellCheck* spellcheck); 43 SpellCheck* spellcheck);
41 ~SpellCheckProvider() override; 44 ~SpellCheckProvider() override;
42 45
43 // Requests async spell and grammar checker to the platform text 46 // Requests async spell and grammar checker to the platform text
44 // checker, which is available on the browser process. The function does not 47 // checker, which is available on the browser process. The function does not
45 // have special handling for partial words, as Blink guarantees that no 48 // have special handling for partial words, as Blink guarantees that no
(...skipping 21 matching lines...) Expand all
67 70
68 // Tries to satisfy a spell check request from the cache in |last_request_|. 71 // Tries to satisfy a spell check request from the cache in |last_request_|.
69 // Returns true (and cancels/finishes the completion) if it can, false 72 // Returns true (and cancels/finishes the completion) if it can, false
70 // if the provider should forward the query on. 73 // if the provider should forward the query on.
71 bool SatisfyRequestFromCache(const base::string16& text, 74 bool SatisfyRequestFromCache(const base::string16& text,
72 blink::WebTextCheckingCompletion* completion); 75 blink::WebTextCheckingCompletion* completion);
73 76
74 // RenderViewObserver implementation. 77 // RenderViewObserver implementation.
75 void OnDestruct() override; 78 void OnDestruct() override;
76 79
77 // blink::WebSpellCheckClient implementation. 80 // blink::WebTextCheckClient implementation.
78 void checkSpelling( 81 void checkSpelling(
79 const blink::WebString& text, 82 const blink::WebString& text,
80 int& offset, 83 int& offset,
81 int& length, 84 int& length,
82 blink::WebVector<blink::WebString>* optional_suggestions) override; 85 blink::WebVector<blink::WebString>* optional_suggestions) override;
83
84 void requestCheckingOfText( 86 void requestCheckingOfText(
85 const blink::WebString& text, 87 const blink::WebString& text,
86 blink::WebTextCheckingCompletion* completion) override; 88 blink::WebTextCheckingCompletion* completion) override;
89 void cancelAllPendingRequests() override;
87 90
88 void cancelAllPendingRequests() override; 91 // blink::WebSpellCheckClient implementation.
89 void showSpellingUI(bool show) override; 92 void showSpellingUI(bool show) override;
90 bool isShowingSpellingUI() override; 93 bool isShowingSpellingUI() override;
91 void updateSpellingUIWithMisspelledWord( 94 void updateSpellingUIWithMisspelledWord(
92 const blink::WebString& word) override; 95 const blink::WebString& word) override;
93 96
94 #if !BUILDFLAG(USE_BROWSER_SPELLCHECKER) 97 #if !BUILDFLAG(USE_BROWSER_SPELLCHECKER)
95 void OnRespondSpellingService( 98 void OnRespondSpellingService(
96 int identifier, 99 int identifier,
97 bool succeeded, 100 bool succeeded,
98 const base::string16& text, 101 const base::string16& text,
(...skipping 24 matching lines...) Expand all
123 // True if the browser is showing the spelling panel for us. 126 // True if the browser is showing the spelling panel for us.
124 bool spelling_panel_visible_; 127 bool spelling_panel_visible_;
125 128
126 // Weak pointer to shared (per RenderView) spellcheck data. 129 // Weak pointer to shared (per RenderView) spellcheck data.
127 SpellCheck* spellcheck_; 130 SpellCheck* spellcheck_;
128 131
129 DISALLOW_COPY_AND_ASSIGN(SpellCheckProvider); 132 DISALLOW_COPY_AND_ASSIGN(SpellCheckProvider);
130 }; 133 };
131 134
132 #endif // COMPONENTS_SPELLCHECK_RENDERER_SPELLCHECK_PROVIDER_H_ 135 #endif // COMPONENTS_SPELLCHECK_RENDERER_SPELLCHECK_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698