| OLD | NEW |
| 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 | 53 |
| 54 // Find-in-page API and related methods. |
| 55 jint FindAllSync(JNIEnv* env, jobject obj, jstring search_string); |
| 56 void FindAllAsync(JNIEnv* env, jobject obj, jstring search_string); |
| 57 void FindNext(JNIEnv* env, jobject obj, jboolean forward); |
| 58 void ClearMatches(JNIEnv* env, jobject obj); |
| 59 |
| 60 FindHelper* GetFindHelper(); |
| 61 |
| 62 // FindHelper::Listener implementation. |
| 63 virtual void OnFindResultReceived(int active_ordinal, |
| 64 int match_count, |
| 65 bool finished) OVERRIDE; |
| 53 private: | 66 private: |
| 54 JavaObjectWeakGlobalRef java_ref_; | 67 JavaObjectWeakGlobalRef java_ref_; |
| 55 scoped_ptr<AwContentsContainer> contents_container_; | 68 scoped_ptr<AwContentsContainer> contents_container_; |
| 56 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; | 69 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; |
| 57 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_; | 70 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_; |
| 71 scoped_ptr<FindHelper> find_helper_; |
| 58 | 72 |
| 59 DISALLOW_COPY_AND_ASSIGN(AwContents); | 73 DISALLOW_COPY_AND_ASSIGN(AwContents); |
| 60 }; | 74 }; |
| 61 | 75 |
| 62 bool RegisterAwContents(JNIEnv* env); | 76 bool RegisterAwContents(JNIEnv* env); |
| 63 | 77 |
| 64 } // namespace android_webview | 78 } // namespace android_webview |
| 65 | 79 |
| 66 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ | 80 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ |
| OLD | NEW |