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

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: nit fixes. 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
« no previous file with comments | « android_webview/lib/main/webview_entry_point.cc ('k') | android_webview/native/aw_contents.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "content/public/browser/javascript_dialogs.h" 15 #include "content/public/browser/javascript_dialogs.h"
15 16
16 class TabContents; 17 class TabContents;
17 18
18 namespace content { 19 namespace content {
19 class WebContents; 20 class WebContents;
20 } 21 }
21 22
22 namespace android_webview { 23 namespace android_webview {
23 24
24 class AwContentsContainer; 25 class AwContentsContainer;
25 class AwRenderViewHostExt; 26 class AwRenderViewHostExt;
26 class AwWebContentsDelegate; 27 class AwWebContentsDelegate;
27 28
28 // Native side of java-class of same name. 29 // Native side of java-class of same name.
29 // Provides the ownership of and access to browser components required for 30 // Provides the ownership of and access to browser components required for
30 // WebView functionality; analogous to chrome's TabContents, but with a 31 // WebView functionality; analogous to chrome's TabContents, but with a
31 // level of indirection provided by the AwContentsContainer abstraction. 32 // level of indirection provided by the AwContentsContainer abstraction.
32 class AwContents { 33 class AwContents : public FindHelper::Listener {
33 public: 34 public:
34 // Returns the AwContents instance associated with |web_contents|, or NULL. 35 // Returns the AwContents instance associated with |web_contents|, or NULL.
35 static AwContents* FromWebContents(content::WebContents* web_contents); 36 static AwContents* FromWebContents(content::WebContents* web_contents);
36 37
37 AwContents(JNIEnv* env, 38 AwContents(JNIEnv* env,
38 jobject obj, 39 jobject obj,
39 jobject web_contents_delegate, 40 jobject web_contents_delegate,
40 bool private_browsing); 41 bool private_browsing);
41 ~AwContents(); 42 virtual ~AwContents();
42 43
43 void RunJavaScriptDialog( 44 void RunJavaScriptDialog(
44 content::JavaScriptMessageType message_type, 45 content::JavaScriptMessageType message_type,
45 const GURL& origin_url, 46 const GURL& origin_url,
46 const string16& message_text, 47 const string16& message_text,
47 const string16& default_prompt_text, 48 const string16& default_prompt_text,
48 const base::android::ScopedJavaLocalRef<jobject>& js_result); 49 const base::android::ScopedJavaLocalRef<jobject>& js_result);
49 50
50 void RunBeforeUnloadDialog( 51 void RunBeforeUnloadDialog(
51 const GURL& origin_url, 52 const GURL& origin_url,
52 const string16& message_text, 53 const string16& message_text,
53 const base::android::ScopedJavaLocalRef<jobject>& js_result); 54 const base::android::ScopedJavaLocalRef<jobject>& js_result);
54 55
55 // |handler| is an instance of 56 // |handler| is an instance of
56 // org.chromium.android_webview.AwHttpAuthHandler. 57 // org.chromium.android_webview.AwHttpAuthHandler.
57 void onReceivedHttpAuthRequest(const base::android::JavaRef<jobject>& handler, 58 void onReceivedHttpAuthRequest(const base::android::JavaRef<jobject>& handler,
58 const std::string& host, 59 const std::string& host,
59 const std::string& realm); 60 const std::string& realm);
60 61
61 // Methods called from Java. 62 // Methods called from Java.
62 jint GetWebContents(JNIEnv* env, jobject obj); 63 jint GetWebContents(JNIEnv* env, jobject obj);
63 void Destroy(JNIEnv* env, jobject obj); 64 void Destroy(JNIEnv* env, jobject obj);
64 void DocumentHasImages(JNIEnv* env, jobject obj, jobject message); 65 void DocumentHasImages(JNIEnv* env, jobject obj, jobject message);
65 void GenerateMHTML(JNIEnv* env, jobject obj, jstring jpath, jobject callback); 66 void GenerateMHTML(JNIEnv* env, jobject obj, jstring jpath, jobject callback);
66 void SetIoThreadClient(JNIEnv* env, jobject obj, jobject client); 67 void SetIoThreadClient(JNIEnv* env, jobject obj, jobject client);
67 68
69 // Find-in-page API and related methods.
70 jint FindAllSync(JNIEnv* env, jobject obj, jstring search_string);
71 void FindAllAsync(JNIEnv* env, jobject obj, jstring search_string);
72 void FindNext(JNIEnv* env, jobject obj, jboolean forward);
73 void ClearMatches(JNIEnv* env, jobject obj);
74
75 FindHelper* GetFindHelper();
76
77 // FindHelper::Listener implementation.
78 virtual void OnFindResultReceived(int active_ordinal,
79 int match_count,
80 bool finished) OVERRIDE;
68 private: 81 private:
69 JavaObjectWeakGlobalRef java_ref_; 82 JavaObjectWeakGlobalRef java_ref_;
70 scoped_ptr<AwContentsContainer> contents_container_; 83 scoped_ptr<AwContentsContainer> contents_container_;
71 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; 84 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_;
72 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_; 85 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_;
86 scoped_ptr<FindHelper> find_helper_;
73 87
74 DISALLOW_COPY_AND_ASSIGN(AwContents); 88 DISALLOW_COPY_AND_ASSIGN(AwContents);
75 }; 89 };
76 90
77 bool RegisterAwContents(JNIEnv* env); 91 bool RegisterAwContents(JNIEnv* env);
78 92
79 } // namespace android_webview 93 } // namespace android_webview
80 94
81 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ 95 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_
OLDNEW
« no previous file with comments | « android_webview/lib/main/webview_entry_point.cc ('k') | android_webview/native/aw_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698