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

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: Addressed Ted's comments 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
« no previous file with comments | « chrome/browser/android/find_in_page/find_in_page_bridge.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 }
OLDNEW
« no previous file with comments | « chrome/browser/android/find_in_page/find_in_page_bridge.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698