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

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: rebase Created 7 years, 11 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/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, jobject obj, jobject canvas);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 bool window_visible, 102 bool window_visible,
95 bool view_visible); 103 bool view_visible);
96 void OnAttachedToWindow(JNIEnv* env, jobject obj, int w, int h); 104 void OnAttachedToWindow(JNIEnv* env, jobject obj, int w, int h);
97 void OnDetachedFromWindow(JNIEnv* env, jobject obj); 105 void OnDetachedFromWindow(JNIEnv* env, jobject obj);
98 base::android::ScopedJavaLocalRef<jbyteArray> GetOpaqueState( 106 base::android::ScopedJavaLocalRef<jbyteArray> GetOpaqueState(
99 JNIEnv* env, jobject obj); 107 JNIEnv* env, jobject obj);
100 jboolean RestoreFromOpaqueState(JNIEnv* env, jobject obj, jbyteArray state); 108 jboolean RestoreFromOpaqueState(JNIEnv* env, jobject obj, jbyteArray state);
101 void SetScrollForHWFrame(JNIEnv* env, jobject obj, 109 void SetScrollForHWFrame(JNIEnv* env, jobject obj,
102 int scroll_x, int scroll_y); 110 int scroll_x, int scroll_y);
103 void FocusFirstNode(JNIEnv* env, jobject obj); 111 void FocusFirstNode(JNIEnv* env, jobject obj);
112 base::android::ScopedJavaLocalRef<jobject> CapturePicture(JNIEnv* env,
113 jobject obj);
114 void EnableOnNewPicture(JNIEnv* env,
115 jobject obj,
116 jboolean enabled,
117 jboolean invalidation_only);
104 118
105 // Geolocation API support 119 // Geolocation API support
106 void OnGeolocationShowPrompt(int render_process_id, 120 void OnGeolocationShowPrompt(int render_process_id,
107 int render_view_id, 121 int render_view_id,
108 int bridge_id, 122 int bridge_id,
109 const GURL& requesting_frame); 123 const GURL& requesting_frame);
110 void OnGeolocationHidePrompt(); 124 void OnGeolocationHidePrompt();
111 125
112 // Find-in-page API and related methods. 126 // Find-in-page API and related methods.
113 jint FindAllSync(JNIEnv* env, jobject obj, jstring search_string); 127 jint FindAllSync(JNIEnv* env, jobject obj, jstring search_string);
(...skipping 12 matching lines...) Expand all
126 // content::Compositor::Client implementation. 140 // content::Compositor::Client implementation.
127 virtual void ScheduleComposite() OVERRIDE; 141 virtual void ScheduleComposite() OVERRIDE;
128 virtual void OnSwapBuffersCompleted() OVERRIDE; 142 virtual void OnSwapBuffersCompleted() OVERRIDE;
129 143
130 void SetPendingWebContentsForPopup(scoped_ptr<content::WebContents> pending); 144 void SetPendingWebContentsForPopup(scoped_ptr<content::WebContents> pending);
131 jint ReleasePopupWebContents(JNIEnv* env, jobject obj); 145 jint ReleasePopupWebContents(JNIEnv* env, jobject obj);
132 146
133 // AwRenderViewHostExt::Client implementation. 147 // AwRenderViewHostExt::Client implementation.
134 virtual void OnPictureUpdated(int process_id, int render_view_id) OVERRIDE; 148 virtual void OnPictureUpdated(int process_id, int render_view_id) OVERRIDE;
135 149
150 // Returns the latest locally available picture if any.
151 // If none is available will synchronously request the latest one
152 // and block until the result is received.
153 skia::RefPtr<SkPicture> GetLastCapturedPicture();
154
136 private: 155 private:
137 void Invalidate(); 156 void Invalidate();
138 void SetWebContents(content::WebContents* web_contents); 157 void SetWebContents(content::WebContents* web_contents);
139 void SetCompositorVisibility(bool visible); 158 void SetCompositorVisibility(bool visible);
140 void ResetCompositor(); 159 void ResetCompositor();
141 void AttachLayerTree(); 160 void AttachLayerTree();
142 161
143 JavaObjectWeakGlobalRef java_ref_; 162 JavaObjectWeakGlobalRef java_ref_;
144 scoped_ptr<content::WebContents> web_contents_; 163 scoped_ptr<content::WebContents> web_contents_;
145 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; 164 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_;
146 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_; 165 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_;
147 scoped_ptr<FindHelper> find_helper_; 166 scoped_ptr<FindHelper> find_helper_;
148 scoped_ptr<content::WebContents> pending_contents_; 167 scoped_ptr<content::WebContents> pending_contents_;
149 168
150 // Compositor-specific state. 169 // Compositor-specific state.
151 scoped_ptr<content::Compositor> compositor_; 170 scoped_ptr<content::Compositor> compositor_;
152 scoped_refptr<cc::Layer> scissor_clip_layer_; 171 scoped_refptr<cc::Layer> scissor_clip_layer_;
153 scoped_refptr<cc::Layer> transform_layer_; 172 scoped_refptr<cc::Layer> transform_layer_;
154 scoped_refptr<cc::Layer> view_clip_layer_; 173 scoped_refptr<cc::Layer> view_clip_layer_;
155 gfx::Point hw_rendering_scroll_; 174 gfx::Point hw_rendering_scroll_;
156 gfx::Size view_size_; 175 gfx::Size view_size_;
157 bool view_visible_; 176 bool view_visible_;
158 bool compositor_visible_; 177 bool compositor_visible_;
159 bool is_composite_pending_; 178 bool is_composite_pending_;
179 OnNewPictureMode on_new_picture_mode_;
160 180
161 // Used only for detecting Android View System context changes. 181 // Used only for detecting Android View System context changes.
162 // Not to be used between draw calls. 182 // Not to be used between draw calls.
163 EGLContext last_frame_context_; 183 EGLContext last_frame_context_;
164 184
165 DISALLOW_COPY_AND_ASSIGN(AwContents); 185 DISALLOW_COPY_AND_ASSIGN(AwContents);
166 }; 186 };
167 187
168 bool RegisterAwContents(JNIEnv* env); 188 bool RegisterAwContents(JNIEnv* env);
169 189
170 } // namespace android_webview 190 } // namespace android_webview
171 191
172 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ 192 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698