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

Side by Side Diff: content/browser/android/ime_adapter_android.h

Issue 2792063003: Factor out RenderWidgetHostConnector (Closed)
Patch Set: RenderWidgetHostConnnector 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_BROWSER_ANDROID_IME_ADAPTER_ANDROID_H_ 5 #ifndef CONTENT_BROWSER_ANDROID_IME_ADAPTER_ANDROID_H_
6 #define CONTENT_BROWSER_ANDROID_IME_ADAPTER_ANDROID_H_ 6 #define CONTENT_BROWSER_ANDROID_IME_ADAPTER_ANDROID_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/android/jni_weak_ref.h" 12 #include "base/android/jni_weak_ref.h"
13 #include "base/memory/weak_ptr.h" 13 #include "content/browser/android/render_widget_host_connector.h"
14 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
15 #include "content/public/browser/web_contents_observer.h"
16 #include "ui/gfx/geometry/rect_f.h" 15 #include "ui/gfx/geometry/rect_f.h"
17 16
18 namespace blink { 17 namespace blink {
19 18
20 struct WebCompositionUnderline; 19 struct WebCompositionUnderline;
21 20
22 } // namespace blink 21 } // namespace blink
23 22
24 namespace content { 23 namespace content {
25 24
26 class RenderFrameHost; 25 class RenderFrameHost;
27 class RenderWidgetHostImpl; 26 class RenderWidgetHostImpl;
28 class RenderWidgetHostViewAndroid; 27 class RenderWidgetHostViewAndroid;
29 struct TextInputState; 28 struct TextInputState;
30 29
31 // This class is in charge of dispatching key events from the java side 30 // This class is in charge of dispatching key events from the java side
32 // and forward to renderer along with input method results via 31 // and forward to renderer along with input method results via
33 // corresponding host view. 32 // corresponding host view.
34 // Ownership of these objects remains on the native side (see 33 class CONTENT_EXPORT ImeAdapterAndroid : public RenderWidgetHostConnector {
35 // RenderWidgetHostViewAndroid).
36 class CONTENT_EXPORT ImeAdapterAndroid : public WebContentsObserver {
37 public: 34 public:
38 ImeAdapterAndroid(JNIEnv* env, 35 ImeAdapterAndroid(JNIEnv* env,
39 const base::android::JavaParamRef<jobject>& obj, 36 const base::android::JavaParamRef<jobject>& obj,
40 WebContents* web_contents); 37 WebContents* web_contents);
41 ~ImeAdapterAndroid() override; 38 ~ImeAdapterAndroid() override;
42 39
43 // Called from java -> native 40 // Called from java -> native
44 bool SendKeyEvent( 41 bool SendKeyEvent(
45 JNIEnv* env, 42 JNIEnv* env,
46 const base::android::JavaParamRef<jobject>&, 43 const base::android::JavaParamRef<jobject>&,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 const base::android::JavaParamRef<jobject>&, 78 const base::android::JavaParamRef<jobject>&,
82 int before, 79 int before,
83 int after); 80 int after);
84 void RequestCursorUpdate(JNIEnv*, 81 void RequestCursorUpdate(JNIEnv*,
85 const base::android::JavaParamRef<jobject>&, 82 const base::android::JavaParamRef<jobject>&,
86 bool immediateRequest, 83 bool immediateRequest,
87 bool monitorRequest); 84 bool monitorRequest);
88 bool RequestTextInputStateUpdate(JNIEnv*, 85 bool RequestTextInputStateUpdate(JNIEnv*,
89 const base::android::JavaParamRef<jobject>&); 86 const base::android::JavaParamRef<jobject>&);
90 87
88 // RendetWidgetHostConnector implementation.
89 void UpdateRenderProcessConnection(
90 RenderWidgetHostViewAndroid* old_rwhva,
91 RenderWidgetHostViewAndroid* new_rhwva) override;
92
91 // Called from native -> java 93 // Called from native -> java
92 void CancelComposition(); 94 void CancelComposition();
93 void FocusedNodeChanged(bool is_editable_node); 95 void FocusedNodeChanged(bool is_editable_node);
94 void SetCharacterBounds(const std::vector<gfx::RectF>& rects); 96 void SetCharacterBounds(const std::vector<gfx::RectF>& rects);
95 97
96 base::android::ScopedJavaLocalRef<jobject> java_ime_adapter_for_testing( 98 base::android::ScopedJavaLocalRef<jobject> java_ime_adapter_for_testing(
97 JNIEnv* env) { 99 JNIEnv* env) {
98 return java_ime_adapter_.get(env); 100 return java_ime_adapter_.get(env);
99 } 101 }
100 102
101 // WebContentsObserver implementation.
102 void RenderViewReady() override;
103 void RenderViewHostChanged(RenderViewHost* old_host,
104 RenderViewHost* new_host) override;
105 void DidAttachInterstitialPage() override;
106 void DidDetachInterstitialPage() override;
107 void WebContentsDestroyed() override;
108
109 void UpdateState(const TextInputState& state); 103 void UpdateState(const TextInputState& state);
110 104
111 private: 105 private:
112 RenderWidgetHostImpl* GetFocusedWidget(); 106 RenderWidgetHostImpl* GetFocusedWidget();
113 RenderFrameHost* GetFocusedFrame(); 107 RenderFrameHost* GetFocusedFrame();
114 std::vector<blink::WebCompositionUnderline> GetUnderlinesFromSpans( 108 std::vector<blink::WebCompositionUnderline> GetUnderlinesFromSpans(
115 JNIEnv* env, 109 JNIEnv* env,
116 const base::android::JavaParamRef<jobject>& obj, 110 const base::android::JavaParamRef<jobject>& obj,
117 const base::android::JavaParamRef<jobject>& text, 111 const base::android::JavaParamRef<jobject>& text,
118 const base::string16& text16); 112 const base::string16& text16);
119 RenderWidgetHostViewAndroid* GetRenderWidgetHostViewAndroid() const;
120 void UpdateRenderProcessConnection(RenderWidgetHostViewAndroid* new_rwhva);
121 113
122 base::WeakPtr<RenderWidgetHostViewAndroid> rwhva_; 114 // Flag used to notify Java layer of the render process connection
115 // at the beginning.
116 bool connected_;
boliu 2017/04/10 18:08:43 java side already has this state, no need to repea
Jinsuk Kim 2017/04/11 01:41:58 Done. Replacing it with (!old_rwhva && new_rwhva)
123 JavaObjectWeakGlobalRef java_ime_adapter_; 117 JavaObjectWeakGlobalRef java_ime_adapter_;
124 }; 118 };
125 119
126 bool RegisterImeAdapter(JNIEnv* env); 120 bool RegisterImeAdapter(JNIEnv* env);
127 121
128 } // namespace content 122 } // namespace content
129 123
130 #endif // CONTENT_BROWSER_ANDROID_IME_ADAPTER_ANDROID_H_ 124 #endif // CONTENT_BROWSER_ANDROID_IME_ADAPTER_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698