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

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

Issue 183923030: Almost finish moving context_menu_node_ from RenderViewImpl to RenderFrameImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync to get android fix Created 6 years, 9 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 | Annotate | Revision Log
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 <android/input.h> 7 #include <android/input.h>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
11 #include "base/android/scoped_java_ref.h" 11 #include "base/android/scoped_java_ref.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "content/browser/frame_host/frame_tree.h"
15 #include "content/browser/frame_host/frame_tree_node.h"
16 #include "content/browser/frame_host/render_frame_host_impl.h"
17 #include "content/browser/renderer_host/render_view_host_impl.h"
14 #include "content/browser/renderer_host/render_widget_host_impl.h" 18 #include "content/browser/renderer_host/render_widget_host_impl.h"
15 #include "content/browser/renderer_host/render_widget_host_view_android.h" 19 #include "content/browser/renderer_host/render_widget_host_view_android.h"
16 #include "content/common/view_messages.h" 20 #include "content/common/view_messages.h"
21 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/native_web_keyboard_event.h" 22 #include "content/public/browser/native_web_keyboard_event.h"
18 #include "jni/ImeAdapter_jni.h" 23 #include "jni/ImeAdapter_jni.h"
19 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" 24 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
20 #include "third_party/WebKit/public/web/WebInputEvent.h" 25 #include "third_party/WebKit/public/web/WebInputEvent.h"
21 26
22 using base::android::AttachCurrentThread; 27 using base::android::AttachCurrentThread;
23 using base::android::ConvertJavaStringToUTF16; 28 using base::android::ConvertJavaStringToUTF16;
24 29
25 namespace content { 30 namespace content {
26 namespace { 31 namespace {
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 238
234 void ImeAdapterAndroid::SelectAll(JNIEnv* env, jobject) { 239 void ImeAdapterAndroid::SelectAll(JNIEnv* env, jobject) {
235 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl(); 240 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl();
236 if (!rwhi) 241 if (!rwhi)
237 return; 242 return;
238 243
239 rwhi->SelectAll(); 244 rwhi->SelectAll();
240 } 245 }
241 246
242 void ImeAdapterAndroid::Cut(JNIEnv* env, jobject) { 247 void ImeAdapterAndroid::Cut(JNIEnv* env, jobject) {
243 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl(); 248 RenderFrameHost* rfh = GetFocusedFrame();
244 if (!rwhi) 249 if (rfh)
245 return; 250 rfh->Cut();
246
247 rwhi->Cut();
248 } 251 }
249 252
250 void ImeAdapterAndroid::Copy(JNIEnv* env, jobject) { 253 void ImeAdapterAndroid::Copy(JNIEnv* env, jobject) {
251 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl(); 254 RenderFrameHost* rfh = GetFocusedFrame();
252 if (!rwhi) 255 if (rfh)
253 return; 256 rfh->Copy();
254
255 rwhi->Copy();
256 } 257 }
257 258
258 void ImeAdapterAndroid::Paste(JNIEnv* env, jobject) { 259 void ImeAdapterAndroid::Paste(JNIEnv* env, jobject) {
259 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl(); 260 RenderFrameHost* rfh = GetFocusedFrame();
260 if (!rwhi) 261 if (rfh)
261 return; 262 rfh->Paste();
262
263 rwhi->Paste();
264 } 263 }
265 264
266 void ImeAdapterAndroid::ResetImeAdapter(JNIEnv* env, jobject) { 265 void ImeAdapterAndroid::ResetImeAdapter(JNIEnv* env, jobject) {
267 java_ime_adapter_.reset(); 266 java_ime_adapter_.reset();
268 } 267 }
269 268
270 RenderWidgetHostImpl* ImeAdapterAndroid::GetRenderWidgetHostImpl() { 269 RenderWidgetHostImpl* ImeAdapterAndroid::GetRenderWidgetHostImpl() {
270 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
271 DCHECK(rwhva_); 271 DCHECK(rwhva_);
272 RenderWidgetHost* rwh = rwhva_->GetRenderWidgetHost(); 272 RenderWidgetHost* rwh = rwhva_->GetRenderWidgetHost();
273 if (!rwh) 273 if (!rwh)
274 return NULL; 274 return NULL;
275 275
276 return RenderWidgetHostImpl::From(rwh); 276 return RenderWidgetHostImpl::From(rwh);
277 } 277 }
278 278
279 RenderFrameHost* ImeAdapterAndroid::GetFocusedFrame() {
280 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl();
281 if (!rwh)
282 return NULL;
283 if (!rwh->IsRenderView())
284 return NULL;
285 RenderViewHost* rvh = RenderViewHost::From(rwh);
286 RenderFrameHostImpl* rfh =
287 static_cast<RenderFrameHostImpl*>(rvh->GetMainFrame());
288 FrameTreeNode* focused_frame =
289 rfh->frame_tree_node()->frame_tree()->GetFocusedFrame();
290 if (!focused_frame)
291 return NULL;
292
293 return focused_frame->current_frame_host();
294 }
295
279 } // namespace content 296 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/ime_adapter_android.h ('k') | content/browser/renderer_host/render_widget_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698