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 <list> | 9 #include <list> |
10 #include <string> | 10 #include <string> |
(...skipping 12 matching lines...) Expand all Loading... |
23 class SkBitmap; | 23 class SkBitmap; |
24 class TabContents; | 24 class TabContents; |
25 | 25 |
26 namespace content { | 26 namespace content { |
27 class WebContents; | 27 class WebContents; |
28 } | 28 } |
29 | 29 |
30 namespace android_webview { | 30 namespace android_webview { |
31 | 31 |
32 class AwContentsContainer; | 32 class AwContentsContainer; |
| 33 class AwContentsClientBridge; |
33 class AwWebContentsDelegate; | 34 class AwWebContentsDelegate; |
34 | 35 |
35 // Native side of java-class of same name. | 36 // Native side of java-class of same name. |
36 // Provides the ownership of and access to browser components required for | 37 // Provides the ownership of and access to browser components required for |
37 // WebView functionality; analogous to chrome's TabContents, but with a | 38 // WebView functionality; analogous to chrome's TabContents, but with a |
38 // level of indirection provided by the AwContentsContainer abstraction. | 39 // level of indirection provided by the AwContentsContainer abstraction. |
39 class AwContents : public FindHelper::Listener, | 40 class AwContents : public FindHelper::Listener, |
40 public IconHelper::Listener, | 41 public IconHelper::Listener, |
41 public BrowserViewRenderer::Client { | 42 public BrowserViewRenderer::Client { |
42 public: | 43 public: |
43 enum OnNewPictureMode { | 44 enum OnNewPictureMode { |
44 kOnNewPictureDisabled = 0, | 45 kOnNewPictureDisabled = 0, |
45 kOnNewPictureEnabled, | 46 kOnNewPictureEnabled, |
46 kOnNewPictureInvalidationOnly, | 47 kOnNewPictureInvalidationOnly, |
47 }; | 48 }; |
48 | 49 |
49 // Returns the AwContents instance associated with |web_contents|, or NULL. | 50 // Returns the AwContents instance associated with |web_contents|, or NULL. |
50 static AwContents* FromWebContents(content::WebContents* web_contents); | 51 static AwContents* FromWebContents(content::WebContents* web_contents); |
51 | 52 |
52 // Returns the AwContents instance associated with with the given | 53 // Returns the AwContents instance associated with with the given |
53 // render_process_id and render_view_id, or NULL. | 54 // render_process_id and render_view_id, or NULL. |
54 static AwContents* FromID(int render_process_id, int render_view_id); | 55 static AwContents* FromID(int render_process_id, int render_view_id); |
55 | 56 |
56 AwContents(JNIEnv* env, | 57 AwContents(JNIEnv* env, |
57 jobject obj, | 58 jobject obj, |
58 jobject web_contents_delegate); | 59 jobject web_contents_delegate, |
| 60 jobject contents_client_bridge); |
59 virtual ~AwContents(); | 61 virtual ~AwContents(); |
60 | 62 |
61 AwRenderViewHostExt* render_view_host_ext() { | 63 AwRenderViewHostExt* render_view_host_ext() { |
62 return render_view_host_ext_.get(); | 64 return render_view_host_ext_.get(); |
63 } | 65 } |
64 | 66 |
65 void RunJavaScriptDialog( | 67 void RunJavaScriptDialog( |
66 content::JavaScriptMessageType message_type, | 68 content::JavaScriptMessageType message_type, |
67 const GURL& origin_url, | 69 const GURL& origin_url, |
68 const string16& message_text, | 70 const string16& message_text, |
69 const string16& default_prompt_text, | 71 const string16& default_prompt_text, |
70 const base::android::ScopedJavaLocalRef<jobject>& js_result); | 72 const base::android::ScopedJavaLocalRef<jobject>& js_result); |
71 | 73 |
72 void RunBeforeUnloadDialog( | 74 void RunBeforeUnloadDialog( |
73 const GURL& origin_url, | 75 const GURL& origin_url, |
74 const string16& message_text, | 76 const string16& message_text, |
75 const base::android::ScopedJavaLocalRef<jobject>& js_result); | 77 const base::android::ScopedJavaLocalRef<jobject>& js_result); |
76 | 78 |
77 void PerformLongClick(); | 79 void PerformLongClick(); |
78 | 80 |
79 // |handler| is an instance of | 81 // |handler| is an instance of |
80 // org.chromium.android_webview.AwHttpAuthHandler. | 82 // org.chromium.android_webview.AwHttpAuthHandler. |
81 void OnReceivedHttpAuthRequest(const base::android::JavaRef<jobject>& handler, | 83 bool OnReceivedHttpAuthRequest(const base::android::JavaRef<jobject>& handler, |
82 const std::string& host, | 84 const std::string& host, |
83 const std::string& realm); | 85 const std::string& realm); |
84 | 86 |
85 // Methods called from Java. | 87 // Methods called from Java. |
86 jint GetWebContents(JNIEnv* env, jobject obj); | 88 jint GetWebContents(JNIEnv* env, jobject obj); |
87 void SetWebContents(JNIEnv* env, jobject obj, jint web_contents); | 89 void SetWebContents(JNIEnv* env, jobject obj, jint web_contents); |
| 90 jint GetAwContentsClientBridge(JNIEnv* env, jobject obj); |
88 | 91 |
89 void DidInitializeContentViewCore(JNIEnv* env, jobject obj, | 92 void DidInitializeContentViewCore(JNIEnv* env, jobject obj, |
90 jint content_view_core); | 93 jint content_view_core); |
91 void Destroy(JNIEnv* env, jobject obj); | 94 void Destroy(JNIEnv* env, jobject obj); |
92 void DocumentHasImages(JNIEnv* env, jobject obj, jobject message); | 95 void DocumentHasImages(JNIEnv* env, jobject obj, jobject message); |
93 void GenerateMHTML(JNIEnv* env, jobject obj, jstring jpath, jobject callback); | 96 void GenerateMHTML(JNIEnv* env, jobject obj, jstring jpath, jobject callback); |
94 void SetIoThreadClient(JNIEnv* env, jobject obj, jobject client); | 97 void SetIoThreadClient(JNIEnv* env, jobject obj, jobject client); |
95 void SetInterceptNavigationDelegate(JNIEnv* env, jobject obj, | 98 void SetInterceptNavigationDelegate(JNIEnv* env, jobject obj, |
96 jobject delegate); | 99 jobject delegate); |
97 void AddVisitedLinks(JNIEnv* env, jobject obj, jobjectArray jvisited_links); | 100 void AddVisitedLinks(JNIEnv* env, jobject obj, jobjectArray jvisited_links); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 void ClearCache(JNIEnv* env, jobject obj, jboolean include_disk_files); | 161 void ClearCache(JNIEnv* env, jobject obj, jboolean include_disk_files); |
159 void SetPendingWebContentsForPopup(scoped_ptr<content::WebContents> pending); | 162 void SetPendingWebContentsForPopup(scoped_ptr<content::WebContents> pending); |
160 jint ReleasePopupWebContents(JNIEnv* env, jobject obj); | 163 jint ReleasePopupWebContents(JNIEnv* env, jobject obj); |
161 | 164 |
162 private: | 165 private: |
163 void SetWebContents(content::WebContents* web_contents); | 166 void SetWebContents(content::WebContents* web_contents); |
164 | 167 |
165 JavaObjectWeakGlobalRef java_ref_; | 168 JavaObjectWeakGlobalRef java_ref_; |
166 scoped_ptr<content::WebContents> web_contents_; | 169 scoped_ptr<content::WebContents> web_contents_; |
167 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; | 170 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; |
| 171 scoped_ptr<AwContentsClientBridge> contents_client_bridge_; |
168 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_; | 172 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_; |
169 scoped_ptr<FindHelper> find_helper_; | 173 scoped_ptr<FindHelper> find_helper_; |
170 scoped_ptr<IconHelper> icon_helper_; | 174 scoped_ptr<IconHelper> icon_helper_; |
171 scoped_ptr<content::WebContents> pending_contents_; | 175 scoped_ptr<content::WebContents> pending_contents_; |
172 scoped_ptr<BrowserViewRenderer> browser_view_renderer_; | 176 scoped_ptr<BrowserViewRenderer> browser_view_renderer_; |
173 | 177 |
174 // GURL is supplied by the content layer as requesting frame. | 178 // GURL is supplied by the content layer as requesting frame. |
175 // Callback is supplied by the content layer, and is invoked with the result | 179 // Callback is supplied by the content layer, and is invoked with the result |
176 // from the permission prompt. | 180 // from the permission prompt. |
177 typedef std::pair<const GURL, base::Callback<void(bool)> > OriginCallback; | 181 typedef std::pair<const GURL, base::Callback<void(bool)> > OriginCallback; |
178 // The first element in the list is always the currently pending request. | 182 // The first element in the list is always the currently pending request. |
179 std::list<OriginCallback> pending_geolocation_prompts_; | 183 std::list<OriginCallback> pending_geolocation_prompts_; |
180 | 184 |
181 DISALLOW_COPY_AND_ASSIGN(AwContents); | 185 DISALLOW_COPY_AND_ASSIGN(AwContents); |
182 }; | 186 }; |
183 | 187 |
184 bool RegisterAwContents(JNIEnv* env); | 188 bool RegisterAwContents(JNIEnv* env); |
185 | 189 |
186 } // namespace android_webview | 190 } // namespace android_webview |
187 | 191 |
188 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ | 192 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ |
OLD | NEW |