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

Unified Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 2752113005: Let ImeAdapterAndroid have the same lifecycle as its Java peer (Closed)
Patch Set: fix tests 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/renderer_host/render_widget_host_view_android.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc
index 12f20f306b9e16a1fbd67f014cdf1d6c26a902a0..90cd9523e338a2066b975f0ef15d4a8844855b0a 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -41,6 +41,7 @@
#include "content/browser/accessibility/browser_accessibility_manager_android.h"
#include "content/browser/android/composited_touch_handle_drawable.h"
#include "content/browser/android/content_view_core_impl.h"
+#include "content/browser/android/ime_adapter_android.h"
#include "content/browser/android/overscroll_controller_android.h"
#include "content/browser/android/synchronous_compositor_host.h"
#include "content/browser/compositor/surface_utils.h"
@@ -450,7 +451,7 @@ RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid(
is_window_activity_started_(true),
is_in_vr_(false),
content_view_core_(nullptr),
- ime_adapter_android_(this),
+ ime_adapter_android_(nullptr),
cached_background_color_(SK_ColorWHITE),
view_(this),
gesture_provider_(ui::GetGestureProviderConfig(
@@ -496,6 +497,8 @@ RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() {
if (content_view_core_)
content_view_core_->RemoveObserver(this);
SetContentViewCore(NULL);
+ if (ime_adapter_android_)
+ ime_adapter_android_ = nullptr;
DCHECK(ack_callbacks_.empty());
DCHECK(!delegated_frame_host_);
}
@@ -703,10 +706,6 @@ void RenderWidgetHostViewAndroid::SetIsLoading(bool is_loading) {
// is TabContentsDelegate.
}
-long RenderWidgetHostViewAndroid::GetNativeImeAdapter() {
- return reinterpret_cast<intptr_t>(&ime_adapter_android_);
-}
-
// -----------------------------------------------------------------------------
// TextInputManager::Observer implementations.
void RenderWidgetHostViewAndroid::OnUpdateTextInputStateCalled(
@@ -725,10 +724,9 @@ void RenderWidgetHostViewAndroid::OnUpdateTextInputStateCalled(
return;
content_view_core_->UpdateImeAdapter(
- GetNativeImeAdapter(), static_cast<int>(state.type), state.flags,
- state.mode, state.value, state.selection_start, state.selection_end,
- state.composition_start, state.composition_end, state.show_ime_if_needed,
- state.reply_to_request);
+ static_cast<int>(state.type), state.flags, state.mode, state.value,
+ state.selection_start, state.selection_end, state.composition_start,
+ state.composition_end, state.show_ime_if_needed, state.reply_to_request);
}
void RenderWidgetHostViewAndroid::OnImeCompositionRangeChanged(
@@ -744,14 +742,16 @@ void RenderWidgetHostViewAndroid::OnImeCompositionRangeChanged(
for (const gfx::Rect& rect : info->character_bounds)
character_bounds.emplace_back(rect);
- ime_adapter_android_.SetCharacterBounds(character_bounds);
+ if (ime_adapter_android_)
+ ime_adapter_android_->SetCharacterBounds(character_bounds);
}
void RenderWidgetHostViewAndroid::OnImeCancelComposition(
TextInputManager* text_input_manager,
RenderWidgetHostViewBase* updated_view) {
DCHECK_EQ(text_input_manager_, text_input_manager);
- ime_adapter_android_.CancelComposition();
+ if (ime_adapter_android_)
+ ime_adapter_android_->CancelComposition();
}
void RenderWidgetHostViewAndroid::OnTextSelectionChanged(
@@ -908,6 +908,11 @@ bool RenderWidgetHostViewAndroid::TransformPointToCoordSpaceForView(
transformed_point);
}
+base::WeakPtr<RenderWidgetHostViewAndroid>
+RenderWidgetHostViewAndroid::GetWeakPtrAndroid() {
+ return weak_ptr_factory_.GetWeakPtr();
+}
+
void RenderWidgetHostViewAndroid::OnStartContentIntent(
const GURL& content_url, bool is_main_frame) {
view_.StartContentIntent(content_url, is_main_frame);
@@ -1004,7 +1009,8 @@ void RenderWidgetHostViewAndroid::SetMultiTouchZoomSupportEnabled(
void RenderWidgetHostViewAndroid::FocusedNodeChanged(
bool is_editable_node,
const gfx::Rect& node_bounds_in_screen) {
- ime_adapter_android_.FocusedNodeChanged(is_editable_node);
+ if (ime_adapter_android_)
+ ime_adapter_android_->FocusedNodeChanged(is_editable_node);
}
void RenderWidgetHostViewAndroid::RenderProcessGone(
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_android.h ('k') | content/browser/site_per_process_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698