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

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: Move init to the bottom 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 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);
35 }
36
37 void FindInPageBridge::StopFinding(JNIEnv* env, jobject obj) {
38 FindTabHelper::FromWebContents(web_contents_)->
39 StopFinding(FindBarController::kClearSelectionOnPage);
40 }
41
42 ScopedJavaLocalRef<jstring> FindInPageBridge::GetPreviousFindText(JNIEnv* env,
43 jobject obj) {
44 return ConvertUTF16ToJavaString(
45 env, FindTabHelper::FromWebContents(web_contents_)->previous_find_text());
46 }
47
48 void FindInPageBridge::RequestFindMatchRects(JNIEnv* env,
49 jobject obj,
50 jint current_version) {
51 FindTabHelper::FromWebContents(web_contents_)->
52 RequestFindMatchRects(current_version);
53 }
54
55 void FindInPageBridge::ActivateNearestFindResult(JNIEnv* env,
56 jobject obj,
57 jfloat x,
58 jfloat y) {
59 FindTabHelper::FromWebContents(web_contents_)->
60 ActivateNearestFindResult(x, y);
61 }
62
63 // static
64 static jlong Init(JNIEnv* env, jobject obj, jobject j_web_contents) {
65 FindInPageBridge* bridge = new FindInPageBridge(env, obj, j_web_contents);
66 return reinterpret_cast<intptr_t>(bridge);
67 }
68
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