OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ |
6 #define CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ | 6 #define CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
13 #include "ui/base/ime/text_input_mode.h" | 13 #include "ui/base/ime/text_input_mode.h" |
14 #include "ui/base/ime/text_input_type.h" | 14 #include "ui/base/ime/text_input_type.h" |
15 | 15 |
16 #ifdef OS_MACOSX | |
17 #include "content/public/browser/browser_message_filter.h" | |
18 #endif | |
19 | |
20 namespace ipc { | |
21 class Message; | |
22 } | |
23 | |
16 namespace gfx { | 24 namespace gfx { |
17 class Range; | 25 class Range; |
18 } | 26 } |
19 | 27 |
20 namespace ui { | 28 namespace ui { |
21 struct CompositionUnderline; | 29 struct CompositionUnderline; |
22 } | 30 } |
23 | 31 |
24 namespace content { | 32 namespace content { |
25 | 33 |
34 class MessageLoopRunner; | |
35 class RenderProcessHost; | |
26 class RenderWidgetHost; | 36 class RenderWidgetHost; |
27 class RenderWidgetHostView; | 37 class RenderWidgetHostView; |
28 class RenderWidgetHostViewBase; | 38 class RenderWidgetHostViewBase; |
29 class WebContents; | 39 class WebContents; |
30 struct TextInputState; | 40 struct TextInputState; |
31 | 41 |
32 // Returns the |TextInputState.type| from the TextInputManager owned by | 42 // Returns the |TextInputState.type| from the TextInputManager owned by |
33 // |web_contents|. | 43 // |web_contents|. |
34 ui::TextInputType GetTextInputTypeFromWebContents(WebContents* web_contents); | 44 ui::TextInputType GetTextInputTypeFromWebContents(WebContents* web_contents); |
35 | 45 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 virtual ui::TextInputType GetTextInputTypeFromClient() = 0; | 183 virtual ui::TextInputType GetTextInputTypeFromClient() = 0; |
174 | 184 |
175 virtual void SetOnTextInputTypeChangedCallback( | 185 virtual void SetOnTextInputTypeChangedCallback( |
176 const base::Closure& callback) = 0; | 186 const base::Closure& callback) = 0; |
177 virtual void SetOnShowImeIfNeededCallback(const base::Closure& callback) = 0; | 187 virtual void SetOnShowImeIfNeededCallback(const base::Closure& callback) = 0; |
178 | 188 |
179 protected: | 189 protected: |
180 TestInputMethodObserver(); | 190 TestInputMethodObserver(); |
181 }; | 191 }; |
182 | 192 |
193 #ifdef OS_MACOSX | |
194 // The test message filter for TextInputClientMac incoming messages from the | |
195 // renderer. | |
196 // NOTE: This filter should be added to the intended RenderProcessHost before | |
197 // the actual TextInputClientMessageFilter, otherwise, the messages | |
198 // will be handled and will never receive this filter. | |
199 class TestTextInputClientMessageFilter : public BrowserMessageFilter { | |
200 public: | |
201 // Creates the filter and adds itself to |host|. | |
202 TestTextInputClientMessageFilter(RenderProcessHost* host); | |
203 | |
204 // Wait until the IPC TextInputClientReplyMsg_GotStringForRange arrives. | |
205 void WaitForStringFromRange(); | |
206 | |
207 // BrowserMessageFilter overrides. | |
208 bool OnMessageReceived(const IPC::Message& message) override; | |
209 | |
210 RenderProcessHost* process() const { return host_; } | |
211 std::string string_from_range() { return string_from_range_; } | |
212 | |
213 private: | |
214 ~TestTextInputClientMessageFilter() override; | |
215 RenderProcessHost* const host_; | |
216 std::string string_from_range_; | |
217 bool received_string_from_range_; | |
218 scoped_refptr<MessageLoopRunner> message_loop_runner_; | |
219 | |
220 DISALLOW_COPY_AND_ASSIGN(TestTextInputClientMessageFilter); | |
221 }; | |
222 | |
223 // Requests the |tab_view| for the definition of the word identified by the | |
224 // given selection range. |range| identifies a word in the focused | |
225 // RenderWidgetHost underneath |tab_view| which may be different than the | |
226 // RenderWidgetHost corresponding to |tab_view|. | |
227 void AskForLookUpDictoinaryForRange(RenderWidgetHostView* tab_view, | |
228 const gfx::Range& range); | |
Avi (use Gerrit)
2016/10/07 21:11:26
Typo in the function name: "Dictionary"
EhsanK
2016/10/11 19:31:56
Thanks! Done.
| |
229 | |
230 // Returns the total count of NSWindows instances which belong to the currently | |
231 // running NSApplication. | |
232 size_t GetOpenNSWindowsCount(); | |
233 #endif | |
234 | |
183 } // namespace content | 235 } // namespace content |
184 | 236 |
185 #endif // CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ | 237 #endif // CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ |
OLD | NEW |