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 | 9 |
10 #include "base/android/jni_helper.h" | 10 #include "base/android/jni_helper.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 | 12 |
13 class TabContents; | 13 class TabContents; |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 class WebContents; | 16 class WebContents; |
17 } | 17 } |
18 | 18 |
19 namespace android_webview { | 19 namespace android_webview { |
20 | 20 |
21 class AwContentsContainer; | 21 class AwContentsContainer; |
22 class AwWebContentsDelegate; | 22 class AwWebContentsDelegate; |
23 | 23 |
24 // Native side of java-class of same name. | 24 // Native side of java-class of same name. |
25 // Provides the ownership of and access to browser components required for | 25 // Provides the ownership of and access to browser components required for |
26 // WebView functionality; analogous to chrome's TabContents, but with a | 26 // WebView functionality; analogous to chrome's TabContents, but with a |
27 // level of indirection provided by the AwContentsContainer abstraction. | 27 // level of indirection provided by the AwContentsContainer abstraction. |
28 class AwContents { | 28 class AwContents { |
29 public: | 29 public: |
| 30 // Returns the AwContents instance associated with |web_contents|, or NULL. |
| 31 static AwContents* FromWebContents(content::WebContents* web_contents); |
| 32 |
30 AwContents(JNIEnv* env, | 33 AwContents(JNIEnv* env, |
31 jobject obj, | 34 jobject obj, |
32 jobject web_contents_delegate, | 35 jobject web_contents_delegate, |
33 bool private_browsing); | 36 bool private_browsing); |
34 ~AwContents(); | 37 ~AwContents(); |
35 | 38 |
| 39 // Methods called from Java. |
36 jint GetWebContents(JNIEnv* env, jobject obj); | 40 jint GetWebContents(JNIEnv* env, jobject obj); |
37 void Destroy(JNIEnv* env, jobject obj); | 41 void Destroy(JNIEnv* env, jobject obj); |
38 | 42 |
39 private: | 43 private: |
40 JavaObjectWeakGlobalRef java_ref_; | 44 JavaObjectWeakGlobalRef java_ref_; |
41 scoped_ptr<AwContentsContainer> contents_container_; | 45 scoped_ptr<AwContentsContainer> contents_container_; |
42 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; | 46 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; |
43 | 47 |
44 DISALLOW_COPY_AND_ASSIGN(AwContents); | 48 DISALLOW_COPY_AND_ASSIGN(AwContents); |
45 }; | 49 }; |
46 | 50 |
47 bool RegisterAwContents(JNIEnv* env); | 51 bool RegisterAwContents(JNIEnv* env); |
48 | 52 |
49 } // namespace android_webview | 53 } // namespace android_webview |
50 | 54 |
51 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ | 55 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ |
OLD | NEW |