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

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

Issue 2828313002: Convert render process component common Spellcheck IPC to mojo (Closed)
Patch Set: Build fix. Created 3 years, 7 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
« no previous file with comments | « components/spellcheck/renderer/DEPS ('k') | components/spellcheck/renderer/spellcheck.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_H_ 5 #ifndef COMPONENTS_SPELLCHECK_RENDERER_SPELLCHECK_H_
6 #define COMPONENTS_SPELLCHECK_RENDERER_SPELLCHECK_H_ 6 #define COMPONENTS_SPELLCHECK_RENDERER_SPELLCHECK_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/files/file.h" 13 #include "base/files/file.h"
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/strings/string16.h" 17 #include "base/strings/string16.h"
18 #include "components/spellcheck/common/spellcheck.mojom.h"
18 #include "components/spellcheck/renderer/custom_dictionary_engine.h" 19 #include "components/spellcheck/renderer/custom_dictionary_engine.h"
19 #include "components/spellcheck/spellcheck_build_features.h" 20 #include "components/spellcheck/spellcheck_build_features.h"
20 #include "content/public/renderer/render_thread_observer.h" 21 #include "content/public/renderer/render_thread_observer.h"
22 #include "mojo/public/cpp/bindings/binding_set.h"
21 23
22 struct SpellCheckBDictLanguage;
23 class SpellcheckLanguage; 24 class SpellcheckLanguage;
24 struct SpellCheckResult; 25 struct SpellCheckResult;
25 26
26 namespace blink { 27 namespace blink {
27 class WebTextCheckingCompletion; 28 class WebTextCheckingCompletion;
28 struct WebTextCheckingResult; 29 struct WebTextCheckingResult;
29 template <typename T> class WebVector; 30 template <typename T> class WebVector;
30 } 31 }
31 32
32 namespace IPC { 33 namespace service_manager {
33 class Message; 34 struct BindSourceInfo;
34 } 35 }
35 36
36 // TODO(morrita): Needs reorg with SpellCheckProvider. 37 // TODO(morrita): Needs reorg with SpellCheckProvider.
37 // See http://crbug.com/73699. 38 // See http://crbug.com/73699.
38 // Shared spellchecking logic/data for a RenderProcess. All RenderViews use 39 // Shared spellchecking logic/data for a RenderProcess. All RenderViews use
39 // this object to perform spellchecking tasks. 40 // this object to perform spellchecking tasks.
40 class SpellCheck : public content::RenderThreadObserver, 41 class SpellCheck : public content::RenderThreadObserver,
41 public base::SupportsWeakPtr<SpellCheck> { 42 public base::SupportsWeakPtr<SpellCheck>,
43 public spellcheck::mojom::SpellChecker {
42 public: 44 public:
43 // TODO(groby): I wonder if this can be private, non-mac only. 45 // TODO(groby): I wonder if this can be private, non-mac only.
44 class SpellcheckRequest; 46 class SpellcheckRequest;
45 enum ResultFilter { 47 enum ResultFilter {
46 DO_NOT_MODIFY = 1, // Do not modify results. 48 DO_NOT_MODIFY = 1, // Do not modify results.
47 USE_NATIVE_CHECKER, // Use native checker to double-check. 49 USE_NATIVE_CHECKER, // Use native checker to double-check.
48 }; 50 };
49 51
50 SpellCheck(); 52 SpellCheck();
51 ~SpellCheck() override; 53 ~SpellCheck() override;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 RequestSpellCheckMultipleTimesWithoutInitialization); 116 RequestSpellCheckMultipleTimesWithoutInitialization);
115 117
116 // Evenly fill |optional_suggestions| with a maximum of |kMaxSuggestions| 118 // Evenly fill |optional_suggestions| with a maximum of |kMaxSuggestions|
117 // suggestions from |suggestions_list|. suggestions_list[i][j] is the j-th 119 // suggestions from |suggestions_list|. suggestions_list[i][j] is the j-th
118 // suggestion from the i-th language's suggestions. |optional_suggestions| 120 // suggestion from the i-th language's suggestions. |optional_suggestions|
119 // cannot be null. 121 // cannot be null.
120 static void FillSuggestions( 122 static void FillSuggestions(
121 const std::vector<std::vector<base::string16>>& suggestions_list, 123 const std::vector<std::vector<base::string16>>& suggestions_list,
122 std::vector<base::string16>* optional_suggestions); 124 std::vector<base::string16>* optional_suggestions);
123 125
124 // RenderThreadObserver implementation: 126 // Binds requests for the SpellChecker interface.
125 bool OnControlMessageReceived(const IPC::Message& message) override; 127 void SpellCheckerRequest(const service_manager::BindSourceInfo& source_info,
128 spellcheck::mojom::SpellCheckerRequest request);
126 129
127 // Message handlers. 130 // spellcheck::mojom::SpellChecker:
128 void OnInit(const std::vector<SpellCheckBDictLanguage>& bdict_languages, 131 void Initialize(
129 const std::set<std::string>& custom_words); 132 std::vector<spellcheck::mojom::SpellCheckBDictLanguagePtr> dictionaries,
130 void OnCustomDictionaryChanged(const std::set<std::string>& words_added, 133 const std::vector<std::string>& custom_words,
131 const std::set<std::string>& words_removed); 134 bool enable) override;
132 void OnEnableSpellCheck(bool enable); 135 void CustomDictionaryChanged(
136 const std::vector<std::string>& words_added,
137 const std::vector<std::string>& words_removed) override;
133 138
134 #if !BUILDFLAG(USE_BROWSER_SPELLCHECKER) 139 #if !BUILDFLAG(USE_BROWSER_SPELLCHECKER)
135 // Posts delayed spellcheck task and clear it if any. 140 // Posts delayed spellcheck task and clear it if any.
136 // Takes ownership of |request|. 141 // Takes ownership of |request|.
137 void PostDelayedSpellCheckTask(SpellcheckRequest* request); 142 void PostDelayedSpellCheckTask(SpellcheckRequest* request);
138 143
139 // Performs spell checking from the request queue. 144 // Performs spell checking from the request queue.
140 void PerformSpellCheck(SpellcheckRequest* request); 145 void PerformSpellCheck(SpellcheckRequest* request);
141 146
142 // The parameters of a pending background-spellchecking request. When WebKit 147 // The parameters of a pending background-spellchecking request. When WebKit
143 // sends a background-spellchecking request before initializing hunspell, 148 // sends a background-spellchecking request before initializing hunspell,
144 // we save its parameters and start spellchecking after we finish initializing 149 // we save its parameters and start spellchecking after we finish initializing
145 // hunspell. (When WebKit sends two or more requests, we cancel the previous 150 // hunspell. (When WebKit sends two or more requests, we cancel the previous
146 // requests so we do not have to use vectors.) 151 // requests so we do not have to use vectors.)
147 std::unique_ptr<SpellcheckRequest> pending_request_param_; 152 std::unique_ptr<SpellcheckRequest> pending_request_param_;
148 #endif 153 #endif
149 154
155 // Bindings for SpellChecker clients.
156 mojo::BindingSet<spellcheck::mojom::SpellChecker> spellchecker_bindings_;
157
150 // A vector of objects used to actually check spelling, one for each enabled 158 // A vector of objects used to actually check spelling, one for each enabled
151 // language. 159 // language.
152 std::vector<std::unique_ptr<SpellcheckLanguage>> languages_; 160 std::vector<std::unique_ptr<SpellcheckLanguage>> languages_;
153 161
154 // Custom dictionary spelling engine. 162 // Custom dictionary spelling engine.
155 CustomDictionaryEngine custom_dictionary_; 163 CustomDictionaryEngine custom_dictionary_;
156 164
157 // Remember state for spellchecking. 165 // Remember state for spellchecking.
158 bool spellcheck_enabled_; 166 bool spellcheck_enabled_;
159 167
160 DISALLOW_COPY_AND_ASSIGN(SpellCheck); 168 DISALLOW_COPY_AND_ASSIGN(SpellCheck);
161 }; 169 };
162 170
163 #endif // COMPONENTS_SPELLCHECK_RENDERER_SPELLCHECK_H_ 171 #endif // COMPONENTS_SPELLCHECK_RENDERER_SPELLCHECK_H_
OLDNEW
« no previous file with comments | « components/spellcheck/renderer/DEPS ('k') | components/spellcheck/renderer/spellcheck.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698