| 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> |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 struct AwDrawGLInfo; | 33 struct AwDrawGLInfo; |
| 34 | 34 |
| 35 namespace content { | 35 namespace content { |
| 36 class WebContents; | 36 class WebContents; |
| 37 } | 37 } |
| 38 | 38 |
| 39 namespace android_webview { | 39 namespace android_webview { |
| 40 | 40 |
| 41 class AwContentsContainer; | 41 class AwContentsContainer; |
| 42 class AwContentsClientBridge; | 42 class AwContentsClientBridge; |
| 43 class AwGLFunctor; |
| 43 class AwPdfExporter; | 44 class AwPdfExporter; |
| 44 class AwWebContentsDelegate; | 45 class AwWebContentsDelegate; |
| 45 class HardwareRenderer; | 46 class HardwareRenderer; |
| 46 class PermissionRequestHandler; | 47 class PermissionRequestHandler; |
| 47 | 48 |
| 48 // Native side of java-class of same name. | 49 // Native side of java-class of same name. |
| 49 // Provides the ownership of and access to browser components required for | 50 // Provides the ownership of and access to browser components required for |
| 50 // WebView functionality; analogous to chrome's TabContents, but with a | 51 // WebView functionality; analogous to chrome's TabContents, but with a |
| 51 // level of indirection provided by the AwContentsContainer abstraction. | 52 // level of indirection provided by the AwContentsContainer abstraction. |
| 52 // | 53 // |
| 53 // Object lifetime: | 54 // Object lifetime: |
| 54 // For most purposes the java and native objects can be considered to have | 55 // For most purposes the java and native objects can be considered to have |
| 55 // 1:1 lifetime and relationship. The exception is the java instance that | 56 // 1:1 lifetime and relationship. The exception is the java instance that |
| 56 // hosts a popup will be rebound to a second native instance (carrying the | 57 // hosts a popup will be rebound to a second native instance (carrying the |
| 57 // popup content) and discard the 'default' native instance it made on | 58 // popup content) and discard the 'default' native instance it made on |
| 58 // construction. A native instance is only bound to at most one Java peer over | 59 // construction. A native instance is only bound to at most one Java peer over |
| 59 // its entire lifetime - see Init() and SetPendingWebContentsForPopup() for the | 60 // its entire lifetime - see Init() and SetPendingWebContentsForPopup() for the |
| 60 // construction points, and SetJavaPeers() where these paths join. | 61 // construction points, and SetJavaPeers() where these paths join. |
| 61 class AwContents : public FindHelper::Listener, | 62 class AwContents : public FindHelper::Listener, |
| 62 public IconHelper::Listener, | 63 public IconHelper::Listener, |
| 63 public AwRenderViewHostExtClient, | 64 public AwRenderViewHostExtClient, |
| 64 public BrowserViewRendererClient, | 65 public BrowserViewRendererClient, |
| 65 public PermissionRequestHandlerClient, | 66 public PermissionRequestHandlerClient, |
| 66 public AwBrowserPermissionRequestDelegate, | 67 public AwBrowserPermissionRequestDelegate { |
| 67 public RenderThreadManagerClient { | |
| 68 public: | 68 public: |
| 69 // Returns the AwContents instance associated with |web_contents|, or NULL. | 69 // Returns the AwContents instance associated with |web_contents|, or NULL. |
| 70 static AwContents* FromWebContents(content::WebContents* web_contents); | 70 static AwContents* FromWebContents(content::WebContents* web_contents); |
| 71 | 71 |
| 72 // Returns the AwContents instance associated with with the given | 72 // Returns the AwContents instance associated with with the given |
| 73 // render_process_id and render_view_id, or NULL. | 73 // render_process_id and render_view_id, or NULL. |
| 74 static AwContents* FromID(int render_process_id, int render_view_id); | 74 static AwContents* FromID(int render_process_id, int render_view_id); |
| 75 | 75 |
| 76 static std::string GetLocale(); | 76 static std::string GetLocale(); |
| 77 | 77 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 96 const base::android::JavaParamRef<jobject>& obj, | 96 const base::android::JavaParamRef<jobject>& obj, |
| 97 const base::android::JavaParamRef<jobject>& aw_contents, | 97 const base::android::JavaParamRef<jobject>& aw_contents, |
| 98 const base::android::JavaParamRef<jobject>& web_contents_delegate, | 98 const base::android::JavaParamRef<jobject>& web_contents_delegate, |
| 99 const base::android::JavaParamRef<jobject>& contents_client_bridge, | 99 const base::android::JavaParamRef<jobject>& contents_client_bridge, |
| 100 const base::android::JavaParamRef<jobject>& io_thread_client, | 100 const base::android::JavaParamRef<jobject>& io_thread_client, |
| 101 const base::android::JavaParamRef<jobject>& | 101 const base::android::JavaParamRef<jobject>& |
| 102 intercept_navigation_delegate); | 102 intercept_navigation_delegate); |
| 103 base::android::ScopedJavaLocalRef<jobject> GetWebContents( | 103 base::android::ScopedJavaLocalRef<jobject> GetWebContents( |
| 104 JNIEnv* env, | 104 JNIEnv* env, |
| 105 const base::android::JavaParamRef<jobject>& obj); | 105 const base::android::JavaParamRef<jobject>& obj); |
| 106 void SetAwGLFunctor(JNIEnv* env, |
| 107 const base::android::JavaParamRef<jobject>& obj, |
| 108 jlong gl_functor); |
| 106 | 109 |
| 107 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | 110 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
| 108 void DocumentHasImages(JNIEnv* env, | 111 void DocumentHasImages(JNIEnv* env, |
| 109 const base::android::JavaParamRef<jobject>& obj, | 112 const base::android::JavaParamRef<jobject>& obj, |
| 110 const base::android::JavaParamRef<jobject>& message); | 113 const base::android::JavaParamRef<jobject>& message); |
| 111 void GenerateMHTML(JNIEnv* env, | 114 void GenerateMHTML(JNIEnv* env, |
| 112 const base::android::JavaParamRef<jobject>& obj, | 115 const base::android::JavaParamRef<jobject>& obj, |
| 113 const base::android::JavaParamRef<jstring>& jpath, | 116 const base::android::JavaParamRef<jstring>& jpath, |
| 114 const base::android::JavaParamRef<jobject>& callback); | 117 const base::android::JavaParamRef<jobject>& callback); |
| 115 void CreatePdfExporter( | 118 void CreatePdfExporter( |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 bool OnDraw(JNIEnv* env, | 176 bool OnDraw(JNIEnv* env, |
| 174 const base::android::JavaParamRef<jobject>& obj, | 177 const base::android::JavaParamRef<jobject>& obj, |
| 175 const base::android::JavaParamRef<jobject>& canvas, | 178 const base::android::JavaParamRef<jobject>& canvas, |
| 176 jboolean is_hardware_accelerated, | 179 jboolean is_hardware_accelerated, |
| 177 jint scroll_x, | 180 jint scroll_x, |
| 178 jint scroll_y, | 181 jint scroll_y, |
| 179 jint visible_left, | 182 jint visible_left, |
| 180 jint visible_top, | 183 jint visible_top, |
| 181 jint visible_right, | 184 jint visible_right, |
| 182 jint visible_bottom); | 185 jint visible_bottom); |
| 183 jlong GetAwDrawGLViewContext(JNIEnv* env, | |
| 184 const base::android::JavaParamRef<jobject>& obj); | |
| 185 jlong CapturePicture(JNIEnv* env, | 186 jlong CapturePicture(JNIEnv* env, |
| 186 const base::android::JavaParamRef<jobject>& obj, | 187 const base::android::JavaParamRef<jobject>& obj, |
| 187 int width, | 188 int width, |
| 188 int height); | 189 int height); |
| 189 void EnableOnNewPicture(JNIEnv* env, | 190 void EnableOnNewPicture(JNIEnv* env, |
| 190 const base::android::JavaParamRef<jobject>& obj, | 191 const base::android::JavaParamRef<jobject>& obj, |
| 191 jboolean enabled); | 192 jboolean enabled); |
| 192 void InsertVisualStateCallback( | 193 void InsertVisualStateCallback( |
| 193 JNIEnv* env, | 194 JNIEnv* env, |
| 194 const base::android::JavaParamRef<jobject>& obj, | 195 const base::android::JavaParamRef<jobject>& obj, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 const GURL& origin) override; | 231 const GURL& origin) override; |
| 231 void RequestGeolocationPermission( | 232 void RequestGeolocationPermission( |
| 232 const GURL& origin, | 233 const GURL& origin, |
| 233 const base::Callback<void(bool)>& callback) override; | 234 const base::Callback<void(bool)>& callback) override; |
| 234 void CancelGeolocationPermissionRequests(const GURL& origin) override; | 235 void CancelGeolocationPermissionRequests(const GURL& origin) override; |
| 235 void RequestMIDISysexPermission( | 236 void RequestMIDISysexPermission( |
| 236 const GURL& origin, | 237 const GURL& origin, |
| 237 const base::Callback<void(bool)>& callback) override; | 238 const base::Callback<void(bool)>& callback) override; |
| 238 void CancelMIDISysexPermissionRequests(const GURL& origin) override; | 239 void CancelMIDISysexPermissionRequests(const GURL& origin) override; |
| 239 | 240 |
| 240 // RenderThreadManagerClient implementation. | 241 // ex-SharedRendererStateClient implementation. |
| 241 void OnParentDrawConstraintsUpdated() override; | 242 void OnParentDrawConstraintsUpdated(); |
| 242 bool RequestDrawGL(bool wait_for_completion) override; | |
| 243 void DetachFunctorFromView() override; | |
| 244 | 243 |
| 245 // Find-in-page API and related methods. | 244 // Find-in-page API and related methods. |
| 246 void FindAllAsync(JNIEnv* env, | 245 void FindAllAsync(JNIEnv* env, |
| 247 const base::android::JavaParamRef<jobject>& obj, | 246 const base::android::JavaParamRef<jobject>& obj, |
| 248 const base::android::JavaParamRef<jstring>& search_string); | 247 const base::android::JavaParamRef<jstring>& search_string); |
| 249 void FindNext(JNIEnv* env, | 248 void FindNext(JNIEnv* env, |
| 250 const base::android::JavaParamRef<jobject>& obj, | 249 const base::android::JavaParamRef<jobject>& obj, |
| 251 jboolean forward); | 250 jboolean forward); |
| 252 void ClearMatches(JNIEnv* env, | 251 void ClearMatches(JNIEnv* env, |
| 253 const base::android::JavaParamRef<jobject>& obj); | 252 const base::android::JavaParamRef<jobject>& obj); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 | 338 |
| 340 private: | 339 private: |
| 341 void InitAutofillIfNecessary(bool enabled); | 340 void InitAutofillIfNecessary(bool enabled); |
| 342 | 341 |
| 343 // Geolocation API support | 342 // Geolocation API support |
| 344 void ShowGeolocationPrompt(const GURL& origin, base::Callback<void(bool)>); | 343 void ShowGeolocationPrompt(const GURL& origin, base::Callback<void(bool)>); |
| 345 void HideGeolocationPrompt(const GURL& origin); | 344 void HideGeolocationPrompt(const GURL& origin); |
| 346 | 345 |
| 347 void SetDipScaleInternal(float dip_scale); | 346 void SetDipScaleInternal(float dip_scale); |
| 348 | 347 |
| 348 void SetAwGLFunctor(AwGLFunctor* functor); |
| 349 |
| 349 JavaObjectWeakGlobalRef java_ref_; | 350 JavaObjectWeakGlobalRef java_ref_; |
| 350 RenderThreadManager render_thread_manager_; | 351 AwGLFunctor* functor_; |
| 351 BrowserViewRenderer browser_view_renderer_; // Must outlive |web_contents_|. | 352 BrowserViewRenderer browser_view_renderer_; // Must outlive |web_contents_|. |
| 352 std::unique_ptr<AwWebContentsDelegate> web_contents_delegate_; | 353 std::unique_ptr<AwWebContentsDelegate> web_contents_delegate_; |
| 353 std::unique_ptr<AwContentsClientBridge> contents_client_bridge_; | 354 std::unique_ptr<AwContentsClientBridge> contents_client_bridge_; |
| 354 std::unique_ptr<content::WebContents> web_contents_; | 355 std::unique_ptr<content::WebContents> web_contents_; |
| 355 std::unique_ptr<AwRenderViewHostExt> render_view_host_ext_; | 356 std::unique_ptr<AwRenderViewHostExt> render_view_host_ext_; |
| 356 std::unique_ptr<FindHelper> find_helper_; | 357 std::unique_ptr<FindHelper> find_helper_; |
| 357 std::unique_ptr<IconHelper> icon_helper_; | 358 std::unique_ptr<IconHelper> icon_helper_; |
| 358 std::unique_ptr<AwContents> pending_contents_; | 359 std::unique_ptr<AwContents> pending_contents_; |
| 359 std::unique_ptr<AwPdfExporter> pdf_exporter_; | 360 std::unique_ptr<AwPdfExporter> pdf_exporter_; |
| 360 std::unique_ptr<PermissionRequestHandler> permission_request_handler_; | 361 std::unique_ptr<PermissionRequestHandler> permission_request_handler_; |
| 361 scoped_refptr<AwMessagePortMessageFilter> message_port_message_filter_; | 362 scoped_refptr<AwMessagePortMessageFilter> message_port_message_filter_; |
| 362 | 363 |
| 363 // GURL is supplied by the content layer as requesting frame. | 364 // GURL is supplied by the content layer as requesting frame. |
| 364 // Callback is supplied by the content layer, and is invoked with the result | 365 // Callback is supplied by the content layer, and is invoked with the result |
| 365 // from the permission prompt. | 366 // from the permission prompt. |
| 366 typedef std::pair<const GURL, base::Callback<void(bool)> > OriginCallback; | 367 typedef std::pair<const GURL, base::Callback<void(bool)> > OriginCallback; |
| 367 // The first element in the list is always the currently pending request. | 368 // The first element in the list is always the currently pending request. |
| 368 std::list<OriginCallback> pending_geolocation_prompts_; | 369 std::list<OriginCallback> pending_geolocation_prompts_; |
| 369 | 370 |
| 370 GLViewRendererManager::Key renderer_manager_key_; | 371 GLViewRendererManager::Key renderer_manager_key_; |
| 371 | 372 |
| 372 DISALLOW_COPY_AND_ASSIGN(AwContents); | 373 DISALLOW_COPY_AND_ASSIGN(AwContents); |
| 373 }; | 374 }; |
| 374 | 375 |
| 375 bool RegisterAwContents(JNIEnv* env); | 376 bool RegisterAwContents(JNIEnv* env); |
| 376 | 377 |
| 377 } // namespace android_webview | 378 } // namespace android_webview |
| 378 | 379 |
| 379 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ | 380 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ |
| OLD | NEW |