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

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

Issue 1948343002: [reland] Browser Side Text Input State Tracking for OOPIF (Aura Only) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merged Created 4 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_
6 #define CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_
7
8 #include <string>
9 #include <unordered_map>
10 #include <vector>
11
12 #include "base/callback.h"
13 #include "ui/base/ime/text_input_mode.h"
14 #include "ui/base/ime/text_input_type.h"
15
16 namespace content {
17
18 class RenderWidgetHostView;
19 class RenderWidgetHostViewBase;
20 class WebContents;
21 struct TextInputState;
22
23 // This class is intended to track TextInputState from TextInputManager.
24 class TestTextInputManagerObserver {
25 public:
26 using Callback = base::Callback<void(TestTextInputManagerObserver*)>;
27
28 virtual ~TestTextInputManagerObserver();
29
30 // static
31 static std::unique_ptr<TestTextInputManagerObserver> Create(
32 WebContents* web_contents);
33 // static
34 static std::unordered_map<const RenderWidgetHostView*, ui::TextInputType>
35 GetTextInputTypeMap(WebContents* web_contents);
36
37 virtual void SetUpdateCallback(const Callback& callback) {}
38 virtual ui::TextInputType GetTextInputType() const = 0;
39 virtual bool GetTextInputValue(std::string& value) const = 0;
40 virtual const RenderWidgetHostView* GetActiveView() const = 0;
41 virtual const RenderWidgetHostView* GetUpdatedView() const = 0;
42 virtual bool IsTextInputStateChanged() const = 0;
43 };
44
45 class RenderWidgetHostViewDestructionObserver {
46 public:
47 virtual ~RenderWidgetHostViewDestructionObserver();
48 // static
49 static std::unique_ptr<RenderWidgetHostViewDestructionObserver> Create(
50 RenderWidgetHostView* view);
51
52 virtual void Wait() = 0;
53 };
54
55 ui::TextInputType GetTextInputTypeFromWebContents(WebContents* web_contents);
56
57 RenderWidgetHostView* GetActiveViewFromWebContents(WebContents* web_contents);
58
59 // Helper class to create TextInputState structs on the browser side and send it
60 // to the |view|.
61 class TextInputStateSender {
62 public:
63 explicit TextInputStateSender(RenderWidgetHostView* view);
64 virtual ~TextInputStateSender();
65
66 void Send();
67
68 void SetFromCurrentState();
69
70 // Adding the required setter methods.
71 void SetType(ui::TextInputType type);
72 void SetMode(ui::TextInputMode mode);
73 void SetFlags(int flags);
74 void SetCanComposeInline(bool can_compose_inline);
75 void SetShowImeIfNeeded(bool show_ime_if_needed);
76 void SetIsNonImeChange(bool is_non_ime_change);
77
78 private:
79 std::unique_ptr<TextInputState> text_input_state_;
80 RenderWidgetHostViewBase* const view_;
81
82 DISALLOW_COPY_AND_ASSIGN(TextInputStateSender);
83 };
84
85 // This class is intended to observe the InputMethod.
86 class TestInputMethodObserver {
87 public:
88 // static
89 static std::unique_ptr<TestInputMethodObserver> Create(
90 WebContents* web_contents);
91
92 virtual ~TestInputMethodObserver();
93
94 virtual ui::TextInputType GetTextInputTypeFromClient() const = 0;
95
96 virtual void SetOnTextInputTypeChangedCallback(
97 const base::Closure& callback) = 0;
98 virtual void SetOnShowImeIfNeededCallback(const base::Closure& callback) = 0;
99 };
100
101 } // namespace content
102
103 #endif // CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698