Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: android_webview/native/aw_contents.h

Issue 2650753002: Implement renderer importance API for WebView (Closed)
Patch Set: clean up unused local Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « android_webview/native/BUILD.gn ('k') | android_webview/native/aw_contents.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_render_process_gone_delegate.h" 16 #include "android_webview/browser/aw_render_process_gone_delegate.h"
17 #include "android_webview/browser/aw_safe_browsing_ui_manager.h" 17 #include "android_webview/browser/aw_safe_browsing_ui_manager.h"
18 #include "android_webview/browser/browser_view_renderer.h" 18 #include "android_webview/browser/browser_view_renderer.h"
19 #include "android_webview/browser/browser_view_renderer_client.h" 19 #include "android_webview/browser/browser_view_renderer_client.h"
20 #include "android_webview/browser/find_helper.h" 20 #include "android_webview/browser/find_helper.h"
21 #include "android_webview/browser/gl_view_renderer_manager.h" 21 #include "android_webview/browser/gl_view_renderer_manager.h"
22 #include "android_webview/browser/icon_helper.h" 22 #include "android_webview/browser/icon_helper.h"
23 #include "android_webview/browser/render_thread_manager.h" 23 #include "android_webview/browser/render_thread_manager.h"
24 #include "android_webview/browser/render_thread_manager_client.h" 24 #include "android_webview/browser/render_thread_manager_client.h"
25 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" 25 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h"
26 #include "android_webview/native/aw_renderer_priority_manager.h"
26 #include "android_webview/native/permission/permission_request_handler_client.h" 27 #include "android_webview/native/permission/permission_request_handler_client.h"
27 #include "base/android/jni_weak_ref.h" 28 #include "base/android/jni_weak_ref.h"
28 #include "base/android/scoped_java_ref.h" 29 #include "base/android/scoped_java_ref.h"
29 #include "base/callback_forward.h" 30 #include "base/callback_forward.h"
30 #include "base/macros.h" 31 #include "base/macros.h"
32 #include "content/public/browser/render_process_host_observer.h"
31 #include "content/public/browser/web_contents_observer.h" 33 #include "content/public/browser/web_contents_observer.h"
32 34
33 class SkBitmap; 35 class SkBitmap;
34 class TabContents; 36 class TabContents;
35 37
36 namespace content { 38 namespace content {
37 class WebContents; 39 class WebContents;
38 } 40 }
39 41
40 namespace android_webview { 42 namespace android_webview {
(...skipping 19 matching lines...) Expand all
60 // its entire lifetime - see Init() and SetPendingWebContentsForPopup() for the 62 // its entire lifetime - see Init() and SetPendingWebContentsForPopup() for the
61 // construction points, and SetJavaPeers() where these paths join. 63 // construction points, and SetJavaPeers() where these paths join.
62 class AwContents : public FindHelper::Listener, 64 class AwContents : public FindHelper::Listener,
63 public IconHelper::Listener, 65 public IconHelper::Listener,
64 public AwRenderViewHostExtClient, 66 public AwRenderViewHostExtClient,
65 public BrowserViewRendererClient, 67 public BrowserViewRendererClient,
66 public PermissionRequestHandlerClient, 68 public PermissionRequestHandlerClient,
67 public AwBrowserPermissionRequestDelegate, 69 public AwBrowserPermissionRequestDelegate,
68 public AwRenderProcessGoneDelegate, 70 public AwRenderProcessGoneDelegate,
69 public content::WebContentsObserver, 71 public content::WebContentsObserver,
72 public content::RenderProcessHostObserver,
70 public AwSafeBrowsingUIManager::UIManagerClient { 73 public AwSafeBrowsingUIManager::UIManagerClient {
71 public: 74 public:
72 // Returns the AwContents instance associated with |web_contents|, or NULL. 75 // Returns the AwContents instance associated with |web_contents|, or NULL.
73 static AwContents* FromWebContents(content::WebContents* web_contents); 76 static AwContents* FromWebContents(content::WebContents* web_contents);
74 77
75 // Returns the AwContents instance associated with with the given 78 // Returns the AwContents instance associated with with the given
76 // render_process_id and render_view_id, or NULL. 79 // render_process_id and render_view_id, or NULL.
77 static AwContents* FromID(int render_process_id, int render_view_id); 80 static AwContents* FromID(int render_process_id, int render_view_id);
78 81
79 static std::string GetLocale(); 82 static std::string GetLocale();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 const base::android::JavaParamRef<jobject>& obj, 209 const base::android::JavaParamRef<jobject>& obj,
207 const base::android::JavaParamRef<jstring>& url, 210 const base::android::JavaParamRef<jstring>& url,
208 const base::android::JavaParamRef<jstring>& extra_headers); 211 const base::android::JavaParamRef<jstring>& extra_headers);
209 212
210 void InvokeGeolocationCallback( 213 void InvokeGeolocationCallback(
211 JNIEnv* env, 214 JNIEnv* env,
212 const base::android::JavaParamRef<jobject>& obj, 215 const base::android::JavaParamRef<jobject>& obj,
213 jboolean value, 216 jboolean value,
214 const base::android::JavaParamRef<jstring>& origin); 217 const base::android::JavaParamRef<jstring>& origin);
215 218
219 AwRendererPriorityManager::RendererPriority GetCurrentRendererPriority();
220 jint GetRendererCurrentPriority(
221 JNIEnv* env,
222 const base::android::JavaParamRef<jobject>& obj);
223 jint GetRendererRequestedPriority(
224 JNIEnv* env,
225 const base::android::JavaParamRef<jobject>& obj);
226 jboolean GetRendererPriorityWaivedWhenNotVisible(
227 JNIEnv* env,
228 const base::android::JavaParamRef<jobject>& obj);
229 void SetRendererPriorityPolicy(
230 JNIEnv* env,
231 const base::android::JavaParamRef<jobject>& obj,
232 jint rendererRequestedPriority,
233 jboolean waivedhenNotVisible);
234
216 // PermissionRequestHandlerClient implementation. 235 // PermissionRequestHandlerClient implementation.
217 void OnPermissionRequest(base::android::ScopedJavaLocalRef<jobject> j_request, 236 void OnPermissionRequest(base::android::ScopedJavaLocalRef<jobject> j_request,
218 AwPermissionRequest* request) override; 237 AwPermissionRequest* request) override;
219 void OnPermissionRequestCanceled(AwPermissionRequest* request) override; 238 void OnPermissionRequestCanceled(AwPermissionRequest* request) override;
220 239
221 PermissionRequestHandler* GetPermissionRequestHandler() { 240 PermissionRequestHandler* GetPermissionRequestHandler() {
222 return permission_request_handler_.get(); 241 return permission_request_handler_.get();
223 } 242 }
224 243
225 void PreauthorizePermission( 244 void PreauthorizePermission(
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 void ResumeLoadingCreatedPopupWebContents( 355 void ResumeLoadingCreatedPopupWebContents(
337 JNIEnv* env, 356 JNIEnv* env,
338 const base::android::JavaParamRef<jobject>& obj); 357 const base::android::JavaParamRef<jobject>& obj);
339 358
340 // content::WebContentsObserver overrides 359 // content::WebContentsObserver overrides
341 void RenderViewHostChanged(content::RenderViewHost* old_host, 360 void RenderViewHostChanged(content::RenderViewHost* old_host,
342 content::RenderViewHost* new_host) override; 361 content::RenderViewHost* new_host) override;
343 void DidAttachInterstitialPage() override; 362 void DidAttachInterstitialPage() override;
344 void DidDetachInterstitialPage() override; 363 void DidDetachInterstitialPage() override;
345 364
365 // content::RenderProcessHostObserver overrides
366 void RenderProcessReady(content::RenderProcessHost* host) override;
367
346 // AwSafeBrowsingUIManager::UIManagerClient implementation 368 // AwSafeBrowsingUIManager::UIManagerClient implementation
347 bool CanShowInterstitial() override; 369 bool CanShowInterstitial() override;
348 370
349 // AwRenderProcessGoneDelegate overrides 371 // AwRenderProcessGoneDelegate overrides
350 void OnRenderProcessGone(int child_process_id) override; 372 void OnRenderProcessGone(int child_process_id) override;
351 bool OnRenderProcessGoneDetail(int child_process_id, bool crashed) override; 373 bool OnRenderProcessGoneDetail(int child_process_id, bool crashed) override;
352 374
353 private: 375 private:
354 void InitAutofillIfNecessary(bool enabled); 376 void InitAutofillIfNecessary(bool enabled);
355 377
356 // Geolocation API support 378 // Geolocation API support
357 void ShowGeolocationPrompt(const GURL& origin, base::Callback<void(bool)>); 379 void ShowGeolocationPrompt(const GURL& origin, base::Callback<void(bool)>);
358 void HideGeolocationPrompt(const GURL& origin); 380 void HideGeolocationPrompt(const GURL& origin);
359 381
360 void SetDipScaleInternal(float dip_scale); 382 void SetDipScaleInternal(float dip_scale);
361 383
362 void SetAwGLFunctor(AwGLFunctor* functor); 384 void SetAwGLFunctor(AwGLFunctor* functor);
363 385
386 AwRendererPriorityManager* GetAwRendererPriorityManager();
387 AwRendererPriorityManager::RendererPriority GetComputedRendererPriority();
388 void UpdateRendererPriority(
389 AwRendererPriorityManager::RendererPriority base_priority);
390 void UpdateRendererPriority();
391
364 JavaObjectWeakGlobalRef java_ref_; 392 JavaObjectWeakGlobalRef java_ref_;
365 AwGLFunctor* functor_; 393 AwGLFunctor* functor_;
366 BrowserViewRenderer browser_view_renderer_; // Must outlive |web_contents_|. 394 BrowserViewRenderer browser_view_renderer_; // Must outlive |web_contents_|.
367 std::unique_ptr<content::WebContents> web_contents_; 395 std::unique_ptr<content::WebContents> web_contents_;
368 std::unique_ptr<AwWebContentsDelegate> web_contents_delegate_; 396 std::unique_ptr<AwWebContentsDelegate> web_contents_delegate_;
369 std::unique_ptr<AwContentsClientBridge> contents_client_bridge_; 397 std::unique_ptr<AwContentsClientBridge> contents_client_bridge_;
370 std::unique_ptr<AwRenderViewHostExt> render_view_host_ext_; 398 std::unique_ptr<AwRenderViewHostExt> render_view_host_ext_;
371 std::unique_ptr<FindHelper> find_helper_; 399 std::unique_ptr<FindHelper> find_helper_;
372 std::unique_ptr<IconHelper> icon_helper_; 400 std::unique_ptr<IconHelper> icon_helper_;
373 std::unique_ptr<AwContents> pending_contents_; 401 std::unique_ptr<AwContents> pending_contents_;
374 std::unique_ptr<AwPdfExporter> pdf_exporter_; 402 std::unique_ptr<AwPdfExporter> pdf_exporter_;
375 std::unique_ptr<PermissionRequestHandler> permission_request_handler_; 403 std::unique_ptr<PermissionRequestHandler> permission_request_handler_;
376 404
377 // GURL is supplied by the content layer as requesting frame. 405 // GURL is supplied by the content layer as requesting frame.
378 // Callback is supplied by the content layer, and is invoked with the result 406 // Callback is supplied by the content layer, and is invoked with the result
379 // from the permission prompt. 407 // from the permission prompt.
380 typedef std::pair<const GURL, base::Callback<void(bool)> > OriginCallback; 408 typedef std::pair<const GURL, base::Callback<void(bool)>> OriginCallback;
381 // The first element in the list is always the currently pending request. 409 // The first element in the list is always the currently pending request.
382 std::list<OriginCallback> pending_geolocation_prompts_; 410 std::list<OriginCallback> pending_geolocation_prompts_;
383 411
384 GLViewRendererManager::Key renderer_manager_key_; 412 GLViewRendererManager::Key renderer_manager_key_;
385 413
414 AwRendererPriorityManager::RendererPriority renderer_requested_priority_;
415 bool renderer_priority_waived_when_not_visible_;
416
386 DISALLOW_COPY_AND_ASSIGN(AwContents); 417 DISALLOW_COPY_AND_ASSIGN(AwContents);
387 }; 418 };
388 419
389 bool RegisterAwContents(JNIEnv* env); 420 bool RegisterAwContents(JNIEnv* env);
390 421
391 } // namespace android_webview 422 } // namespace android_webview
392 423
393 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ 424 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_
OLDNEW
« no previous file with comments | « android_webview/native/BUILD.gn ('k') | android_webview/native/aw_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698