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 void UpdateParentDrawConstraints() override; | |
238 bool RequestDrawGL(bool wait_for_completion) override; | |
239 void DetachFunctorFromView() override; | |
240 | |
233 // Find-in-page API and related methods. | 241 // Find-in-page API and related methods. |
234 void FindAllAsync(JNIEnv* env, | 242 void FindAllAsync(JNIEnv* env, |
235 const base::android::JavaParamRef<jobject>& obj, | 243 const base::android::JavaParamRef<jobject>& obj, |
236 const base::android::JavaParamRef<jstring>& search_string); | 244 const base::android::JavaParamRef<jstring>& search_string); |
237 void FindNext(JNIEnv* env, | 245 void FindNext(JNIEnv* env, |
238 const base::android::JavaParamRef<jobject>& obj, | 246 const base::android::JavaParamRef<jobject>& obj, |
239 jboolean forward); | 247 jboolean forward); |
240 void ClearMatches(JNIEnv* env, | 248 void ClearMatches(JNIEnv* env, |
241 const base::android::JavaParamRef<jobject>& obj); | 249 const base::android::JavaParamRef<jobject>& obj); |
242 FindHelper* GetFindHelper(); | 250 FindHelper* GetFindHelper(); |
243 | 251 |
244 // Per WebView Cookie Policy | 252 // Per WebView Cookie Policy |
245 bool AllowThirdPartyCookies(); | 253 bool AllowThirdPartyCookies(); |
246 | 254 |
247 // FindHelper::Listener implementation. | 255 // FindHelper::Listener implementation. |
248 void OnFindResultReceived(int active_ordinal, | 256 void OnFindResultReceived(int active_ordinal, |
249 int match_count, | 257 int match_count, |
250 bool finished) override; | 258 bool finished) override; |
251 // IconHelper::Listener implementation. | 259 // IconHelper::Listener implementation. |
252 bool ShouldDownloadFavicon(const GURL& icon_url) override; | 260 bool ShouldDownloadFavicon(const GURL& icon_url) override; |
253 void OnReceivedIcon(const GURL& icon_url, const SkBitmap& bitmap) override; | 261 void OnReceivedIcon(const GURL& icon_url, const SkBitmap& bitmap) override; |
254 void OnReceivedTouchIconUrl(const std::string& url, | 262 void OnReceivedTouchIconUrl(const std::string& url, |
255 const bool precomposed) override; | 263 const bool precomposed) override; |
256 | 264 |
257 // AwRenderViewHostExtClient implementation. | 265 // AwRenderViewHostExtClient implementation. |
258 void OnWebLayoutPageScaleFactorChanged(float page_scale_factor) override; | 266 void OnWebLayoutPageScaleFactorChanged(float page_scale_factor) override; |
259 void OnWebLayoutContentsSizeChanged(const gfx::Size& contents_size) override; | 267 void OnWebLayoutContentsSizeChanged(const gfx::Size& contents_size) override; |
260 | 268 |
261 // BrowserViewRendererClient implementation. | 269 // BrowserViewRendererClient implementation. |
262 bool RequestDrawGL(bool wait_for_completion) override; | |
263 void PostInvalidate() override; | 270 void PostInvalidate() override; |
264 void DetachFunctorFromView() override; | |
265 void OnNewPicture() override; | 271 void OnNewPicture() override; |
266 gfx::Point GetLocationOnScreen() override; | 272 gfx::Point GetLocationOnScreen() override; |
267 void ScrollContainerViewTo(const gfx::Vector2d& new_value) override; | 273 void ScrollContainerViewTo(const gfx::Vector2d& new_value) override; |
268 void UpdateScrollState(const gfx::Vector2d& max_scroll_offset, | 274 void UpdateScrollState(const gfx::Vector2d& max_scroll_offset, |
269 const gfx::SizeF& contents_size_dip, | 275 const gfx::SizeF& contents_size_dip, |
270 float page_scale_factor, | 276 float page_scale_factor, |
271 float min_page_scale_factor, | 277 float min_page_scale_factor, |
272 float max_page_scale_factor) override; | 278 float max_page_scale_factor) override; |
273 void DidOverscroll(const gfx::Vector2d& overscroll_delta, | 279 void DidOverscroll(const gfx::Vector2d& overscroll_delta, |
274 const gfx::Vector2dF& overscroll_velocity) override; | 280 const gfx::Vector2dF& overscroll_velocity) override; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 | 329 |
324 void GrantFileSchemeAccesstoChildProcess( | 330 void GrantFileSchemeAccesstoChildProcess( |
325 JNIEnv* env, | 331 JNIEnv* env, |
326 const base::android::JavaParamRef<jobject>& obj); | 332 const base::android::JavaParamRef<jobject>& obj); |
327 | 333 |
328 void ResumeLoadingCreatedPopupWebContents( | 334 void ResumeLoadingCreatedPopupWebContents( |
329 JNIEnv* env, | 335 JNIEnv* env, |
330 const base::android::JavaParamRef<jobject>& obj); | 336 const base::android::JavaParamRef<jobject>& obj); |
331 | 337 |
332 private: | 338 private: |
339 void CleanUpUncommittedFrame(); | |
340 void CleanUpReturnedResources(); | |
341 | |
342 bool OnDrawHardware(const gfx::Vector2d& scroll); | |
343 bool OnDrawSoftware(const base::android::JavaRef<jobject>& canvas, | |
344 const gfx::Vector2d& scroll); | |
boliu
2016/03/30 16:12:13
these new methods don't exist anymore
Tobias Sargeant
2016/03/30 17:17:17
Done.
| |
345 | |
333 void InitAutofillIfNecessary(bool enabled); | 346 void InitAutofillIfNecessary(bool enabled); |
334 | 347 |
335 // Geolocation API support | 348 // Geolocation API support |
336 void ShowGeolocationPrompt(const GURL& origin, base::Callback<void(bool)>); | 349 void ShowGeolocationPrompt(const GURL& origin, base::Callback<void(bool)>); |
337 void HideGeolocationPrompt(const GURL& origin); | 350 void HideGeolocationPrompt(const GURL& origin); |
338 | 351 |
339 void SetDipScaleInternal(float dip_scale); | 352 void SetDipScaleInternal(float dip_scale); |
340 | 353 |
341 JavaObjectWeakGlobalRef java_ref_; | 354 JavaObjectWeakGlobalRef java_ref_; |
355 SharedRendererState shared_renderer_state_; | |
342 BrowserViewRenderer browser_view_renderer_; // Must outlive |web_contents_|. | 356 BrowserViewRenderer browser_view_renderer_; // Must outlive |web_contents_|. |
343 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; | 357 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; |
344 scoped_ptr<AwContentsClientBridge> contents_client_bridge_; | 358 scoped_ptr<AwContentsClientBridge> contents_client_bridge_; |
345 scoped_ptr<content::WebContents> web_contents_; | 359 scoped_ptr<content::WebContents> web_contents_; |
346 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_; | 360 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_; |
347 scoped_ptr<FindHelper> find_helper_; | 361 scoped_ptr<FindHelper> find_helper_; |
348 scoped_ptr<IconHelper> icon_helper_; | 362 scoped_ptr<IconHelper> icon_helper_; |
349 scoped_ptr<AwContents> pending_contents_; | 363 scoped_ptr<AwContents> pending_contents_; |
350 scoped_ptr<AwPdfExporter> pdf_exporter_; | 364 scoped_ptr<AwPdfExporter> pdf_exporter_; |
351 scoped_ptr<PermissionRequestHandler> permission_request_handler_; | 365 scoped_ptr<PermissionRequestHandler> permission_request_handler_; |
352 scoped_refptr<AwMessagePortMessageFilter> message_port_message_filter_; | 366 scoped_refptr<AwMessagePortMessageFilter> message_port_message_filter_; |
353 | 367 |
354 // GURL is supplied by the content layer as requesting frame. | 368 // GURL is supplied by the content layer as requesting frame. |
355 // Callback is supplied by the content layer, and is invoked with the result | 369 // Callback is supplied by the content layer, and is invoked with the result |
356 // from the permission prompt. | 370 // from the permission prompt. |
357 typedef std::pair<const GURL, base::Callback<void(bool)> > OriginCallback; | 371 typedef std::pair<const GURL, base::Callback<void(bool)> > OriginCallback; |
358 // The first element in the list is always the currently pending request. | 372 // The first element in the list is always the currently pending request. |
359 std::list<OriginCallback> pending_geolocation_prompts_; | 373 std::list<OriginCallback> pending_geolocation_prompts_; |
360 | 374 |
361 GLViewRendererManager::Key renderer_manager_key_; | 375 GLViewRendererManager::Key renderer_manager_key_; |
362 | 376 |
363 DISALLOW_COPY_AND_ASSIGN(AwContents); | 377 DISALLOW_COPY_AND_ASSIGN(AwContents); |
364 }; | 378 }; |
365 | 379 |
366 bool RegisterAwContents(JNIEnv* env); | 380 bool RegisterAwContents(JNIEnv* env); |
367 | 381 |
368 } // namespace android_webview | 382 } // namespace android_webview |
369 | 383 |
370 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ | 384 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ |
OLD | NEW |