| 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/browser/view_renderer.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" | |
| 18 #include "content/public/browser/javascript_dialogs.h" | 17 #include "content/public/browser/javascript_dialogs.h" |
| 19 | 18 |
| 20 typedef void* EGLContext; | |
| 21 class TabContents; | 19 class TabContents; |
| 22 | 20 |
| 23 namespace cc { | |
| 24 class Layer; | |
| 25 } | |
| 26 | |
| 27 namespace content { | 21 namespace content { |
| 28 class Compositor; | |
| 29 class WebContents; | 22 class WebContents; |
| 30 } | 23 } |
| 31 | 24 |
| 32 namespace android_webview { | 25 namespace android_webview { |
| 33 | 26 |
| 34 class AwContentsContainer; | 27 class AwContentsContainer; |
| 35 class AwWebContentsDelegate; | 28 class AwWebContentsDelegate; |
| 36 | 29 |
| 37 // Native side of java-class of same name. | 30 // Native side of java-class of same name. |
| 38 // Provides the ownership of and access to browser components required for | 31 // Provides the ownership of and access to browser components required for |
| 39 // WebView functionality; analogous to chrome's TabContents, but with a | 32 // WebView functionality; analogous to chrome's TabContents, but with a |
| 40 // level of indirection provided by the AwContentsContainer abstraction. | 33 // level of indirection provided by the AwContentsContainer abstraction. |
| 41 class AwContents : public FindHelper::Listener, | 34 class AwContents : public FindHelper::Listener, |
| 42 public content::Compositor::Client, | 35 public ViewRenderer::Client { |
| 43 public AwRenderViewHostExt::Client { | |
| 44 public: | 36 public: |
| 45 // Returns the AwContents instance associated with |web_contents|, or NULL. | 37 // Returns the AwContents instance associated with |web_contents|, or NULL. |
| 46 static AwContents* FromWebContents(content::WebContents* web_contents); | 38 static AwContents* FromWebContents(content::WebContents* web_contents); |
| 47 | 39 |
| 48 AwContents(JNIEnv* env, | 40 AwContents(JNIEnv* env, |
| 49 jobject obj, | 41 jobject obj, |
| 50 jobject web_contents_delegate); | 42 jobject web_contents_delegate); |
| 51 virtual ~AwContents(); | 43 virtual ~AwContents(); |
| 52 | 44 |
| 53 void DrawGL(AwDrawGLInfo* draw_info); | |
| 54 bool DrawSW(JNIEnv* env, jobject obj, jobject canvas); | |
| 55 | |
| 56 void RunJavaScriptDialog( | 45 void RunJavaScriptDialog( |
| 57 content::JavaScriptMessageType message_type, | 46 content::JavaScriptMessageType message_type, |
| 58 const GURL& origin_url, | 47 const GURL& origin_url, |
| 59 const string16& message_text, | 48 const string16& message_text, |
| 60 const string16& default_prompt_text, | 49 const string16& default_prompt_text, |
| 61 const base::android::ScopedJavaLocalRef<jobject>& js_result); | 50 const base::android::ScopedJavaLocalRef<jobject>& js_result); |
| 62 | 51 |
| 63 void RunBeforeUnloadDialog( | 52 void RunBeforeUnloadDialog( |
| 64 const GURL& origin_url, | 53 const GURL& origin_url, |
| 65 const string16& message_text, | 54 const string16& message_text, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 91 void UpdateLastHitTestData(JNIEnv* env, jobject obj); | 80 void UpdateLastHitTestData(JNIEnv* env, jobject obj); |
| 92 void OnSizeChanged(JNIEnv* env, jobject obj, int w, int h, int ow, int oh); | 81 void OnSizeChanged(JNIEnv* env, jobject obj, int w, int h, int ow, int oh); |
| 93 void SetWindowViewVisibility(JNIEnv* env, jobject obj, | 82 void SetWindowViewVisibility(JNIEnv* env, jobject obj, |
| 94 bool window_visible, | 83 bool window_visible, |
| 95 bool view_visible); | 84 bool view_visible); |
| 96 void OnAttachedToWindow(JNIEnv* env, jobject obj, int w, int h); | 85 void OnAttachedToWindow(JNIEnv* env, jobject obj, int w, int h); |
| 97 void OnDetachedFromWindow(JNIEnv* env, jobject obj); | 86 void OnDetachedFromWindow(JNIEnv* env, jobject obj); |
| 98 base::android::ScopedJavaLocalRef<jbyteArray> GetOpaqueState( | 87 base::android::ScopedJavaLocalRef<jbyteArray> GetOpaqueState( |
| 99 JNIEnv* env, jobject obj); | 88 JNIEnv* env, jobject obj); |
| 100 jboolean RestoreFromOpaqueState(JNIEnv* env, jobject obj, jbyteArray state); | 89 jboolean RestoreFromOpaqueState(JNIEnv* env, jobject obj, jbyteArray state); |
| 90 void FocusFirstNode(JNIEnv* env, jobject obj); |
| 91 bool DrawSW(JNIEnv* env, |
| 92 jobject obj, |
| 93 jobject canvas, |
| 94 jint clip_x, |
| 95 jint clip_y, |
| 96 jint clip_w, |
| 97 jint clip_h); |
| 101 void SetScrollForHWFrame(JNIEnv* env, jobject obj, | 98 void SetScrollForHWFrame(JNIEnv* env, jobject obj, |
| 102 int scroll_x, int scroll_y); | 99 int scroll_x, int scroll_y); |
| 103 void FocusFirstNode(JNIEnv* env, jobject obj); | 100 jint GetAwDrawGLViewContext(JNIEnv* env, jobject obj); |
| 101 base::android::ScopedJavaLocalRef<jobject> CapturePicture(JNIEnv* env, |
| 102 jobject obj); |
| 103 void EnableOnNewPicture(JNIEnv* env, |
| 104 jobject obj, |
| 105 jboolean enabled, |
| 106 jboolean invalidation_only); |
| 104 | 107 |
| 105 // Geolocation API support | 108 // Geolocation API support |
| 106 void OnGeolocationShowPrompt(int render_process_id, | 109 void OnGeolocationShowPrompt(int render_process_id, |
| 107 int render_view_id, | 110 int render_view_id, |
| 108 int bridge_id, | 111 int bridge_id, |
| 109 const GURL& requesting_frame); | 112 const GURL& requesting_frame); |
| 110 void OnGeolocationHidePrompt(); | 113 void OnGeolocationHidePrompt(); |
| 111 | 114 |
| 112 // Find-in-page API and related methods. | 115 // Find-in-page API and related methods. |
| 113 jint FindAllSync(JNIEnv* env, jobject obj, jstring search_string); | 116 jint FindAllSync(JNIEnv* env, jobject obj, jstring search_string); |
| 114 void FindAllAsync(JNIEnv* env, jobject obj, jstring search_string); | 117 void FindAllAsync(JNIEnv* env, jobject obj, jstring search_string); |
| 115 void FindNext(JNIEnv* env, jobject obj, jboolean forward); | 118 void FindNext(JNIEnv* env, jobject obj, jboolean forward); |
| 116 void ClearMatches(JNIEnv* env, jobject obj); | 119 void ClearMatches(JNIEnv* env, jobject obj); |
| 117 void ClearCache(JNIEnv* env, jobject obj, jboolean include_disk_files); | |
| 118 | |
| 119 FindHelper* GetFindHelper(); | 120 FindHelper* GetFindHelper(); |
| 120 | 121 |
| 121 // FindHelper::Listener implementation. | 122 // FindHelper::Listener implementation. |
| 122 virtual void OnFindResultReceived(int active_ordinal, | 123 virtual void OnFindResultReceived(int active_ordinal, |
| 123 int match_count, | 124 int match_count, |
| 124 bool finished) OVERRIDE; | 125 bool finished) OVERRIDE; |
| 125 | 126 |
| 126 // content::Compositor::Client implementation. | 127 // ViewRenderer::Client implementation. |
| 127 virtual void ScheduleComposite() OVERRIDE; | 128 virtual void Invalidate() OVERRIDE; |
| 128 virtual void OnSwapBuffersCompleted() OVERRIDE; | 129 virtual void OnNewPicture( |
| 130 base::android::ScopedJavaLocalRef<jobject> picture) OVERRIDE; |
| 129 | 131 |
| 132 void ClearCache(JNIEnv* env, jobject obj, jboolean include_disk_files); |
| 130 void SetPendingWebContentsForPopup(scoped_ptr<content::WebContents> pending); | 133 void SetPendingWebContentsForPopup(scoped_ptr<content::WebContents> pending); |
| 131 jint ReleasePopupWebContents(JNIEnv* env, jobject obj); | 134 jint ReleasePopupWebContents(JNIEnv* env, jobject obj); |
| 132 | 135 |
| 133 // AwRenderViewHostExt::Client implementation. | |
| 134 virtual void OnPictureUpdated(int process_id, int render_view_id) OVERRIDE; | |
| 135 | |
| 136 private: | 136 private: |
| 137 void Invalidate(); | |
| 138 void SetWebContents(content::WebContents* web_contents); | 137 void SetWebContents(content::WebContents* web_contents); |
| 139 void SetCompositorVisibility(bool visible); | |
| 140 void ResetCompositor(); | |
| 141 void AttachLayerTree(); | |
| 142 | 138 |
| 143 JavaObjectWeakGlobalRef java_ref_; | 139 JavaObjectWeakGlobalRef java_ref_; |
| 144 scoped_ptr<content::WebContents> web_contents_; | 140 scoped_ptr<content::WebContents> web_contents_; |
| 145 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; | 141 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; |
| 146 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_; | 142 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_; |
| 147 scoped_ptr<FindHelper> find_helper_; | 143 scoped_ptr<FindHelper> find_helper_; |
| 148 scoped_ptr<content::WebContents> pending_contents_; | 144 scoped_ptr<content::WebContents> pending_contents_; |
| 149 | 145 scoped_ptr<ViewRenderer> view_renderer_; |
| 150 // Compositor-specific state. | |
| 151 scoped_ptr<content::Compositor> compositor_; | |
| 152 scoped_refptr<cc::Layer> scissor_clip_layer_; | |
| 153 scoped_refptr<cc::Layer> transform_layer_; | |
| 154 scoped_refptr<cc::Layer> view_clip_layer_; | |
| 155 gfx::Point hw_rendering_scroll_; | |
| 156 gfx::Size view_size_; | |
| 157 bool view_visible_; | |
| 158 bool compositor_visible_; | |
| 159 bool is_composite_pending_; | |
| 160 | |
| 161 // Used only for detecting Android View System context changes. | |
| 162 // Not to be used between draw calls. | |
| 163 EGLContext last_frame_context_; | |
| 164 | 146 |
| 165 DISALLOW_COPY_AND_ASSIGN(AwContents); | 147 DISALLOW_COPY_AND_ASSIGN(AwContents); |
| 166 }; | 148 }; |
| 167 | 149 |
| 168 bool RegisterAwContents(JNIEnv* env); | 150 bool RegisterAwContents(JNIEnv* env); |
| 169 | 151 |
| 170 } // namespace android_webview | 152 } // namespace android_webview |
| 171 | 153 |
| 172 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ | 154 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ |
| OLD | NEW |