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

Side by Side Diff: content/public/test/text_input_test_utils.h

Issue 2132633002: Tracking composition range on the browser side (Aura) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments Created 4 years, 5 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 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 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "ui/base/ime/text_input_mode.h" 11 #include "ui/base/ime/text_input_mode.h"
12 #include "ui/base/ime/text_input_type.h" 12 #include "ui/base/ime/text_input_type.h"
13 13
14 namespace ui {
15
Charlie Reis 2016/07/11 23:56:19 nit: No blank line here, as in text_input_manager.
EhsanK 2016/07/12 18:31:14 Acknowledged.
16 struct CompositionText;
17 } // namespace ui
Charlie Reis 2016/07/11 23:56:19 nit: No close comment needed on something this sim
EhsanK 2016/07/12 18:31:14 Acknowledged.
18
14 namespace content { 19 namespace content {
15 20
16 class RenderWidgetHostView; 21 class RenderWidgetHostView;
17 class RenderWidgetHostViewBase; 22 class RenderWidgetHostViewBase;
18 class WebContents; 23 class WebContents;
19 struct TextInputState; 24 struct TextInputState;
20 25
21 // Returns the |TextInputState.type| from the TextInputManager owned by 26 // Returns the |TextInputState.type| from the TextInputManager owned by
22 // |web_contents|. 27 // |web_contents|.
23 ui::TextInputType GetTextInputTypeFromWebContents(WebContents* web_contents); 28 ui::TextInputType GetTextInputTypeFromWebContents(WebContents* web_contents);
24 29
25 // This method returns true if |view| is registered in the TextInputManager that 30 // This method returns true if |view| is registered in the TextInputManager that
26 // is owned by |web_contents|. If that is the case, the value of |type| will be 31 // is owned by |web_contents|. If that is the case, the value of |type| will be
27 // the |TextInputState.type| corresponding to the |view|. Returns false if 32 // the |TextInputState.type| corresponding to the |view|. Returns false if
28 // |view| is not registered. 33 // |view| is not registered.
29 bool GetTextInputTypeForView(WebContents* web_contents, 34 bool GetTextInputTypeForView(WebContents* web_contents,
30 RenderWidgetHostView* view, 35 RenderWidgetHostView* view,
31 ui::TextInputType* type); 36 ui::TextInputType* type);
32 37
33 // This method returns the number of RenderWidgetHostViews which are currently 38 // This method returns the number of RenderWidgetHostViews which are currently
34 // registered with the TextInputManager that is owned by |web_contents|. 39 // registered with the TextInputManager that is owned by |web_contents|.
35 size_t GetRegisteredViewsCountFromTextInputManager(WebContents* web_contents); 40 size_t GetRegisteredViewsCountFromTextInputManager(WebContents* web_contents);
36 41
37 // Returns the RWHV corresponding to the frame with a focused <input> within the 42 // Returns the RWHV corresponding to the frame with a focused <input> within the
38 // given WebContents. 43 // given WebContents.
39 RenderWidgetHostView* GetActiveViewFromWebContents(WebContents* web_contents); 44 RenderWidgetHostView* GetActiveViewFromWebContents(WebContents* web_contents);
40 45
46 // This method will use |web_contents| to find the tab's RenderWidgetHostView
47 // and then uses that to send an IPC to set composition to the currently
Charlie Reis 2016/07/11 23:56:19 nit: s/uses/use/
EhsanK 2016/07/12 18:31:14 Done.
48 // active RenderWidgetHost.
49 void SetCompositionTextForFocusedTextInputClient(
50 WebContents* web_contents,
51 const ui::CompositionText& composition);
52
41 // This class provides the necessary API for accessing the state of and also 53 // This class provides the necessary API for accessing the state of and also
42 // observing the TextInputManager for WebContents. 54 // observing the TextInputManager for WebContents.
43 class TextInputManagerTester { 55 class TextInputManagerTester {
44 public: 56 public:
45 TextInputManagerTester(WebContents* web_contents); 57 TextInputManagerTester(WebContents* web_contents);
46 virtual ~TextInputManagerTester(); 58 virtual ~TextInputManagerTester();
47 59
48 // Sets a callback which is invoked when a RWHV calls UpdateTextInputState 60 // Sets a callback which is invoked when a RWHV calls UpdateTextInputState
49 // on the TextInputManager which is being observed. 61 // on the TextInputManager which is being observed.
50 void SetUpdateTextInputStateCalledCallback(const base::Closure& callback); 62 void SetUpdateTextInputStateCalledCallback(const base::Closure& callback);
51 63
52 // Sets a callback which is invoked when a RWHV calls SelectionBoundsChanged 64 // Sets a callback which is invoked when a RWHV calls SelectionBoundsChanged
53 // on the TextInputManager which is being observed. 65 // on the TextInputManager which is being observed.
54 void SetOnSelectionBoundsChangedCallback(const base::Closure& callback); 66 void SetOnSelectionBoundsChangedCallback(const base::Closure& callback);
55 67
68 // Sets a callback which is invoked when a RWHV calls
69 // ImeCompositionRangeChanged on the TextInputManager that is being observed.
70 void SetOnImeCompositionRangeChangedCallback(const base::Closure& callback);
71
56 // Returns true if there is a focused <input> and populates |type| with 72 // Returns true if there is a focused <input> and populates |type| with
57 // |TextInputState.type| of the TextInputManager. 73 // |TextInputState.type| of the TextInputManager.
58 bool GetTextInputType(ui::TextInputType* type); 74 bool GetTextInputType(ui::TextInputType* type);
59 75
60 // Returns true if there is a focused <input> and populates |value| with 76 // Returns true if there is a focused <input> and populates |value| with
61 // |TextInputState.value| of the TextInputManager. 77 // |TextInputState.value| of the TextInputManager.
62 bool GetTextInputValue(std::string* value); 78 bool GetTextInputValue(std::string* value);
63 79
64 // Returns the RenderWidgetHostView with a focused <input> element or nullptr 80 // Returns the RenderWidgetHostView with a focused <input> element or nullptr
65 // if none exists. 81 // if none exists.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 const base::Closure& callback) = 0; 163 const base::Closure& callback) = 0;
148 virtual void SetOnShowImeIfNeededCallback(const base::Closure& callback) = 0; 164 virtual void SetOnShowImeIfNeededCallback(const base::Closure& callback) = 0;
149 165
150 protected: 166 protected:
151 TestInputMethodObserver(); 167 TestInputMethodObserver();
152 }; 168 };
153 169
154 } // namespace content 170 } // namespace content
155 171
156 #endif // CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ 172 #endif // CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698