Chromium Code Reviews| 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 |
| 74 AwContents(scoped_ptr<content::WebContents> web_contents); | 77 AwContents(scoped_ptr<content::WebContents> web_contents); |
| 75 ~AwContents() override; | 78 ~AwContents() override; |
| 76 | 79 |
| 77 AwRenderViewHostExt* render_view_host_ext() { | 80 AwRenderViewHostExt* render_view_host_ext() { |
| 78 return render_view_host_ext_.get(); | 81 return render_view_host_ext_.get(); |
| 79 } | 82 } |
| 80 | 83 |
| 81 // |handler| is an instance of | 84 // |handler| is an instance of |
| 82 // org.chromium.android_webview.AwHttpAuthHandler. | 85 // org.chromium.android_webview.AwHttpAuthHandler. |
| 83 bool OnReceivedHttpAuthRequest(const base::android::JavaRef<jobject>& handler, | 86 bool OnReceivedHttpAuthRequest(const base::android::JavaRef<jobject>& handler, |
| 84 const std::string& host, | 87 const std::string& host, |
| 85 const std::string& realm); | 88 const std::string& realm); |
| 86 | 89 |
| 87 void SetOffscreenPreRaster(bool enabled); | 90 void SetOffscreenPreRaster(bool enabled); |
| 88 | 91 |
| 92 void CreateSharedRendererState(); | |
|
boliu
2016/03/30 17:21:52
new stuff from next patch, here and on line 104?
| |
| 93 | |
| 89 // Methods called from Java. | 94 // Methods called from Java. |
| 90 void SetJavaPeers( | 95 void SetJavaPeers( |
| 91 JNIEnv* env, | 96 JNIEnv* env, |
| 92 const base::android::JavaParamRef<jobject>& obj, | 97 const base::android::JavaParamRef<jobject>& obj, |
| 93 const base::android::JavaParamRef<jobject>& aw_contents, | 98 const base::android::JavaParamRef<jobject>& aw_contents, |
| 94 const base::android::JavaParamRef<jobject>& web_contents_delegate, | 99 const base::android::JavaParamRef<jobject>& web_contents_delegate, |
| 95 const base::android::JavaParamRef<jobject>& contents_client_bridge, | 100 const base::android::JavaParamRef<jobject>& contents_client_bridge, |
| 96 const base::android::JavaParamRef<jobject>& io_thread_client, | 101 const base::android::JavaParamRef<jobject>& io_thread_client, |
| 97 const base::android::JavaParamRef<jobject>& | 102 const base::android::JavaParamRef<jobject>& |
| 98 intercept_navigation_delegate); | 103 intercept_navigation_delegate); |
| 104 jlong CreateSharedRendererState( | |
| 105 JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | |
| 99 base::android::ScopedJavaLocalRef<jobject> GetWebContents( | 106 base::android::ScopedJavaLocalRef<jobject> GetWebContents( |
| 100 JNIEnv* env, | 107 JNIEnv* env, |
| 101 const base::android::JavaParamRef<jobject>& obj); | 108 const base::android::JavaParamRef<jobject>& obj); |
| 102 | 109 |
| 103 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | 110 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
| 104 void DocumentHasImages(JNIEnv* env, | 111 void DocumentHasImages(JNIEnv* env, |
| 105 const base::android::JavaParamRef<jobject>& obj, | 112 const base::android::JavaParamRef<jobject>& obj, |
| 106 const base::android::JavaParamRef<jobject>& message); | 113 const base::android::JavaParamRef<jobject>& message); |
| 107 void GenerateMHTML(JNIEnv* env, | 114 void GenerateMHTML(JNIEnv* env, |
| 108 const base::android::JavaParamRef<jobject>& obj, | 115 const base::android::JavaParamRef<jobject>& obj, |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 const GURL& origin) override; | 230 const GURL& origin) override; |
| 224 void RequestGeolocationPermission( | 231 void RequestGeolocationPermission( |
| 225 const GURL& origin, | 232 const GURL& origin, |
| 226 const base::Callback<void(bool)>& callback) override; | 233 const base::Callback<void(bool)>& callback) override; |
| 227 void CancelGeolocationPermissionRequests(const GURL& origin) override; | 234 void CancelGeolocationPermissionRequests(const GURL& origin) override; |
| 228 void RequestMIDISysexPermission( | 235 void RequestMIDISysexPermission( |
| 229 const GURL& origin, | 236 const GURL& origin, |
| 230 const base::Callback<void(bool)>& callback) override; | 237 const base::Callback<void(bool)>& callback) override; |
| 231 void CancelMIDISysexPermissionRequests(const GURL& origin) override; | 238 void CancelMIDISysexPermissionRequests(const GURL& origin) override; |
| 232 | 239 |
| 240 // SharedRendererStateClient implementation. | |
| 241 void OnParentDrawConstraintsUpdated() override; | |
| 242 bool RequestDrawGL(bool wait_for_completion) override; | |
| 243 void DetachFunctorFromView() override; | |
| 244 | |
| 233 // Find-in-page API and related methods. | 245 // Find-in-page API and related methods. |
| 234 void FindAllAsync(JNIEnv* env, | 246 void FindAllAsync(JNIEnv* env, |
| 235 const base::android::JavaParamRef<jobject>& obj, | 247 const base::android::JavaParamRef<jobject>& obj, |
| 236 const base::android::JavaParamRef<jstring>& search_string); | 248 const base::android::JavaParamRef<jstring>& search_string); |
| 237 void FindNext(JNIEnv* env, | 249 void FindNext(JNIEnv* env, |
| 238 const base::android::JavaParamRef<jobject>& obj, | 250 const base::android::JavaParamRef<jobject>& obj, |
| 239 jboolean forward); | 251 jboolean forward); |
| 240 void ClearMatches(JNIEnv* env, | 252 void ClearMatches(JNIEnv* env, |
| 241 const base::android::JavaParamRef<jobject>& obj); | 253 const base::android::JavaParamRef<jobject>& obj); |
| 242 FindHelper* GetFindHelper(); | 254 FindHelper* GetFindHelper(); |
| 243 | 255 |
| 244 // Per WebView Cookie Policy | 256 // Per WebView Cookie Policy |
| 245 bool AllowThirdPartyCookies(); | 257 bool AllowThirdPartyCookies(); |
| 246 | 258 |
| 247 // FindHelper::Listener implementation. | 259 // FindHelper::Listener implementation. |
| 248 void OnFindResultReceived(int active_ordinal, | 260 void OnFindResultReceived(int active_ordinal, |
| 249 int match_count, | 261 int match_count, |
| 250 bool finished) override; | 262 bool finished) override; |
| 251 // IconHelper::Listener implementation. | 263 // IconHelper::Listener implementation. |
| 252 bool ShouldDownloadFavicon(const GURL& icon_url) override; | 264 bool ShouldDownloadFavicon(const GURL& icon_url) override; |
| 253 void OnReceivedIcon(const GURL& icon_url, const SkBitmap& bitmap) override; | 265 void OnReceivedIcon(const GURL& icon_url, const SkBitmap& bitmap) override; |
| 254 void OnReceivedTouchIconUrl(const std::string& url, | 266 void OnReceivedTouchIconUrl(const std::string& url, |
| 255 const bool precomposed) override; | 267 const bool precomposed) override; |
| 256 | 268 |
| 257 // AwRenderViewHostExtClient implementation. | 269 // AwRenderViewHostExtClient implementation. |
| 258 void OnWebLayoutPageScaleFactorChanged(float page_scale_factor) override; | 270 void OnWebLayoutPageScaleFactorChanged(float page_scale_factor) override; |
| 259 void OnWebLayoutContentsSizeChanged(const gfx::Size& contents_size) override; | 271 void OnWebLayoutContentsSizeChanged(const gfx::Size& contents_size) override; |
| 260 | 272 |
| 261 // BrowserViewRendererClient implementation. | 273 // BrowserViewRendererClient implementation. |
| 262 bool RequestDrawGL(bool wait_for_completion) override; | |
| 263 void PostInvalidate() override; | 274 void PostInvalidate() override; |
| 264 void DetachFunctorFromView() override; | |
| 265 void OnNewPicture() override; | 275 void OnNewPicture() override; |
| 266 gfx::Point GetLocationOnScreen() override; | 276 gfx::Point GetLocationOnScreen() override; |
| 267 void ScrollContainerViewTo(const gfx::Vector2d& new_value) override; | 277 void ScrollContainerViewTo(const gfx::Vector2d& new_value) override; |
| 268 void UpdateScrollState(const gfx::Vector2d& max_scroll_offset, | 278 void UpdateScrollState(const gfx::Vector2d& max_scroll_offset, |
| 269 const gfx::SizeF& contents_size_dip, | 279 const gfx::SizeF& contents_size_dip, |
| 270 float page_scale_factor, | 280 float page_scale_factor, |
| 271 float min_page_scale_factor, | 281 float min_page_scale_factor, |
| 272 float max_page_scale_factor) override; | 282 float max_page_scale_factor) override; |
| 273 void DidOverscroll(const gfx::Vector2d& overscroll_delta, | 283 void DidOverscroll(const gfx::Vector2d& overscroll_delta, |
| 274 const gfx::Vector2dF& overscroll_velocity) override; | 284 const gfx::Vector2dF& overscroll_velocity) override; |
| 275 | 285 |
| 276 void ParentDrawConstraintsUpdated( | |
| 277 const ParentCompositorDrawConstraints& draw_constraints) override {} | |
| 278 | |
| 279 void ClearCache(JNIEnv* env, | 286 void ClearCache(JNIEnv* env, |
| 280 const base::android::JavaParamRef<jobject>& obj, | 287 const base::android::JavaParamRef<jobject>& obj, |
| 281 jboolean include_disk_files); | 288 jboolean include_disk_files); |
| 282 void SetPendingWebContentsForPopup(scoped_ptr<content::WebContents> pending); | 289 void SetPendingWebContentsForPopup(scoped_ptr<content::WebContents> pending); |
| 283 jlong ReleasePopupAwContents(JNIEnv* env, | 290 jlong ReleasePopupAwContents(JNIEnv* env, |
| 284 const base::android::JavaParamRef<jobject>& obj); | 291 const base::android::JavaParamRef<jobject>& obj); |
| 285 | 292 |
| 286 void ScrollTo(JNIEnv* env, | 293 void ScrollTo(JNIEnv* env, |
| 287 const base::android::JavaParamRef<jobject>& obj, | 294 const base::android::JavaParamRef<jobject>& obj, |
| 288 jint x, | 295 jint x, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 private: | 339 private: |
| 333 void InitAutofillIfNecessary(bool enabled); | 340 void InitAutofillIfNecessary(bool enabled); |
| 334 | 341 |
| 335 // Geolocation API support | 342 // Geolocation API support |
| 336 void ShowGeolocationPrompt(const GURL& origin, base::Callback<void(bool)>); | 343 void ShowGeolocationPrompt(const GURL& origin, base::Callback<void(bool)>); |
| 337 void HideGeolocationPrompt(const GURL& origin); | 344 void HideGeolocationPrompt(const GURL& origin); |
| 338 | 345 |
| 339 void SetDipScaleInternal(float dip_scale); | 346 void SetDipScaleInternal(float dip_scale); |
| 340 | 347 |
| 341 JavaObjectWeakGlobalRef java_ref_; | 348 JavaObjectWeakGlobalRef java_ref_; |
| 349 SharedRendererState shared_renderer_state_; | |
| 342 BrowserViewRenderer browser_view_renderer_; // Must outlive |web_contents_|. | 350 BrowserViewRenderer browser_view_renderer_; // Must outlive |web_contents_|. |
| 343 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; | 351 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; |
| 344 scoped_ptr<AwContentsClientBridge> contents_client_bridge_; | 352 scoped_ptr<AwContentsClientBridge> contents_client_bridge_; |
| 345 scoped_ptr<content::WebContents> web_contents_; | 353 scoped_ptr<content::WebContents> web_contents_; |
| 346 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_; | 354 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_; |
| 347 scoped_ptr<FindHelper> find_helper_; | 355 scoped_ptr<FindHelper> find_helper_; |
| 348 scoped_ptr<IconHelper> icon_helper_; | 356 scoped_ptr<IconHelper> icon_helper_; |
| 349 scoped_ptr<AwContents> pending_contents_; | 357 scoped_ptr<AwContents> pending_contents_; |
| 350 scoped_ptr<AwPdfExporter> pdf_exporter_; | 358 scoped_ptr<AwPdfExporter> pdf_exporter_; |
| 351 scoped_ptr<PermissionRequestHandler> permission_request_handler_; | 359 scoped_ptr<PermissionRequestHandler> permission_request_handler_; |
| 352 scoped_refptr<AwMessagePortMessageFilter> message_port_message_filter_; | 360 scoped_refptr<AwMessagePortMessageFilter> message_port_message_filter_; |
| 353 | 361 |
| 354 // GURL is supplied by the content layer as requesting frame. | 362 // GURL is supplied by the content layer as requesting frame. |
| 355 // Callback is supplied by the content layer, and is invoked with the result | 363 // Callback is supplied by the content layer, and is invoked with the result |
| 356 // from the permission prompt. | 364 // from the permission prompt. |
| 357 typedef std::pair<const GURL, base::Callback<void(bool)> > OriginCallback; | 365 typedef std::pair<const GURL, base::Callback<void(bool)> > OriginCallback; |
| 358 // The first element in the list is always the currently pending request. | 366 // The first element in the list is always the currently pending request. |
| 359 std::list<OriginCallback> pending_geolocation_prompts_; | 367 std::list<OriginCallback> pending_geolocation_prompts_; |
| 360 | 368 |
| 361 GLViewRendererManager::Key renderer_manager_key_; | 369 GLViewRendererManager::Key renderer_manager_key_; |
| 362 | 370 |
| 363 DISALLOW_COPY_AND_ASSIGN(AwContents); | 371 DISALLOW_COPY_AND_ASSIGN(AwContents); |
| 364 }; | 372 }; |
| 365 | 373 |
| 366 bool RegisterAwContents(JNIEnv* env); | 374 bool RegisterAwContents(JNIEnv* env); |
| 367 | 375 |
| 368 } // namespace android_webview | 376 } // namespace android_webview |
| 369 | 377 |
| 370 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ | 378 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ |
| OLD | NEW |