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

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

Issue 1209713002: [Android] Use WebContents text manipulation methods directly (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix null check 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
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 } 262 }
263 263
264 void ImeAdapterAndroid::DeleteSurroundingText(JNIEnv*, jobject, 264 void ImeAdapterAndroid::DeleteSurroundingText(JNIEnv*, jobject,
265 int before, int after) { 265 int before, int after) {
266 RenderFrameHostImpl* rfh = 266 RenderFrameHostImpl* rfh =
267 static_cast<RenderFrameHostImpl*>(GetFocusedFrame()); 267 static_cast<RenderFrameHostImpl*>(GetFocusedFrame());
268 if (rfh) 268 if (rfh)
269 rfh->ExtendSelectionAndDelete(before, after); 269 rfh->ExtendSelectionAndDelete(before, after);
270 } 270 }
271 271
272 void ImeAdapterAndroid::Unselect(JNIEnv* env, jobject) {
273 WebContents* wc = GetWebContents();
274 if (wc)
275 wc->Unselect();
276 }
277
278 void ImeAdapterAndroid::SelectAll(JNIEnv* env, jobject) {
279 WebContents* wc = GetWebContents();
280 if (wc)
281 wc->SelectAll();
282 }
283
284 void ImeAdapterAndroid::Cut(JNIEnv* env, jobject) {
285 WebContents* wc = GetWebContents();
286 if (wc)
287 wc->Cut();
288 }
289
290 void ImeAdapterAndroid::Copy(JNIEnv* env, jobject) {
291 WebContents* wc = GetWebContents();
292 if (wc)
293 wc->Copy();
294 }
295
296 void ImeAdapterAndroid::Paste(JNIEnv* env, jobject) {
297 WebContents* wc = GetWebContents();
298 if (wc)
299 wc->Paste();
300 }
301
302 void ImeAdapterAndroid::ResetImeAdapter(JNIEnv* env, jobject) { 272 void ImeAdapterAndroid::ResetImeAdapter(JNIEnv* env, jobject) {
303 java_ime_adapter_.reset(); 273 java_ime_adapter_.reset();
304 } 274 }
305 275
306 RenderWidgetHostImpl* ImeAdapterAndroid::GetRenderWidgetHostImpl() { 276 RenderWidgetHostImpl* ImeAdapterAndroid::GetRenderWidgetHostImpl() {
307 DCHECK_CURRENTLY_ON(BrowserThread::UI); 277 DCHECK_CURRENTLY_ON(BrowserThread::UI);
308 DCHECK(rwhva_); 278 DCHECK(rwhva_);
309 RenderWidgetHost* rwh = rwhva_->GetRenderWidgetHost(); 279 RenderWidgetHost* rwh = rwhva_->GetRenderWidgetHost();
310 if (!rwh) 280 if (!rwh)
311 return NULL; 281 return NULL;
(...skipping 19 matching lines...) Expand all
331 WebContents* ImeAdapterAndroid::GetWebContents() { 301 WebContents* ImeAdapterAndroid::GetWebContents() {
332 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl(); 302 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl();
333 if (!rwh) 303 if (!rwh)
334 return NULL; 304 return NULL;
335 if (!rwh->IsRenderView()) 305 if (!rwh->IsRenderView())
336 return NULL; 306 return NULL;
337 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh)); 307 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh));
338 } 308 }
339 309
340 } // namespace content 310 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/ime_adapter_android.h ('k') | content/browser/web_contents/web_contents_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698