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

Side by Side Diff: chrome/browser/android/find_in_page/find_in_page_bridge.cc

Issue 633743002: Add FindInPageBridge (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
(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
26 bool FindInPageBridge::RegisterFindInPageBridge(JNIEnv* env) {
27 return RegisterNativesImpl(env);
28 }
29
30 static jlong Init(JNIEnv* env, jobject obj, jobject j_web_contents) {
31 FindInPageBridge* bridge = new FindInPageBridge(env, obj, j_web_contents);
32 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.
33 }
34
35 void FindInPageBridge::StartFinding(JNIEnv* env,
36 jobject obj,
37 jstring search_string,
38 jboolean forward_direction,
39 jboolean case_sensitive) {
40 FindTabHelper::FromWebContents(web_contents_)
41 ->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.
42 base::android::ConvertJavaStringToUTF16(env, search_string),
43 forward_direction,
44 case_sensitive);
45 }
46
47 void FindInPageBridge::StopFinding(JNIEnv* env, jobject obj) {
48 FindTabHelper::FromWebContents(web_contents_)
49 ->StopFinding(FindBarController::kClearSelectionOnPage);
50 }
51
52 ScopedJavaLocalRef<jstring> FindInPageBridge::GetPreviousFindText(JNIEnv* env,
53 jobject obj) {
54 return ConvertUTF16ToJavaString(
55 env, FindTabHelper::FromWebContents(web_contents_)->previous_find_text());
56 }
57
58 void FindInPageBridge::RequestFindMatchRects(JNIEnv* env,
59 jobject obj,
60 jint current_version) {
61 FindTabHelper::FromWebContents(web_contents_)
62 ->RequestFindMatchRects(current_version);
63 }
64
65 void FindInPageBridge::ActivateNearestFindResult(JNIEnv* env,
66 jobject obj,
67 jfloat x,
68 jfloat y) {
69 FindTabHelper::FromWebContents(web_contents_)
70 ->ActivateNearestFindResult(x, y);
71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698