 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) 
  | 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 #include "content/browser/web_contents/web_contents_view_android.h" | 5 #include "content/browser/web_contents/web_contents_view_android.h" | 
| 6 | 6 | 
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" | 
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" | 
| 9 #include "base/logging.h" | 9 #include "base/logging.h" | 
| 10 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" | 
| 11 #include "content/browser/android/content_view_core_impl.h" | 11 #include "content/browser/android/content_view_core_impl.h" | 
| 12 #include "content/browser/frame_host/interstitial_page_impl.h" | 12 #include "content/browser/frame_host/interstitial_page_impl.h" | 
| 13 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 13 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 
| 14 #include "content/browser/renderer_host/render_view_host_factory.h" | 14 #include "content/browser/renderer_host/render_view_host_factory.h" | 
| 15 #include "content/browser/renderer_host/render_view_host_impl.h" | 15 #include "content/browser/renderer_host/render_view_host_impl.h" | 
| 16 #include "content/browser/web_contents/web_contents_android.h" | |
| 16 #include "content/browser/web_contents/web_contents_impl.h" | 17 #include "content/browser/web_contents/web_contents_impl.h" | 
| 17 #include "content/public/browser/render_widget_host.h" | 18 #include "content/public/browser/render_widget_host.h" | 
| 18 #include "content/public/browser/web_contents_delegate.h" | 19 #include "content/public/browser/web_contents_delegate.h" | 
| 19 #include "content/public/common/drop_data.h" | 20 #include "content/public/common/drop_data.h" | 
| 20 #include "ui/display/screen.h" | 21 #include "ui/display/screen.h" | 
| 21 #include "ui/gfx/android/device_display_info.h" | 22 #include "ui/gfx/android/device_display_info.h" | 
| 22 #include "ui/gfx/android/java_bitmap.h" | 23 #include "ui/gfx/android/java_bitmap.h" | 
| 23 #include "ui/gfx/image/image_skia.h" | 24 #include "ui/gfx/image/image_skia.h" | 
| 24 | 25 | 
| 25 using base::android::AttachCurrentThread; | 26 using base::android::AttachCurrentThread; | 
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 WebContentsViewAndroid::~WebContentsViewAndroid() { | 68 WebContentsViewAndroid::~WebContentsViewAndroid() { | 
| 68 if (view_.GetLayer()) | 69 if (view_.GetLayer()) | 
| 69 view_.GetLayer()->RemoveFromParent(); | 70 view_.GetLayer()->RemoveFromParent(); | 
| 70 } | 71 } | 
| 71 | 72 | 
| 72 void WebContentsViewAndroid::SetContentViewCore( | 73 void WebContentsViewAndroid::SetContentViewCore( | 
| 73 ContentViewCoreImpl* content_view_core) { | 74 ContentViewCoreImpl* content_view_core) { | 
| 74 content_view_core_ = content_view_core; | 75 content_view_core_ = content_view_core; | 
| 75 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( | 76 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( | 
| 76 web_contents_->GetRenderWidgetHostView()); | 77 web_contents_->GetRenderWidgetHostView()); | 
| 77 if (rwhv) | 78 if (rwhv) { | 
| 78 rwhv->SetContentViewCore(content_view_core_); | 79 rwhv->SetContentViewCore(content_view_core); | 
| 79 | 80 SetSynchronousCompositorClientFor(rwhv); | 
| 81 } | |
| 80 if (web_contents_->ShowingInterstitialPage()) { | 82 if (web_contents_->ShowingInterstitialPage()) { | 
| 81 rwhv = static_cast<RenderWidgetHostViewAndroid*>( | 83 rwhv = static_cast<RenderWidgetHostViewAndroid*>( | 
| 82 web_contents_->GetInterstitialPage() | 84 web_contents_->GetInterstitialPage() | 
| 83 ->GetMainFrame() | 85 ->GetMainFrame() | 
| 84 ->GetRenderViewHost() | 86 ->GetRenderViewHost() | 
| 85 ->GetWidget() | 87 ->GetWidget() | 
| 86 ->GetView()); | 88 ->GetView()); | 
| 87 if (rwhv) | 89 if (rwhv) { | 
| 88 rwhv->SetContentViewCore(content_view_core_); | 90 rwhv->SetContentViewCore(content_view_core); | 
| 91 SetSynchronousCompositorClientFor(rwhv); | |
| 92 } | |
| 89 } | 93 } | 
| 90 } | 94 } | 
| 91 | 95 | 
| 96 void WebContentsViewAndroid::SetSynchronousCompositorClientFor( | |
| 97 RenderWidgetHostViewAndroid* rwhv) { | |
| 98 WebContentsAndroid* web_contents_android = | |
| 99 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.
 | |
| 100 SynchronousCompositorClient* client = | |
| 101 web_contents_android->synchronous_compositor_client(); | |
| 102 if (client) | |
| 103 rwhv->set_synchronous_compositor_client(client); | |
| 104 } | |
| 105 | |
| 92 gfx::NativeView WebContentsViewAndroid::GetNativeView() const { | 106 gfx::NativeView WebContentsViewAndroid::GetNativeView() const { | 
| 93 return const_cast<gfx::NativeView>(&view_); | 107 return const_cast<gfx::NativeView>(&view_); | 
| 94 } | 108 } | 
| 95 | 109 | 
| 96 gfx::NativeView WebContentsViewAndroid::GetContentNativeView() const { | 110 gfx::NativeView WebContentsViewAndroid::GetContentNativeView() const { | 
| 97 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); | 111 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); | 
| 98 if (rwhv) | 112 if (rwhv) | 
| 99 return rwhv->GetNativeView(); | 113 return rwhv->GetNativeView(); | 
| 100 | 114 | 
| 101 // TODO(sievers): This should return null. | 115 // TODO(sievers): This should return null. | 
| (...skipping 20 matching lines...) Expand all Loading... | |
| 122 } | 136 } | 
| 123 | 137 | 
| 124 void WebContentsViewAndroid::SizeContents(const gfx::Size& size) { | 138 void WebContentsViewAndroid::SizeContents(const gfx::Size& size) { | 
| 125 // TODO(klobag): Do we need to do anything else? | 139 // TODO(klobag): Do we need to do anything else? | 
| 126 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); | 140 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); | 
| 127 if (rwhv) | 141 if (rwhv) | 
| 128 rwhv->SetSize(size); | 142 rwhv->SetSize(size); | 
| 129 } | 143 } | 
| 130 | 144 | 
| 131 void WebContentsViewAndroid::Focus() { | 145 void WebContentsViewAndroid::Focus() { | 
| 132 if (web_contents_->ShowingInterstitialPage()) | 146 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( | 
| 147 web_contents_->GetRenderWidgetHostView()); | |
| 148 if (web_contents_->ShowingInterstitialPage()) { | |
| 133 web_contents_->GetInterstitialPage()->Focus(); | 149 web_contents_->GetInterstitialPage()->Focus(); | 
| 134 else | 150 if (content_view_core_) | 
| 135 web_contents_->GetRenderWidgetHostView()->Focus(); | 151 content_view_core_->ForceUpdateImeAdapter(rwhv->GetNativeImeAdapter()); | 
| 152 } else { | |
| 153 rwhv->Focus(); | |
| 154 } | |
| 136 } | 155 } | 
| 137 | 156 | 
| 138 void WebContentsViewAndroid::SetInitialFocus() { | 157 void WebContentsViewAndroid::SetInitialFocus() { | 
| 139 if (web_contents_->FocusLocationBarByDefault()) | 158 if (web_contents_->FocusLocationBarByDefault()) | 
| 140 web_contents_->SetFocusToLocationBar(false); | 159 web_contents_->SetFocusToLocationBar(false); | 
| 141 else | 160 else | 
| 142 Focus(); | 161 Focus(); | 
| 143 } | 162 } | 
| 144 | 163 | 
| 145 void WebContentsViewAndroid::StoreFocus() { | 164 void WebContentsViewAndroid::StoreFocus() { | 
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 323 // This is called when we the renderer asks us to take focus back (i.e., it has | 342 // This is called when we the renderer asks us to take focus back (i.e., it has | 
| 324 // iterated past the last focusable element on the page). | 343 // iterated past the last focusable element on the page). | 
| 325 void WebContentsViewAndroid::TakeFocus(bool reverse) { | 344 void WebContentsViewAndroid::TakeFocus(bool reverse) { | 
| 326 if (web_contents_->GetDelegate() && | 345 if (web_contents_->GetDelegate() && | 
| 327 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse)) | 346 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse)) | 
| 328 return; | 347 return; | 
| 329 web_contents_->GetRenderWidgetHostView()->Focus(); | 348 web_contents_->GetRenderWidgetHostView()->Focus(); | 
| 330 } | 349 } | 
| 331 | 350 | 
| 332 } // namespace content | 351 } // namespace content | 
| OLD | NEW |