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 "android_webview/browser/find_helper.h" |
12 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" | 12 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" |
13 #include "android_webview/public/browser/draw_gl.h" | 13 #include "android_webview/public/browser/draw_gl.h" |
14 #include "base/android/scoped_java_ref.h" | 14 #include "base/android/scoped_java_ref.h" |
15 #include "base/android/jni_helper.h" | 15 #include "base/android/jni_helper.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "content/public/browser/android/compositor.h" | 17 #include "content/public/browser/android/compositor.h" |
18 #include "content/public/browser/javascript_dialogs.h" | 18 #include "content/public/browser/javascript_dialogs.h" |
| 19 #include "skia/ext/refptr.h" |
| 20 #include "third_party/skia/include/core/SkPicture.h" |
19 | 21 |
20 typedef void* EGLContext; | 22 typedef void* EGLContext; |
21 class TabContents; | 23 class TabContents; |
22 | 24 |
23 namespace cc { | 25 namespace cc { |
24 class Layer; | 26 class Layer; |
25 } | 27 } |
26 | 28 |
27 namespace content { | 29 namespace content { |
28 class Compositor; | 30 class Compositor; |
29 class WebContents; | 31 class WebContents; |
30 } | 32 } |
31 | 33 |
32 namespace android_webview { | 34 namespace android_webview { |
33 | 35 |
34 class AwContentsContainer; | 36 class AwContentsContainer; |
35 class AwWebContentsDelegate; | 37 class AwWebContentsDelegate; |
36 | 38 |
37 // Native side of java-class of same name. | 39 // Native side of java-class of same name. |
38 // Provides the ownership of and access to browser components required for | 40 // Provides the ownership of and access to browser components required for |
39 // WebView functionality; analogous to chrome's TabContents, but with a | 41 // WebView functionality; analogous to chrome's TabContents, but with a |
40 // level of indirection provided by the AwContentsContainer abstraction. | 42 // level of indirection provided by the AwContentsContainer abstraction. |
41 class AwContents : public FindHelper::Listener, | 43 class AwContents : public FindHelper::Listener, |
42 public content::Compositor::Client, | 44 public content::Compositor::Client, |
43 public AwRenderViewHostExt::Client { | 45 public AwRenderViewHostExt::Client { |
44 public: | 46 public: |
| 47 enum OnNewPictureMode { |
| 48 kOnNewPictureDisabled = 0, |
| 49 kOnNewPictureEnabled, |
| 50 kOnNewPictureInvalidationOnly, |
| 51 }; |
| 52 |
45 // Returns the AwContents instance associated with |web_contents|, or NULL. | 53 // Returns the AwContents instance associated with |web_contents|, or NULL. |
46 static AwContents* FromWebContents(content::WebContents* web_contents); | 54 static AwContents* FromWebContents(content::WebContents* web_contents); |
47 | 55 |
48 AwContents(JNIEnv* env, | 56 AwContents(JNIEnv* env, |
49 jobject obj, | 57 jobject obj, |
50 jobject web_contents_delegate); | 58 jobject web_contents_delegate); |
51 virtual ~AwContents(); | 59 virtual ~AwContents(); |
52 | 60 |
53 void DrawGL(AwDrawGLInfo* draw_info); | 61 void DrawGL(AwDrawGLInfo* draw_info); |
54 bool DrawSW(JNIEnv* env, jobject obj, jobject canvas); | 62 bool DrawSW(JNIEnv* env, |
| 63 jobject obj, |
| 64 jobject canvas, |
| 65 jint clip_x, |
| 66 jint clip_y, |
| 67 jint clip_w, |
| 68 jint clip_h); |
55 | 69 |
56 void RunJavaScriptDialog( | 70 void RunJavaScriptDialog( |
57 content::JavaScriptMessageType message_type, | 71 content::JavaScriptMessageType message_type, |
58 const GURL& origin_url, | 72 const GURL& origin_url, |
59 const string16& message_text, | 73 const string16& message_text, |
60 const string16& default_prompt_text, | 74 const string16& default_prompt_text, |
61 const base::android::ScopedJavaLocalRef<jobject>& js_result); | 75 const base::android::ScopedJavaLocalRef<jobject>& js_result); |
62 | 76 |
63 void RunBeforeUnloadDialog( | 77 void RunBeforeUnloadDialog( |
64 const GURL& origin_url, | 78 const GURL& origin_url, |
(...skipping 29 matching lines...) Expand all Loading... |
94 bool window_visible, | 108 bool window_visible, |
95 bool view_visible); | 109 bool view_visible); |
96 void OnAttachedToWindow(JNIEnv* env, jobject obj, int w, int h); | 110 void OnAttachedToWindow(JNIEnv* env, jobject obj, int w, int h); |
97 void OnDetachedFromWindow(JNIEnv* env, jobject obj); | 111 void OnDetachedFromWindow(JNIEnv* env, jobject obj); |
98 base::android::ScopedJavaLocalRef<jbyteArray> GetOpaqueState( | 112 base::android::ScopedJavaLocalRef<jbyteArray> GetOpaqueState( |
99 JNIEnv* env, jobject obj); | 113 JNIEnv* env, jobject obj); |
100 jboolean RestoreFromOpaqueState(JNIEnv* env, jobject obj, jbyteArray state); | 114 jboolean RestoreFromOpaqueState(JNIEnv* env, jobject obj, jbyteArray state); |
101 void SetScrollForHWFrame(JNIEnv* env, jobject obj, | 115 void SetScrollForHWFrame(JNIEnv* env, jobject obj, |
102 int scroll_x, int scroll_y); | 116 int scroll_x, int scroll_y); |
103 void FocusFirstNode(JNIEnv* env, jobject obj); | 117 void FocusFirstNode(JNIEnv* env, jobject obj); |
| 118 base::android::ScopedJavaLocalRef<jobject> CapturePicture(JNIEnv* env, |
| 119 jobject obj); |
| 120 void EnableOnNewPicture(JNIEnv* env, |
| 121 jobject obj, |
| 122 jboolean enabled, |
| 123 jboolean invalidation_only); |
104 | 124 |
105 // Geolocation API support | 125 // Geolocation API support |
106 void OnGeolocationShowPrompt(int render_process_id, | 126 void OnGeolocationShowPrompt(int render_process_id, |
107 int render_view_id, | 127 int render_view_id, |
108 int bridge_id, | 128 int bridge_id, |
109 const GURL& requesting_frame); | 129 const GURL& requesting_frame); |
110 void OnGeolocationHidePrompt(); | 130 void OnGeolocationHidePrompt(); |
111 | 131 |
112 // Find-in-page API and related methods. | 132 // Find-in-page API and related methods. |
113 jint FindAllSync(JNIEnv* env, jobject obj, jstring search_string); | 133 jint FindAllSync(JNIEnv* env, jobject obj, jstring search_string); |
(...skipping 12 matching lines...) Expand all Loading... |
126 // content::Compositor::Client implementation. | 146 // content::Compositor::Client implementation. |
127 virtual void ScheduleComposite() OVERRIDE; | 147 virtual void ScheduleComposite() OVERRIDE; |
128 virtual void OnSwapBuffersCompleted() OVERRIDE; | 148 virtual void OnSwapBuffersCompleted() OVERRIDE; |
129 | 149 |
130 void SetPendingWebContentsForPopup(scoped_ptr<content::WebContents> pending); | 150 void SetPendingWebContentsForPopup(scoped_ptr<content::WebContents> pending); |
131 jint ReleasePopupWebContents(JNIEnv* env, jobject obj); | 151 jint ReleasePopupWebContents(JNIEnv* env, jobject obj); |
132 | 152 |
133 // AwRenderViewHostExt::Client implementation. | 153 // AwRenderViewHostExt::Client implementation. |
134 virtual void OnPictureUpdated(int process_id, int render_view_id) OVERRIDE; | 154 virtual void OnPictureUpdated(int process_id, int render_view_id) OVERRIDE; |
135 | 155 |
| 156 // Returns the latest locally available picture if any. |
| 157 // If none is available will synchronously request the latest one |
| 158 // and block until the result is received. |
| 159 skia::RefPtr<SkPicture> GetLastCapturedPicture(); |
| 160 |
136 private: | 161 private: |
137 void Invalidate(); | 162 void Invalidate(); |
138 void SetWebContents(content::WebContents* web_contents); | 163 void SetWebContents(content::WebContents* web_contents); |
139 void SetCompositorVisibility(bool visible); | 164 void SetCompositorVisibility(bool visible); |
140 void ResetCompositor(); | 165 void ResetCompositor(); |
141 void AttachLayerTree(); | 166 void AttachLayerTree(); |
| 167 bool RenderSW(SkCanvas* canvas); |
| 168 bool RenderPicture(SkCanvas* canvas); |
142 | 169 |
143 JavaObjectWeakGlobalRef java_ref_; | 170 JavaObjectWeakGlobalRef java_ref_; |
144 scoped_ptr<content::WebContents> web_contents_; | 171 scoped_ptr<content::WebContents> web_contents_; |
145 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; | 172 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; |
146 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_; | 173 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_; |
147 scoped_ptr<FindHelper> find_helper_; | 174 scoped_ptr<FindHelper> find_helper_; |
148 scoped_ptr<content::WebContents> pending_contents_; | 175 scoped_ptr<content::WebContents> pending_contents_; |
149 | 176 |
150 // Compositor-specific state. | 177 // Compositor-specific state. |
151 scoped_ptr<content::Compositor> compositor_; | 178 scoped_ptr<content::Compositor> compositor_; |
152 scoped_refptr<cc::Layer> scissor_clip_layer_; | 179 scoped_refptr<cc::Layer> scissor_clip_layer_; |
153 scoped_refptr<cc::Layer> transform_layer_; | 180 scoped_refptr<cc::Layer> transform_layer_; |
154 scoped_refptr<cc::Layer> view_clip_layer_; | 181 scoped_refptr<cc::Layer> view_clip_layer_; |
155 gfx::Point hw_rendering_scroll_; | 182 gfx::Point hw_rendering_scroll_; |
156 gfx::Size view_size_; | 183 gfx::Size view_size_; |
157 bool view_visible_; | 184 bool view_visible_; |
158 bool compositor_visible_; | 185 bool compositor_visible_; |
159 bool is_composite_pending_; | 186 bool is_composite_pending_; |
| 187 OnNewPictureMode on_new_picture_mode_; |
160 | 188 |
161 // Used only for detecting Android View System context changes. | 189 // Used only for detecting Android View System context changes. |
162 // Not to be used between draw calls. | 190 // Not to be used between draw calls. |
163 EGLContext last_frame_context_; | 191 EGLContext last_frame_context_; |
164 | 192 |
165 DISALLOW_COPY_AND_ASSIGN(AwContents); | 193 DISALLOW_COPY_AND_ASSIGN(AwContents); |
166 }; | 194 }; |
167 | 195 |
168 bool RegisterAwContents(JNIEnv* env); | 196 bool RegisterAwContents(JNIEnv* env); |
169 | 197 |
170 } // namespace android_webview | 198 } // namespace android_webview |
171 | 199 |
172 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ | 200 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ |
OLD | NEW |