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 | 9 |
10 #include <list> | 10 #include <list> |
11 #include <memory> | 11 #include <memory> |
12 #include <string> | 12 #include <string> |
13 #include <utility> | 13 #include <utility> |
14 | 14 |
15 #include "android_webview/browser/aw_browser_permission_request_delegate.h" | 15 #include "android_webview/browser/aw_browser_permission_request_delegate.h" |
16 #include "android_webview/browser/aw_message_port_message_filter.h" | 16 #include "android_webview/browser/aw_message_port_message_filter.h" |
17 #include "android_webview/browser/browser_view_renderer.h" | 17 #include "android_webview/browser/browser_view_renderer.h" |
18 #include "android_webview/browser/browser_view_renderer_client.h" | 18 #include "android_webview/browser/browser_view_renderer_client.h" |
19 #include "android_webview/browser/find_helper.h" | 19 #include "android_webview/browser/find_helper.h" |
20 #include "android_webview/browser/gl_view_renderer_manager.h" | 20 #include "android_webview/browser/gl_view_renderer_manager.h" |
21 #include "android_webview/browser/icon_helper.h" | 21 #include "android_webview/browser/icon_helper.h" |
22 #include "android_webview/browser/render_thread_manager.h" | 22 #include "android_webview/browser/render_thread_manager.h" |
23 #include "android_webview/browser/render_thread_manager_client.h" | 23 #include "android_webview/browser/render_thread_manager_client.h" |
24 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" | 24 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" |
25 #include "android_webview/native/permission/permission_request_handler_client.h" | 25 #include "android_webview/native/permission/permission_request_handler_client.h" |
26 #include "base/android/jni_weak_ref.h" | 26 #include "base/android/jni_weak_ref.h" |
27 #include "base/android/scoped_java_ref.h" | 27 #include "base/android/scoped_java_ref.h" |
28 #include "base/callback_forward.h" | 28 #include "base/callback_forward.h" |
29 #include "base/macros.h" | 29 #include "base/macros.h" |
| 30 #include "content/public/browser/web_contents_observer.h" |
30 | 31 |
31 class SkBitmap; | 32 class SkBitmap; |
32 class TabContents; | 33 class TabContents; |
33 struct AwDrawGLInfo; | 34 struct AwDrawGLInfo; |
34 | 35 |
35 namespace content { | 36 namespace content { |
36 class WebContents; | 37 class WebContents; |
37 } | 38 } |
38 | 39 |
39 namespace android_webview { | 40 namespace android_webview { |
(...skipping 17 matching lines...) Expand all Loading... |
57 // hosts a popup will be rebound to a second native instance (carrying the | 58 // hosts a popup will be rebound to a second native instance (carrying the |
58 // popup content) and discard the 'default' native instance it made on | 59 // popup content) and discard the 'default' native instance it made on |
59 // construction. A native instance is only bound to at most one Java peer over | 60 // construction. A native instance is only bound to at most one Java peer over |
60 // its entire lifetime - see Init() and SetPendingWebContentsForPopup() for the | 61 // its entire lifetime - see Init() and SetPendingWebContentsForPopup() for the |
61 // construction points, and SetJavaPeers() where these paths join. | 62 // construction points, and SetJavaPeers() where these paths join. |
62 class AwContents : public FindHelper::Listener, | 63 class AwContents : public FindHelper::Listener, |
63 public IconHelper::Listener, | 64 public IconHelper::Listener, |
64 public AwRenderViewHostExtClient, | 65 public AwRenderViewHostExtClient, |
65 public BrowserViewRendererClient, | 66 public BrowserViewRendererClient, |
66 public PermissionRequestHandlerClient, | 67 public PermissionRequestHandlerClient, |
67 public AwBrowserPermissionRequestDelegate { | 68 public AwBrowserPermissionRequestDelegate, |
| 69 public content::WebContentsObserver { |
68 public: | 70 public: |
69 // Returns the AwContents instance associated with |web_contents|, or NULL. | 71 // Returns the AwContents instance associated with |web_contents|, or NULL. |
70 static AwContents* FromWebContents(content::WebContents* web_contents); | 72 static AwContents* FromWebContents(content::WebContents* web_contents); |
71 | 73 |
72 // Returns the AwContents instance associated with with the given | 74 // Returns the AwContents instance associated with with the given |
73 // render_process_id and render_view_id, or NULL. | 75 // render_process_id and render_view_id, or NULL. |
74 static AwContents* FromID(int render_process_id, int render_view_id); | 76 static AwContents* FromID(int render_process_id, int render_view_id); |
75 | 77 |
76 static std::string GetLocale(); | 78 static std::string GetLocale(); |
77 | 79 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 const base::android::JavaParamRef<jobjectArray>& ports); | 328 const base::android::JavaParamRef<jobjectArray>& ports); |
327 | 329 |
328 void GrantFileSchemeAccesstoChildProcess( | 330 void GrantFileSchemeAccesstoChildProcess( |
329 JNIEnv* env, | 331 JNIEnv* env, |
330 const base::android::JavaParamRef<jobject>& obj); | 332 const base::android::JavaParamRef<jobject>& obj); |
331 | 333 |
332 void ResumeLoadingCreatedPopupWebContents( | 334 void ResumeLoadingCreatedPopupWebContents( |
333 JNIEnv* env, | 335 JNIEnv* env, |
334 const base::android::JavaParamRef<jobject>& obj); | 336 const base::android::JavaParamRef<jobject>& obj); |
335 | 337 |
| 338 // content::WebContentsObserver overrides |
| 339 void RenderViewHostChanged(content::RenderViewHost* old_host, |
| 340 content::RenderViewHost* new_host) override; |
| 341 |
336 private: | 342 private: |
337 void InitAutofillIfNecessary(bool enabled); | 343 void InitAutofillIfNecessary(bool enabled); |
338 | 344 |
339 // Geolocation API support | 345 // Geolocation API support |
340 void ShowGeolocationPrompt(const GURL& origin, base::Callback<void(bool)>); | 346 void ShowGeolocationPrompt(const GURL& origin, base::Callback<void(bool)>); |
341 void HideGeolocationPrompt(const GURL& origin); | 347 void HideGeolocationPrompt(const GURL& origin); |
342 | 348 |
343 void SetDipScaleInternal(float dip_scale); | 349 void SetDipScaleInternal(float dip_scale); |
344 | 350 |
345 void SetAwGLFunctor(AwGLFunctor* functor); | 351 void SetAwGLFunctor(AwGLFunctor* functor); |
346 | 352 |
347 JavaObjectWeakGlobalRef java_ref_; | 353 JavaObjectWeakGlobalRef java_ref_; |
348 AwGLFunctor* functor_; | 354 AwGLFunctor* functor_; |
349 BrowserViewRenderer browser_view_renderer_; // Must outlive |web_contents_|. | 355 BrowserViewRenderer browser_view_renderer_; // Must outlive |web_contents_|. |
| 356 std::unique_ptr<content::WebContents> web_contents_; |
350 std::unique_ptr<AwWebContentsDelegate> web_contents_delegate_; | 357 std::unique_ptr<AwWebContentsDelegate> web_contents_delegate_; |
351 std::unique_ptr<AwContentsClientBridge> contents_client_bridge_; | 358 std::unique_ptr<AwContentsClientBridge> contents_client_bridge_; |
352 std::unique_ptr<content::WebContents> web_contents_; | |
353 std::unique_ptr<AwRenderViewHostExt> render_view_host_ext_; | 359 std::unique_ptr<AwRenderViewHostExt> render_view_host_ext_; |
354 std::unique_ptr<FindHelper> find_helper_; | 360 std::unique_ptr<FindHelper> find_helper_; |
355 std::unique_ptr<IconHelper> icon_helper_; | 361 std::unique_ptr<IconHelper> icon_helper_; |
356 std::unique_ptr<AwContents> pending_contents_; | 362 std::unique_ptr<AwContents> pending_contents_; |
357 std::unique_ptr<AwPdfExporter> pdf_exporter_; | 363 std::unique_ptr<AwPdfExporter> pdf_exporter_; |
358 std::unique_ptr<PermissionRequestHandler> permission_request_handler_; | 364 std::unique_ptr<PermissionRequestHandler> permission_request_handler_; |
359 scoped_refptr<AwMessagePortMessageFilter> message_port_message_filter_; | 365 scoped_refptr<AwMessagePortMessageFilter> message_port_message_filter_; |
360 | 366 |
361 // GURL is supplied by the content layer as requesting frame. | 367 // GURL is supplied by the content layer as requesting frame. |
362 // 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 |
363 // from the permission prompt. | 369 // from the permission prompt. |
364 typedef std::pair<const GURL, base::Callback<void(bool)> > OriginCallback; | 370 typedef std::pair<const GURL, base::Callback<void(bool)> > OriginCallback; |
365 // 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. |
366 std::list<OriginCallback> pending_geolocation_prompts_; | 372 std::list<OriginCallback> pending_geolocation_prompts_; |
367 | 373 |
368 GLViewRendererManager::Key renderer_manager_key_; | 374 GLViewRendererManager::Key renderer_manager_key_; |
369 | 375 |
370 DISALLOW_COPY_AND_ASSIGN(AwContents); | 376 DISALLOW_COPY_AND_ASSIGN(AwContents); |
371 }; | 377 }; |
372 | 378 |
373 bool RegisterAwContents(JNIEnv* env); | 379 bool RegisterAwContents(JNIEnv* env); |
374 | 380 |
375 } // namespace android_webview | 381 } // namespace android_webview |
376 | 382 |
377 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ | 383 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ |
OLD | NEW |