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

Side by Side Diff: android_webview/native/aw_contents.h

Issue 10941015: [Android] Upstream the WebView find-in-page API implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review fixes + command line switch for synchronous APIs Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ 5 #ifndef ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_
6 #define ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ 6 #define ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <string> 9 #include <string>
10 10
11 #include "android_webview/browser/find_helper.h"
11 #include "base/android/scoped_java_ref.h" 12 #include "base/android/scoped_java_ref.h"
12 #include "base/android/jni_helper.h" 13 #include "base/android/jni_helper.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 15
15 class TabContents; 16 class TabContents;
16 17
17 namespace content { 18 namespace content {
18 class WebContents; 19 class WebContents;
19 } 20 }
20 21
21 namespace android_webview { 22 namespace android_webview {
22 23
23 class AwContentsContainer; 24 class AwContentsContainer;
24 class AwRenderViewHostExt; 25 class AwRenderViewHostExt;
25 class AwWebContentsDelegate; 26 class AwWebContentsDelegate;
26 27
27 // Native side of java-class of same name. 28 // Native side of java-class of same name.
28 // Provides the ownership of and access to browser components required for 29 // Provides the ownership of and access to browser components required for
29 // WebView functionality; analogous to chrome's TabContents, but with a 30 // WebView functionality; analogous to chrome's TabContents, but with a
30 // level of indirection provided by the AwContentsContainer abstraction. 31 // level of indirection provided by the AwContentsContainer abstraction.
31 class AwContents { 32 class AwContents : public FindHelper::Listener {
32 public: 33 public:
33 // Returns the AwContents instance associated with |web_contents|, or NULL. 34 // Returns the AwContents instance associated with |web_contents|, or NULL.
34 static AwContents* FromWebContents(content::WebContents* web_contents); 35 static AwContents* FromWebContents(content::WebContents* web_contents);
35 36
36 AwContents(JNIEnv* env, 37 AwContents(JNIEnv* env,
37 jobject obj, 38 jobject obj,
38 jobject web_contents_delegate, 39 jobject web_contents_delegate,
39 bool private_browsing); 40 bool private_browsing);
40 ~AwContents(); 41 virtual ~AwContents();
41 42
42 // |handler| is an instance of 43 // |handler| is an instance of
43 // org.chromium.android_webview.AwHttpAuthHandler. 44 // org.chromium.android_webview.AwHttpAuthHandler.
44 void onReceivedHttpAuthRequest(const base::android::JavaRef<jobject>& handler, 45 void onReceivedHttpAuthRequest(const base::android::JavaRef<jobject>& handler,
45 const std::string& host, 46 const std::string& host,
46 const std::string& realm); 47 const std::string& realm);
47 48
48 // Methods called from Java. 49 // Methods called from Java.
49 jint GetWebContents(JNIEnv* env, jobject obj); 50 jint GetWebContents(JNIEnv* env, jobject obj);
50 void Destroy(JNIEnv* env, jobject obj); 51 void Destroy(JNIEnv* env, jobject obj);
51 void DocumentHasImages(JNIEnv* env, jobject obj, jobject message); 52 void DocumentHasImages(JNIEnv* env, jobject obj, jobject message);
52 void GenerateMHTML(JNIEnv* env, jobject obj, jstring jpath, jobject callback); 53 void GenerateMHTML(JNIEnv* env, jobject obj, jstring jpath, jobject callback);
53 void SetIoThreadClient(JNIEnv* env, jobject obj, jobject client); 54 void SetIoThreadClient(JNIEnv* env, jobject obj, jobject client);
54 55
56 // Find-in-page API and related methods.
57 jint FindAllSync(JNIEnv* env, jobject obj, jstring search_string);
58 void FindAllAsync(JNIEnv* env, jobject obj, jstring search_string);
59 void FindNext(JNIEnv* env, jobject obj, jboolean forward);
60 void ClearMatches(JNIEnv* env, jobject obj);
61
62 FindHelper* GetFindHelper();
63
64 // FindHelper::Listener implementation.
65 virtual void OnFindResultReceived(int active_ordinal,
66 int match_count,
67 bool finished) OVERRIDE;
55 private: 68 private:
56 JavaObjectWeakGlobalRef java_ref_; 69 JavaObjectWeakGlobalRef java_ref_;
57 scoped_ptr<AwContentsContainer> contents_container_; 70 scoped_ptr<AwContentsContainer> contents_container_;
58 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; 71 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_;
59 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_; 72 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_;
73 scoped_ptr<FindHelper> find_helper_;
60 74
61 DISALLOW_COPY_AND_ASSIGN(AwContents); 75 DISALLOW_COPY_AND_ASSIGN(AwContents);
62 }; 76 };
63 77
64 bool RegisterAwContents(JNIEnv* env); 78 bool RegisterAwContents(JNIEnv* env);
65 79
66 } // namespace android_webview 80 } // namespace android_webview
67 81
68 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ 82 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698