| 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 "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
| 12 #include "base/android/jni_helper.h" | 12 #include "base/android/jni_helper.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "content/public/browser/javascript_dialogs.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 { |
| 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 ~AwContents(); |
| 41 | 42 |
| 43 void RunJavaScriptDialog( |
| 44 content::JavaScriptMessageType message_type, |
| 45 const GURL& origin_url, |
| 46 const string16& message_text, |
| 47 const string16& default_prompt_text, |
| 48 const base::android::ScopedJavaLocalRef<jobject>& js_result); |
| 49 |
| 50 void RunBeforeUnloadDialog( |
| 51 const GURL& origin_url, |
| 52 const string16& message_text, |
| 53 const base::android::ScopedJavaLocalRef<jobject>& js_result); |
| 54 |
| 42 // |handler| is an instance of | 55 // |handler| is an instance of |
| 43 // org.chromium.android_webview.AwHttpAuthHandler. | 56 // org.chromium.android_webview.AwHttpAuthHandler. |
| 44 void onReceivedHttpAuthRequest(const base::android::JavaRef<jobject>& handler, | 57 void onReceivedHttpAuthRequest(const base::android::JavaRef<jobject>& handler, |
| 45 const std::string& host, | 58 const std::string& host, |
| 46 const std::string& realm); | 59 const std::string& realm); |
| 47 | 60 |
| 48 // Methods called from Java. | 61 // Methods called from Java. |
| 49 jint GetWebContents(JNIEnv* env, jobject obj); | 62 jint GetWebContents(JNIEnv* env, jobject obj); |
| 50 void Destroy(JNIEnv* env, jobject obj); | 63 void Destroy(JNIEnv* env, jobject obj); |
| 51 void DocumentHasImages(JNIEnv* env, jobject obj, jobject message); | 64 void DocumentHasImages(JNIEnv* env, jobject obj, jobject message); |
| 52 void SetIoThreadClient(JNIEnv* env, jobject obj, jobject client); | 65 void SetIoThreadClient(JNIEnv* env, jobject obj, jobject client); |
| 53 | 66 |
| 54 private: | 67 private: |
| 55 JavaObjectWeakGlobalRef java_ref_; | 68 JavaObjectWeakGlobalRef java_ref_; |
| 56 scoped_ptr<AwContentsContainer> contents_container_; | 69 scoped_ptr<AwContentsContainer> contents_container_; |
| 57 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; | 70 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; |
| 58 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_; | 71 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_; |
| 59 | 72 |
| 60 DISALLOW_COPY_AND_ASSIGN(AwContents); | 73 DISALLOW_COPY_AND_ASSIGN(AwContents); |
| 61 }; | 74 }; |
| 62 | 75 |
| 63 bool RegisterAwContents(JNIEnv* env); | 76 bool RegisterAwContents(JNIEnv* env); |
| 64 | 77 |
| 65 } // namespace android_webview | 78 } // namespace android_webview |
| 66 | 79 |
| 67 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ | 80 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ |
| OLD | NEW |