OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/android/find_in_page/find_in_page_bridge.h" | |
6 | |
7 #include "base/android/jni_string.h" | |
8 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | |
9 #include "content/public/browser/web_contents.h" | |
10 #include "jni/FindInPageBridge_jni.h" | |
11 | |
12 using base::android::ConvertUTF16ToJavaString; | |
13 | |
14 FindInPageBridge::FindInPageBridge(JNIEnv* env, | |
15 jobject obj, | |
16 jobject j_web_contents) | |
17 : weak_java_ref_(env, obj) { | |
18 web_contents_ = content::WebContents::FromJavaWebContents(j_web_contents); | |
19 } | |
20 | |
21 void FindInPageBridge::Destroy(JNIEnv*, jobject) { | |
22 delete this; | |
23 } | |
24 | |
25 static jlong Init(JNIEnv* env, jobject obj, jobject j_web_contents) { | |
Ted C
2014/10/08 18:02:27
move this to the bottom as well
aurimas (slooooooooow)
2014/10/08 18:28:24
Done.
| |
26 FindInPageBridge* bridge = new FindInPageBridge(env, obj, j_web_contents); | |
27 return reinterpret_cast<intptr_t>(bridge); | |
28 } | |
29 | |
30 void FindInPageBridge::StartFinding(JNIEnv* env, | |
31 jobject obj, | |
32 jstring search_string, | |
33 jboolean forward_direction, | |
34 jboolean case_sensitive) { | |
35 FindTabHelper::FromWebContents(web_contents_)-> | |
36 StartFinding( | |
37 base::android::ConvertJavaStringToUTF16(env, search_string), | |
38 forward_direction, | |
39 case_sensitive); | |
40 } | |
41 | |
42 void FindInPageBridge::StopFinding(JNIEnv* env, jobject obj) { | |
43 FindTabHelper::FromWebContents(web_contents_)-> | |
44 StopFinding(FindBarController::kClearSelectionOnPage); | |
45 } | |
46 | |
47 ScopedJavaLocalRef<jstring> FindInPageBridge::GetPreviousFindText(JNIEnv* env, | |
48 jobject obj) { | |
49 return ConvertUTF16ToJavaString( | |
50 env, FindTabHelper::FromWebContents(web_contents_)->previous_find_text()); | |
51 } | |
52 | |
53 void FindInPageBridge::RequestFindMatchRects(JNIEnv* env, | |
54 jobject obj, | |
55 jint current_version) { | |
56 FindTabHelper::FromWebContents(web_contents_)-> | |
57 RequestFindMatchRects(current_version); | |
58 } | |
59 | |
60 void FindInPageBridge::ActivateNearestFindResult(JNIEnv* env, | |
61 jobject obj, | |
62 jfloat x, | |
63 jfloat y) { | |
64 FindTabHelper::FromWebContents(web_contents_)-> | |
65 ActivateNearestFindResult(x, y); | |
66 } | |
67 | |
68 // static | |
69 bool FindInPageBridge::RegisterFindInPageBridge(JNIEnv* env) { | |
70 return RegisterNativesImpl(env); | |
71 } | |
OLD | NEW |