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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 10911012: Upstream Android IME support (ImeAdapter). (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: nits fixed; recent downstream changes applied; ime adapter added to browser_jni_registrar Created 8 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "content/browser/renderer_host/render_widget_host_view_android.h" 5 #include "content/browser/renderer_host/render_widget_host_view_android.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "content/browser/android/content_view_core_impl.h" 11 #include "content/browser/android/content_view_core_impl.h"
12 #include "content/browser/android/draw_delegate_impl.h" 12 #include "content/browser/android/draw_delegate_impl.h"
13 #include "content/browser/gpu/gpu_surface_tracker.h" 13 #include "content/browser/gpu/gpu_surface_tracker.h"
14 #include "content/browser/renderer_host/render_widget_host_impl.h" 14 #include "content/browser/renderer_host/render_widget_host_impl.h"
15 #include "content/common/android/device_info.h" 15 #include "content/common/android/device_info.h"
16 #include "content/common/gpu/gpu_messages.h" 16 #include "content/common/gpu/gpu_messages.h"
17 #include "content/common/view_messages.h" 17 #include "content/common/view_messages.h"
18 18
19 namespace content { 19 namespace content {
20 20
21 RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( 21 RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid(
22 RenderWidgetHostImpl* widget_host, 22 RenderWidgetHostImpl* widget_host,
23 ContentViewCoreImpl* content_view_core) 23 ContentViewCoreImpl* content_view_core)
24 : host_(widget_host), 24 : host_(widget_host),
25 // ContentViewCoreImpl represents the native side of the Java 25 // ContentViewCoreImpl represents the native side of the Java
26 // ContentViewCore. It being NULL means that it is not attached to the 26 // ContentViewCore. It being NULL means that it is not attached to the
27 // View system yet, so we treat it as hidden. 27 // View system yet, so we treat it as hidden.
28 is_hidden_(!content_view_core), 28 is_hidden_(!content_view_core),
29 content_view_core_(content_view_core) { 29 content_view_core_(content_view_core),
30 ime_adapter_android_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
30 host_->SetView(this); 31 host_->SetView(this);
31 // RenderWidgetHost is initialized as visible. If is_hidden_ is true, tell 32 // RenderWidgetHost is initialized as visible. If is_hidden_ is true, tell
32 // RenderWidgetHost to hide. 33 // RenderWidgetHost to hide.
33 if (is_hidden_) 34 if (is_hidden_)
34 host_->WasHidden(); 35 host_->WasHidden();
35 } 36 }
36 37
37 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { 38 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() {
38 } 39 }
39 40
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 // There are no cursors on Android. 172 // There are no cursors on Android.
172 } 173 }
173 174
174 void RenderWidgetHostViewAndroid::SetIsLoading(bool is_loading) { 175 void RenderWidgetHostViewAndroid::SetIsLoading(bool is_loading) {
175 // Do nothing. The UI notification is handled through ContentViewClient which 176 // Do nothing. The UI notification is handled through ContentViewClient which
176 // is TabContentsDelegate. 177 // is TabContentsDelegate.
177 } 178 }
178 179
179 void RenderWidgetHostViewAndroid::TextInputStateChanged( 180 void RenderWidgetHostViewAndroid::TextInputStateChanged(
180 const ViewHostMsg_TextInputState_Params& params) { 181 const ViewHostMsg_TextInputState_Params& params) {
181 NOTIMPLEMENTED(); 182 if (is_hidden_)
183 return;
184
185 content_view_core_->ImeUpdateAdapter(
186 GetNativeImeAdapter(),
187 static_cast<int>(params.type),
188 params.value, params.selection_start, params.selection_end,
189 params.composition_start, params.composition_end,
190 false /* show_ime_if_needed */);
191 }
192
193 int RenderWidgetHostViewAndroid::GetNativeImeAdapter() {
194 return reinterpret_cast<int>(&ime_adapter_android_);
182 } 195 }
183 196
184 void RenderWidgetHostViewAndroid::ImeCancelComposition() { 197 void RenderWidgetHostViewAndroid::ImeCancelComposition() {
198 ime_adapter_android_.CancelComposition();
185 } 199 }
186 200
187 void RenderWidgetHostViewAndroid::DidUpdateBackingStore( 201 void RenderWidgetHostViewAndroid::DidUpdateBackingStore(
188 const gfx::Rect& scroll_rect, int scroll_dx, int scroll_dy, 202 const gfx::Rect& scroll_rect, int scroll_dx, int scroll_dy,
189 const std::vector<gfx::Rect>& copy_rects) { 203 const std::vector<gfx::Rect>& copy_rects) {
190 NOTIMPLEMENTED(); 204 NOTIMPLEMENTED();
191 } 205 }
192 206
193 void RenderWidgetHostViewAndroid::RenderViewGone( 207 void RenderWidgetHostViewAndroid::RenderViewGone(
194 base::TerminationStatus status, int error_code) { 208 base::TerminationStatus status, int error_code) {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 344
331 bool RenderWidgetHostViewAndroid::LockMouse() { 345 bool RenderWidgetHostViewAndroid::LockMouse() {
332 NOTIMPLEMENTED(); 346 NOTIMPLEMENTED();
333 return false; 347 return false;
334 } 348 }
335 349
336 void RenderWidgetHostViewAndroid::UnlockMouse() { 350 void RenderWidgetHostViewAndroid::UnlockMouse() {
337 NOTIMPLEMENTED(); 351 NOTIMPLEMENTED();
338 } 352 }
339 353
354 // Methods called from the host to the render
355
356 void RenderWidgetHostViewAndroid::SendKeyEvent(
357 const NativeWebKeyboardEvent& event) {
358 if (host_)
359 host_->ForwardKeyboardEvent(event);
360 }
361
340 void RenderWidgetHostViewAndroid::TouchEvent( 362 void RenderWidgetHostViewAndroid::TouchEvent(
341 const WebKit::WebTouchEvent& event) { 363 const WebKit::WebTouchEvent& event) {
342 if (host_) 364 if (host_)
343 host_->ForwardTouchEvent(event); 365 host_->ForwardTouchEvent(event);
344 } 366 }
345 367
346 void RenderWidgetHostViewAndroid::GestureEvent( 368 void RenderWidgetHostViewAndroid::GestureEvent(
347 const WebKit::WebGestureEvent& event) { 369 const WebKit::WebGestureEvent& event) {
348 if (host_) 370 if (host_)
349 host_->ForwardGestureEvent(event); 371 host_->ForwardGestureEvent(event);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 // RenderWidgetHostView, public: 407 // RenderWidgetHostView, public:
386 408
387 // static 409 // static
388 RenderWidgetHostView* 410 RenderWidgetHostView*
389 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { 411 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) {
390 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); 412 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget);
391 return new RenderWidgetHostViewAndroid(rwhi, NULL); 413 return new RenderWidgetHostViewAndroid(rwhi, NULL);
392 } 414 }
393 415
394 } // namespace content 416 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_android.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698