Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: android_webview/native/aw_contents.h

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

Powered by Google App Engine
This is Rietveld 408576698