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

Unified Diff: content/browser/android/ime_adapter_android.h

Issue 2792063003: Factor out RenderWidgetHostConnector (Closed)
Patch Set: composed connector 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/android/ime_adapter_android.h
diff --git a/content/browser/android/ime_adapter_android.h b/content/browser/android/ime_adapter_android.h
index e2860e1203b7f1fb73cb317200af17681443cecc..86bf0e6ca9ac6b1b7f4c12a9b1abfaefe4f5e452 100644
--- a/content/browser/android/ime_adapter_android.h
+++ b/content/browser/android/ime_adapter_android.h
@@ -10,9 +10,8 @@
#include <vector>
#include "base/android/jni_weak_ref.h"
-#include "base/memory/weak_ptr.h"
+#include "content/browser/android/render_widget_host_connector.h"
#include "content/common/content_export.h"
-#include "content/public/browser/web_contents_observer.h"
#include "ui/gfx/geometry/rect_f.h"
namespace blink {
@@ -31,14 +30,12 @@ struct TextInputState;
// This class is in charge of dispatching key events from the java side
// and forward to renderer along with input method results via
// corresponding host view.
-// Ownership of these objects remains on the native side (see
-// RenderWidgetHostViewAndroid).
-class CONTENT_EXPORT ImeAdapterAndroid : public WebContentsObserver {
+class CONTENT_EXPORT ImeAdapterAndroid {
public:
ImeAdapterAndroid(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
WebContents* web_contents);
- ~ImeAdapterAndroid() override;
+ ~ImeAdapterAndroid();
// Called from java -> native
bool SendKeyEvent(
@@ -98,17 +95,21 @@ class CONTENT_EXPORT ImeAdapterAndroid : public WebContentsObserver {
return java_ime_adapter_.get(env);
}
- // WebContentsObserver implementation.
- void RenderViewReady() override;
- void RenderViewHostChanged(RenderViewHost* old_host,
- RenderViewHost* new_host) override;
- void DidAttachInterstitialPage() override;
- void DidDetachInterstitialPage() override;
- void WebContentsDestroyed() override;
-
+ void SetRenderWidgetHostView(RenderWidgetHostViewAndroid* rwhva);
void UpdateState(const TextInputState& state);
private:
+ class Connector : public RenderWidgetHostConnector {
+ public:
+ Connector(WebContents* web_contents, ImeAdapterAndroid* ime_adapter);
+ // RendetWidgetHostConnector implementation.
+ void UpdateRenderWidgetHostView(
+ RenderWidgetHostViewAndroid* old_rwhva,
+ RenderWidgetHostViewAndroid* new_rwhva) override;
+
+ private:
+ ImeAdapterAndroid* const ime_adapter_;
+ };
RenderWidgetHostImpl* GetFocusedWidget();
RenderFrameHost* GetFocusedFrame();
std::vector<blink::WebCompositionUnderline> GetUnderlinesFromSpans(
@@ -116,10 +117,10 @@ class CONTENT_EXPORT ImeAdapterAndroid : public WebContentsObserver {
const base::android::JavaParamRef<jobject>& obj,
const base::android::JavaParamRef<jobject>& text,
const base::string16& text16);
- RenderWidgetHostViewAndroid* GetRenderWidgetHostViewAndroid() const;
- void UpdateRenderProcessConnection(RenderWidgetHostViewAndroid* new_rwhva);
- base::WeakPtr<RenderWidgetHostViewAndroid> rwhva_;
+ std::unique_ptr<Connector> connector_;
+ // Current RenderWidgetHostView connected to this instance. Can be null.
+ RenderWidgetHostViewAndroid* rwhva_;
JavaObjectWeakGlobalRef java_ime_adapter_;
};

Powered by Google App Engine
This is Rietveld 408576698