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

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

Issue 1162373002: Make some editing/selection functions accessible to c/b/renderer_host/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Switched to oninput event as oncut/onpaste happen before cut/paste Created 5 years, 5 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/ime_adapter_android.h" 5 #include "content/browser/renderer_host/ime_adapter_android.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <android/input.h> 8 #include <android/input.h>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/android/jni_android.h" 11 #include "base/android/jni_android.h"
12 #include "base/android/jni_string.h" 12 #include "base/android/jni_string.h"
13 #include "base/android/scoped_java_ref.h" 13 #include "base/android/scoped_java_ref.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "content/browser/frame_host/frame_tree.h" 16 #include "content/browser/frame_host/frame_tree.h"
17 #include "content/browser/frame_host/frame_tree_node.h" 17 #include "content/browser/frame_host/frame_tree_node.h"
18 #include "content/browser/frame_host/render_frame_host_impl.h" 18 #include "content/browser/frame_host/render_frame_host_impl.h"
19 #include "content/browser/renderer_host/render_view_host_delegate.h" 19 #include "content/browser/renderer_host/render_view_host_delegate.h"
20 #include "content/browser/renderer_host/render_view_host_impl.h" 20 #include "content/browser/renderer_host/render_view_host_impl.h"
21 #include "content/browser/renderer_host/render_widget_host_delegate.h"
21 #include "content/browser/renderer_host/render_widget_host_impl.h" 22 #include "content/browser/renderer_host/render_widget_host_impl.h"
22 #include "content/browser/renderer_host/render_widget_host_view_android.h" 23 #include "content/browser/renderer_host/render_widget_host_view_android.h"
23 #include "content/common/frame_messages.h" 24 #include "content/common/frame_messages.h"
24 #include "content/common/input_messages.h" 25 #include "content/common/input_messages.h"
25 #include "content/common/view_messages.h" 26 #include "content/common/view_messages.h"
26 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
27 #include "content/public/browser/native_web_keyboard_event.h" 28 #include "content/public/browser/native_web_keyboard_event.h"
28 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
29 #include "jni/ImeAdapter_jni.h" 30 #include "jni/ImeAdapter_jni.h"
30 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" 31 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 wc->Unselect(); 276 wc->Unselect();
276 } 277 }
277 278
278 void ImeAdapterAndroid::SelectAll(JNIEnv* env, jobject) { 279 void ImeAdapterAndroid::SelectAll(JNIEnv* env, jobject) {
279 WebContents* wc = GetWebContents(); 280 WebContents* wc = GetWebContents();
280 if (wc) 281 if (wc)
281 wc->SelectAll(); 282 wc->SelectAll();
282 } 283 }
283 284
284 void ImeAdapterAndroid::Cut(JNIEnv* env, jobject) { 285 void ImeAdapterAndroid::Cut(JNIEnv* env, jobject) {
285 WebContents* wc = GetWebContents(); 286 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl();
286 if (wc) 287 RenderWidgetHostDelegate* delegate = rwh ? rwh->delegate() : nullptr;
287 wc->Cut(); 288 if (delegate)
289 delegate->Cut();
288 } 290 }
289 291
290 void ImeAdapterAndroid::Copy(JNIEnv* env, jobject) { 292 void ImeAdapterAndroid::Copy(JNIEnv* env, jobject) {
291 WebContents* wc = GetWebContents(); 293 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl();
292 if (wc) 294 RenderWidgetHostDelegate* delegate = rwh ? rwh->delegate() : nullptr;
293 wc->Copy(); 295 if (delegate)
296 delegate->Copy();
294 } 297 }
295 298
296 void ImeAdapterAndroid::Paste(JNIEnv* env, jobject) { 299 void ImeAdapterAndroid::Paste(JNIEnv* env, jobject) {
297 WebContents* wc = GetWebContents(); 300 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl();
298 if (wc) 301 RenderWidgetHostDelegate* delegate = rwh ? rwh->delegate() : nullptr;
299 wc->Paste(); 302 if (delegate)
303 delegate->Paste();
300 } 304 }
301 305
302 void ImeAdapterAndroid::ResetImeAdapter(JNIEnv* env, jobject) { 306 void ImeAdapterAndroid::ResetImeAdapter(JNIEnv* env, jobject) {
303 java_ime_adapter_.reset(); 307 java_ime_adapter_.reset();
304 } 308 }
305 309
306 RenderWidgetHostImpl* ImeAdapterAndroid::GetRenderWidgetHostImpl() { 310 RenderWidgetHostImpl* ImeAdapterAndroid::GetRenderWidgetHostImpl() {
307 DCHECK_CURRENTLY_ON(BrowserThread::UI); 311 DCHECK_CURRENTLY_ON(BrowserThread::UI);
308 DCHECK(rwhva_); 312 DCHECK(rwhva_);
309 RenderWidgetHost* rwh = rwhva_->GetRenderWidgetHost(); 313 RenderWidgetHost* rwh = rwhva_->GetRenderWidgetHost();
(...skipping 21 matching lines...) Expand all
331 WebContents* ImeAdapterAndroid::GetWebContents() { 335 WebContents* ImeAdapterAndroid::GetWebContents() {
332 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl(); 336 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl();
333 if (!rwh) 337 if (!rwh)
334 return NULL; 338 return NULL;
335 if (!rwh->IsRenderView()) 339 if (!rwh->IsRenderView())
336 return NULL; 340 return NULL;
337 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh)); 341 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh));
338 } 342 }
339 343
340 } // namespace content 344 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698