Index: chrome/browser/android/find_in_page/find_in_page_bridge.cc |
diff --git a/chrome/browser/android/find_in_page/find_in_page_bridge.cc b/chrome/browser/android/find_in_page/find_in_page_bridge.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d365c6131d4e5878bac21a77434f9d28a895c786 |
--- /dev/null |
+++ b/chrome/browser/android/find_in_page/find_in_page_bridge.cc |
@@ -0,0 +1,71 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/android/find_in_page/find_in_page_bridge.h" |
+ |
+#include "base/android/jni_string.h" |
+#include "chrome/browser/ui/find_bar/find_tab_helper.h" |
+#include "content/public/browser/web_contents.h" |
+#include "jni/FindInPageBridge_jni.h" |
+ |
+using base::android::ConvertUTF16ToJavaString; |
+ |
+FindInPageBridge::FindInPageBridge(JNIEnv* env, |
+ jobject obj, |
+ jobject j_web_contents) |
+ : weak_java_ref_(env, obj) { |
+ web_contents_ = content::WebContents::FromJavaWebContents(j_web_contents); |
+} |
+ |
+void FindInPageBridge::Destroy(JNIEnv*, jobject) { |
+ delete this; |
+} |
+ |
+// static |
+bool FindInPageBridge::RegisterFindInPageBridge(JNIEnv* env) { |
+ return RegisterNativesImpl(env); |
+} |
+ |
+static jlong Init(JNIEnv* env, jobject obj, jobject j_web_contents) { |
+ FindInPageBridge* bridge = new FindInPageBridge(env, obj, j_web_contents); |
+ return reinterpret_cast<intptr_t>(bridge); |
Ted C
2014/10/07 20:49:49
And in moving the above static, I would also put t
aurimas (slooooooooow)
2014/10/07 23:28:25
Done.
|
+} |
+ |
+void FindInPageBridge::StartFinding(JNIEnv* env, |
+ jobject obj, |
+ jstring search_string, |
+ jboolean forward_direction, |
+ jboolean case_sensitive) { |
+ FindTabHelper::FromWebContents(web_contents_) |
+ ->StartFinding( |
Ted C
2014/10/07 20:49:49
I "think" the -> goes on the previous line in c++.
aurimas (slooooooooow)
2014/10/07 23:28:25
Done.
|
+ base::android::ConvertJavaStringToUTF16(env, search_string), |
+ forward_direction, |
+ case_sensitive); |
+} |
+ |
+void FindInPageBridge::StopFinding(JNIEnv* env, jobject obj) { |
+ FindTabHelper::FromWebContents(web_contents_) |
+ ->StopFinding(FindBarController::kClearSelectionOnPage); |
+} |
+ |
+ScopedJavaLocalRef<jstring> FindInPageBridge::GetPreviousFindText(JNIEnv* env, |
+ jobject obj) { |
+ return ConvertUTF16ToJavaString( |
+ env, FindTabHelper::FromWebContents(web_contents_)->previous_find_text()); |
+} |
+ |
+void FindInPageBridge::RequestFindMatchRects(JNIEnv* env, |
+ jobject obj, |
+ jint current_version) { |
+ FindTabHelper::FromWebContents(web_contents_) |
+ ->RequestFindMatchRects(current_version); |
+} |
+ |
+void FindInPageBridge::ActivateNearestFindResult(JNIEnv* env, |
+ jobject obj, |
+ jfloat x, |
+ jfloat y) { |
+ FindTabHelper::FromWebContents(web_contents_) |
+ ->ActivateNearestFindResult(x, y); |
+} |