 Chromium Code Reviews
 Chromium Code Reviews Issue 2484793002:
  Remove access to WebContents in RWHVA::SynchronousFrameMetadata()  (Closed)
    
  
    Issue 2484793002:
  Remove access to WebContents in RWHVA::SynchronousFrameMetadata()  (Closed) 
  | Index: content/browser/web_contents/web_contents_view_android.cc | 
| diff --git a/content/browser/web_contents/web_contents_view_android.cc b/content/browser/web_contents/web_contents_view_android.cc | 
| index e3b9d4ad53631b2a91caa1b4e1aa2bd54264310e..22b85cab7c3fec248b529a0f5298aef4914f72ba 100644 | 
| --- a/content/browser/web_contents/web_contents_view_android.cc | 
| +++ b/content/browser/web_contents/web_contents_view_android.cc | 
| @@ -13,6 +13,7 @@ | 
| #include "content/browser/renderer_host/render_widget_host_view_android.h" | 
| #include "content/browser/renderer_host/render_view_host_factory.h" | 
| #include "content/browser/renderer_host/render_view_host_impl.h" | 
| +#include "content/browser/web_contents/web_contents_android.h" | 
| #include "content/browser/web_contents/web_contents_impl.h" | 
| #include "content/public/browser/render_widget_host.h" | 
| #include "content/public/browser/web_contents_delegate.h" | 
| @@ -74,9 +75,10 @@ void WebContentsViewAndroid::SetContentViewCore( | 
| content_view_core_ = content_view_core; | 
| RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( | 
| web_contents_->GetRenderWidgetHostView()); | 
| - if (rwhv) | 
| - rwhv->SetContentViewCore(content_view_core_); | 
| - | 
| + if (rwhv) { | 
| + rwhv->SetContentViewCore(content_view_core); | 
| + SetSynchronousCompositorClientFor(rwhv); | 
| + } | 
| if (web_contents_->ShowingInterstitialPage()) { | 
| rwhv = static_cast<RenderWidgetHostViewAndroid*>( | 
| web_contents_->GetInterstitialPage() | 
| @@ -84,11 +86,23 @@ void WebContentsViewAndroid::SetContentViewCore( | 
| ->GetRenderViewHost() | 
| ->GetWidget() | 
| ->GetView()); | 
| - if (rwhv) | 
| - rwhv->SetContentViewCore(content_view_core_); | 
| + if (rwhv) { | 
| + rwhv->SetContentViewCore(content_view_core); | 
| + SetSynchronousCompositorClientFor(rwhv); | 
| + } | 
| } | 
| } | 
| +void WebContentsViewAndroid::SetSynchronousCompositorClientFor( | 
| + RenderWidgetHostViewAndroid* rwhv) { | 
| + WebContentsAndroid* web_contents_android = | 
| + static_cast<WebContentsImpl*>(web_contents_)->GetWebContentsAndroid(); | 
| 
boliu
2016/11/08 00:13:55
I think WCVA could just hold SCClient directly, an
 
Jinsuk Kim
2016/11/08 17:58:19
Good idea. Addressed in the new patch.
 | 
| + SynchronousCompositorClient* client = | 
| + web_contents_android->synchronous_compositor_client(); | 
| + if (client) | 
| + rwhv->set_synchronous_compositor_client(client); | 
| +} | 
| + | 
| gfx::NativeView WebContentsViewAndroid::GetNativeView() const { | 
| return const_cast<gfx::NativeView>(&view_); | 
| } | 
| @@ -129,10 +143,15 @@ void WebContentsViewAndroid::SizeContents(const gfx::Size& size) { | 
| } | 
| void WebContentsViewAndroid::Focus() { | 
| - if (web_contents_->ShowingInterstitialPage()) | 
| + RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( | 
| + web_contents_->GetRenderWidgetHostView()); | 
| + if (web_contents_->ShowingInterstitialPage()) { | 
| web_contents_->GetInterstitialPage()->Focus(); | 
| - else | 
| - web_contents_->GetRenderWidgetHostView()->Focus(); | 
| + if (content_view_core_) | 
| + content_view_core_->ForceUpdateImeAdapter(rwhv->GetNativeImeAdapter()); | 
| + } else { | 
| + rwhv->Focus(); | 
| + } | 
| } | 
| void WebContentsViewAndroid::SetInitialFocus() { |