| 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> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "android_webview/browser/aw_browser_permission_request_delegate.h" | 13 #include "android_webview/browser/aw_browser_permission_request_delegate.h" |
| 14 #include "android_webview/browser/aw_message_port_message_filter.h" | 14 #include "android_webview/browser/aw_message_port_message_filter.h" |
| 15 #include "android_webview/browser/browser_view_renderer.h" | 15 #include "android_webview/browser/browser_view_renderer.h" |
| 16 #include "android_webview/browser/browser_view_renderer_client.h" | 16 #include "android_webview/browser/browser_view_renderer_client.h" |
| 17 #include "android_webview/browser/find_helper.h" | 17 #include "android_webview/browser/find_helper.h" |
| 18 #include "android_webview/browser/gl_view_renderer_manager.h" | 18 #include "android_webview/browser/gl_view_renderer_manager.h" |
| 19 #include "android_webview/browser/icon_helper.h" | 19 #include "android_webview/browser/icon_helper.h" |
| 20 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" | 20 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" |
| 21 #include "android_webview/browser/shared_renderer_state.h" |
| 22 #include "android_webview/browser/shared_renderer_state_client.h" |
| 21 #include "android_webview/native/permission/permission_request_handler_client.h" | 23 #include "android_webview/native/permission/permission_request_handler_client.h" |
| 22 #include "base/android/jni_weak_ref.h" | 24 #include "base/android/jni_weak_ref.h" |
| 23 #include "base/android/scoped_java_ref.h" | 25 #include "base/android/scoped_java_ref.h" |
| 24 #include "base/callback_forward.h" | 26 #include "base/callback_forward.h" |
| 25 #include "base/macros.h" | 27 #include "base/macros.h" |
| 26 #include "base/memory/scoped_ptr.h" | 28 #include "base/memory/scoped_ptr.h" |
| 27 | 29 |
| 28 class SkBitmap; | 30 class SkBitmap; |
| 29 class TabContents; | 31 class TabContents; |
| 30 struct AwDrawGLInfo; | 32 struct AwDrawGLInfo; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 53 // hosts a popup will be rebound to a second native instance (carrying the | 55 // hosts a popup will be rebound to a second native instance (carrying the |
| 54 // popup content) and discard the 'default' native instance it made on | 56 // popup content) and discard the 'default' native instance it made on |
| 55 // construction. A native instance is only bound to at most one Java peer over | 57 // construction. A native instance is only bound to at most one Java peer over |
| 56 // its entire lifetime - see Init() and SetPendingWebContentsForPopup() for the | 58 // its entire lifetime - see Init() and SetPendingWebContentsForPopup() for the |
| 57 // construction points, and SetJavaPeers() where these paths join. | 59 // construction points, and SetJavaPeers() where these paths join. |
| 58 class AwContents : public FindHelper::Listener, | 60 class AwContents : public FindHelper::Listener, |
| 59 public IconHelper::Listener, | 61 public IconHelper::Listener, |
| 60 public AwRenderViewHostExtClient, | 62 public AwRenderViewHostExtClient, |
| 61 public BrowserViewRendererClient, | 63 public BrowserViewRendererClient, |
| 62 public PermissionRequestHandlerClient, | 64 public PermissionRequestHandlerClient, |
| 63 public AwBrowserPermissionRequestDelegate { | 65 public AwBrowserPermissionRequestDelegate, |
| 66 public SharedRendererStateClient { |
| 64 public: | 67 public: |
| 65 // Returns the AwContents instance associated with |web_contents|, or NULL. | 68 // Returns the AwContents instance associated with |web_contents|, or NULL. |
| 66 static AwContents* FromWebContents(content::WebContents* web_contents); | 69 static AwContents* FromWebContents(content::WebContents* web_contents); |
| 67 | 70 |
| 68 // Returns the AwContents instance associated with with the given | 71 // Returns the AwContents instance associated with with the given |
| 69 // render_process_id and render_view_id, or NULL. | 72 // render_process_id and render_view_id, or NULL. |
| 70 static AwContents* FromID(int render_process_id, int render_view_id); | 73 static AwContents* FromID(int render_process_id, int render_view_id); |
| 71 | 74 |
| 72 static std::string GetLocale(); | 75 static std::string GetLocale(); |
| 73 | 76 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 const GURL& origin) override; | 226 const GURL& origin) override; |
| 224 void RequestGeolocationPermission( | 227 void RequestGeolocationPermission( |
| 225 const GURL& origin, | 228 const GURL& origin, |
| 226 const base::Callback<void(bool)>& callback) override; | 229 const base::Callback<void(bool)>& callback) override; |
| 227 void CancelGeolocationPermissionRequests(const GURL& origin) override; | 230 void CancelGeolocationPermissionRequests(const GURL& origin) override; |
| 228 void RequestMIDISysexPermission( | 231 void RequestMIDISysexPermission( |
| 229 const GURL& origin, | 232 const GURL& origin, |
| 230 const base::Callback<void(bool)>& callback) override; | 233 const base::Callback<void(bool)>& callback) override; |
| 231 void CancelMIDISysexPermissionRequests(const GURL& origin) override; | 234 void CancelMIDISysexPermissionRequests(const GURL& origin) override; |
| 232 | 235 |
| 236 // SharedRendererStateClient implementation. |
| 237 bool RequestDrawGL(bool wait_for_completion) override; |
| 238 void DetachFunctorFromView() override; |
| 239 void DrawConstraintsUpdated( |
| 240 const ParentCompositorDrawConstraints& draw_constraints) override; |
| 241 bool IsHardwareEnabled() override; |
| 242 |
| 233 // Find-in-page API and related methods. | 243 // Find-in-page API and related methods. |
| 234 void FindAllAsync(JNIEnv* env, | 244 void FindAllAsync(JNIEnv* env, |
| 235 const base::android::JavaParamRef<jobject>& obj, | 245 const base::android::JavaParamRef<jobject>& obj, |
| 236 const base::android::JavaParamRef<jstring>& search_string); | 246 const base::android::JavaParamRef<jstring>& search_string); |
| 237 void FindNext(JNIEnv* env, | 247 void FindNext(JNIEnv* env, |
| 238 const base::android::JavaParamRef<jobject>& obj, | 248 const base::android::JavaParamRef<jobject>& obj, |
| 239 jboolean forward); | 249 jboolean forward); |
| 240 void ClearMatches(JNIEnv* env, | 250 void ClearMatches(JNIEnv* env, |
| 241 const base::android::JavaParamRef<jobject>& obj); | 251 const base::android::JavaParamRef<jobject>& obj); |
| 242 FindHelper* GetFindHelper(); | 252 FindHelper* GetFindHelper(); |
| 243 | 253 |
| 244 // Per WebView Cookie Policy | 254 // Per WebView Cookie Policy |
| 245 bool AllowThirdPartyCookies(); | 255 bool AllowThirdPartyCookies(); |
| 246 | 256 |
| 247 // FindHelper::Listener implementation. | 257 // FindHelper::Listener implementation. |
| 248 void OnFindResultReceived(int active_ordinal, | 258 void OnFindResultReceived(int active_ordinal, |
| 249 int match_count, | 259 int match_count, |
| 250 bool finished) override; | 260 bool finished) override; |
| 251 // IconHelper::Listener implementation. | 261 // IconHelper::Listener implementation. |
| 252 bool ShouldDownloadFavicon(const GURL& icon_url) override; | 262 bool ShouldDownloadFavicon(const GURL& icon_url) override; |
| 253 void OnReceivedIcon(const GURL& icon_url, const SkBitmap& bitmap) override; | 263 void OnReceivedIcon(const GURL& icon_url, const SkBitmap& bitmap) override; |
| 254 void OnReceivedTouchIconUrl(const std::string& url, | 264 void OnReceivedTouchIconUrl(const std::string& url, |
| 255 const bool precomposed) override; | 265 const bool precomposed) override; |
| 256 | 266 |
| 257 // AwRenderViewHostExtClient implementation. | 267 // AwRenderViewHostExtClient implementation. |
| 258 void OnWebLayoutPageScaleFactorChanged(float page_scale_factor) override; | 268 void OnWebLayoutPageScaleFactorChanged(float page_scale_factor) override; |
| 259 void OnWebLayoutContentsSizeChanged(const gfx::Size& contents_size) override; | 269 void OnWebLayoutContentsSizeChanged(const gfx::Size& contents_size) override; |
| 260 | 270 |
| 261 // BrowserViewRendererClient implementation. | 271 // BrowserViewRendererClient implementation. |
| 262 bool RequestDrawGL(bool wait_for_completion) override; | |
| 263 void PostInvalidate() override; | 272 void PostInvalidate() override; |
| 264 void DetachFunctorFromView() override; | |
| 265 void OnNewPicture() override; | 273 void OnNewPicture() override; |
| 266 gfx::Point GetLocationOnScreen() override; | 274 gfx::Point GetLocationOnScreen() override; |
| 267 void ScrollContainerViewTo(const gfx::Vector2d& new_value) override; | 275 void ScrollContainerViewTo(const gfx::Vector2d& new_value) override; |
| 268 void UpdateScrollState(const gfx::Vector2d& max_scroll_offset, | 276 void UpdateScrollState(const gfx::Vector2d& max_scroll_offset, |
| 269 const gfx::SizeF& contents_size_dip, | 277 const gfx::SizeF& contents_size_dip, |
| 270 float page_scale_factor, | 278 float page_scale_factor, |
| 271 float min_page_scale_factor, | 279 float min_page_scale_factor, |
| 272 float max_page_scale_factor) override; | 280 float max_page_scale_factor) override; |
| 273 void DidOverscroll(const gfx::Vector2d& overscroll_delta, | 281 void DidOverscroll(const gfx::Vector2d& overscroll_delta, |
| 274 const gfx::Vector2dF& overscroll_velocity) override; | 282 const gfx::Vector2dF& overscroll_velocity) override; |
| 275 | 283 |
| 276 void ParentDrawConstraintsUpdated( | |
| 277 const ParentCompositorDrawConstraints& draw_constraints) override {} | |
| 278 | |
| 279 void ClearCache(JNIEnv* env, | 284 void ClearCache(JNIEnv* env, |
| 280 const base::android::JavaParamRef<jobject>& obj, | 285 const base::android::JavaParamRef<jobject>& obj, |
| 281 jboolean include_disk_files); | 286 jboolean include_disk_files); |
| 282 void SetPendingWebContentsForPopup(scoped_ptr<content::WebContents> pending); | 287 void SetPendingWebContentsForPopup(scoped_ptr<content::WebContents> pending); |
| 283 jlong ReleasePopupAwContents(JNIEnv* env, | 288 jlong ReleasePopupAwContents(JNIEnv* env, |
| 284 const base::android::JavaParamRef<jobject>& obj); | 289 const base::android::JavaParamRef<jobject>& obj); |
| 285 | 290 |
| 286 void ScrollTo(JNIEnv* env, | 291 void ScrollTo(JNIEnv* env, |
| 287 const base::android::JavaParamRef<jobject>& obj, | 292 const base::android::JavaParamRef<jobject>& obj, |
| 288 jint x, | 293 jint x, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 | 328 |
| 324 void GrantFileSchemeAccesstoChildProcess( | 329 void GrantFileSchemeAccesstoChildProcess( |
| 325 JNIEnv* env, | 330 JNIEnv* env, |
| 326 const base::android::JavaParamRef<jobject>& obj); | 331 const base::android::JavaParamRef<jobject>& obj); |
| 327 | 332 |
| 328 void ResumeLoadingCreatedPopupWebContents( | 333 void ResumeLoadingCreatedPopupWebContents( |
| 329 JNIEnv* env, | 334 JNIEnv* env, |
| 330 const base::android::JavaParamRef<jobject>& obj); | 335 const base::android::JavaParamRef<jobject>& obj); |
| 331 | 336 |
| 332 private: | 337 private: |
| 338 void CleanUpUncommittedFrame(); |
| 339 void CleanUpReturnedResources(); |
| 340 |
| 341 bool OnDrawHardware(const gfx::Vector2d& scroll); |
| 342 bool OnDrawSoftware(const base::android::JavaRef<jobject>& canvas, |
| 343 const gfx::Vector2d& scroll); |
| 344 |
| 333 void InitAutofillIfNecessary(bool enabled); | 345 void InitAutofillIfNecessary(bool enabled); |
| 334 | 346 |
| 335 // Geolocation API support | 347 // Geolocation API support |
| 336 void ShowGeolocationPrompt(const GURL& origin, base::Callback<void(bool)>); | 348 void ShowGeolocationPrompt(const GURL& origin, base::Callback<void(bool)>); |
| 337 void HideGeolocationPrompt(const GURL& origin); | 349 void HideGeolocationPrompt(const GURL& origin); |
| 338 | 350 |
| 339 void SetDipScaleInternal(float dip_scale); | 351 void SetDipScaleInternal(float dip_scale); |
| 340 | 352 |
| 341 JavaObjectWeakGlobalRef java_ref_; | 353 JavaObjectWeakGlobalRef java_ref_; |
| 342 BrowserViewRenderer browser_view_renderer_; // Must outlive |web_contents_|. | 354 BrowserViewRenderer browser_view_renderer_; // Must outlive |web_contents_|. |
| 355 SharedRendererState shared_renderer_state_; |
| 343 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; | 356 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; |
| 344 scoped_ptr<AwContentsClientBridge> contents_client_bridge_; | 357 scoped_ptr<AwContentsClientBridge> contents_client_bridge_; |
| 345 scoped_ptr<content::WebContents> web_contents_; | 358 scoped_ptr<content::WebContents> web_contents_; |
| 346 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_; | 359 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_; |
| 347 scoped_ptr<FindHelper> find_helper_; | 360 scoped_ptr<FindHelper> find_helper_; |
| 348 scoped_ptr<IconHelper> icon_helper_; | 361 scoped_ptr<IconHelper> icon_helper_; |
| 349 scoped_ptr<AwContents> pending_contents_; | 362 scoped_ptr<AwContents> pending_contents_; |
| 350 scoped_ptr<AwPdfExporter> pdf_exporter_; | 363 scoped_ptr<AwPdfExporter> pdf_exporter_; |
| 351 scoped_ptr<PermissionRequestHandler> permission_request_handler_; | 364 scoped_ptr<PermissionRequestHandler> permission_request_handler_; |
| 352 scoped_refptr<AwMessagePortMessageFilter> message_port_message_filter_; | 365 scoped_refptr<AwMessagePortMessageFilter> message_port_message_filter_; |
| 353 | 366 |
| 354 // GURL is supplied by the content layer as requesting frame. | 367 // GURL is supplied by the content layer as requesting frame. |
| 355 // Callback is supplied by the content layer, and is invoked with the result | 368 // Callback is supplied by the content layer, and is invoked with the result |
| 356 // from the permission prompt. | 369 // from the permission prompt. |
| 357 typedef std::pair<const GURL, base::Callback<void(bool)> > OriginCallback; | 370 typedef std::pair<const GURL, base::Callback<void(bool)> > OriginCallback; |
| 358 // The first element in the list is always the currently pending request. | 371 // The first element in the list is always the currently pending request. |
| 359 std::list<OriginCallback> pending_geolocation_prompts_; | 372 std::list<OriginCallback> pending_geolocation_prompts_; |
| 360 | 373 |
| 361 GLViewRendererManager::Key renderer_manager_key_; | 374 GLViewRendererManager::Key renderer_manager_key_; |
| 362 | 375 |
| 363 DISALLOW_COPY_AND_ASSIGN(AwContents); | 376 DISALLOW_COPY_AND_ASSIGN(AwContents); |
| 364 }; | 377 }; |
| 365 | 378 |
| 366 bool RegisterAwContents(JNIEnv* env); | 379 bool RegisterAwContents(JNIEnv* env); |
| 367 | 380 |
| 368 } // namespace android_webview | 381 } // namespace android_webview |
| 369 | 382 |
| 370 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ | 383 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ |
| OLD | NEW |