Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / android / find_in_page / find_in_page_bridge.cc
blob6488fbaa420068c969cb4dc470d01e7d2d29cd29
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.
5 #include "chrome/browser/android/find_in_page/find_in_page_bridge.h"
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"
12 using base::android::ConvertUTF16ToJavaString;
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);
21 void FindInPageBridge::Destroy(JNIEnv*, jobject) {
22 delete this;
25 void FindInPageBridge::StartFinding(JNIEnv* env,
26 jobject obj,
27 jstring search_string,
28 jboolean forward_direction,
29 jboolean case_sensitive) {
30 FindTabHelper::FromWebContents(web_contents_)->
31 StartFinding(
32 base::android::ConvertJavaStringToUTF16(env, search_string),
33 forward_direction,
34 case_sensitive);
37 void FindInPageBridge::StopFinding(JNIEnv* env,
38 jobject obj,
39 jboolean clearSelection) {
40 FindTabHelper::FromWebContents(web_contents_)->
41 StopFinding(clearSelection ? FindBarController::kClearSelectionOnPage
42 : FindBarController::kKeepSelectionOnPage);
45 ScopedJavaLocalRef<jstring> FindInPageBridge::GetPreviousFindText(JNIEnv* env,
46 jobject obj) {
47 return ConvertUTF16ToJavaString(
48 env, FindTabHelper::FromWebContents(web_contents_)->previous_find_text());
51 void FindInPageBridge::RequestFindMatchRects(JNIEnv* env,
52 jobject obj,
53 jint current_version) {
54 FindTabHelper::FromWebContents(web_contents_)->
55 RequestFindMatchRects(current_version);
58 void FindInPageBridge::ActivateNearestFindResult(JNIEnv* env,
59 jobject obj,
60 jfloat x,
61 jfloat y) {
62 FindTabHelper::FromWebContents(web_contents_)->
63 ActivateNearestFindResult(x, y);
66 void FindInPageBridge::ActivateFindInPageResultForAccessibility(
67 JNIEnv* env, jobject obj) {
68 FindTabHelper::FromWebContents(web_contents_)->
69 ActivateFindInPageResultForAccessibility();
72 // static
73 static jlong Init(JNIEnv* env,
74 const JavaParamRef<jobject>& obj,
75 const JavaParamRef<jobject>& j_web_contents) {
76 FindInPageBridge* bridge = new FindInPageBridge(env, obj, j_web_contents);
77 return reinterpret_cast<intptr_t>(bridge);
80 bool FindInPageBridge::RegisterFindInPageBridge(JNIEnv* env) {
81 return RegisterNativesImpl(env);