Chromium Code Reviews| 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" |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 results->device_scale_factor = display.device_scale_factor(); | 39 results->device_scale_factor = display.device_scale_factor(); |
| 40 results->orientation_angle = display.RotationAsDegree(); | 40 results->orientation_angle = display.RotationAsDegree(); |
| 41 results->orientation_type = | 41 results->orientation_type = |
| 42 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); | 42 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); |
| 43 gfx::DeviceDisplayInfo info; | 43 gfx::DeviceDisplayInfo info; |
| 44 results->depth = display.color_depth(); | 44 results->depth = display.color_depth(); |
| 45 results->depth_per_component = display.depth_per_component(); | 45 results->depth_per_component = display.depth_per_component(); |
| 46 results->is_monochrome = display.is_monochrome(); | 46 results->is_monochrome = display.is_monochrome(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 // static | |
| 50 void SynchronousCompositor::SetClientForWebContents( | |
| 51 WebContents* contents, | |
| 52 SynchronousCompositorClient* client) { | |
| 53 DCHECK(contents); | |
| 54 DCHECK(client); | |
| 55 WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>( | |
| 56 static_cast<WebContentsImpl*>(contents)->GetView()); | |
| 57 DCHECK(!wcva->synchronous_compositor_client()); | |
| 58 wcva->set_synchronous_compositor_client(client); | |
| 59 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( | |
|
boliu
2016/11/08 17:41:05
probably needs null check
Jinsuk Kim
2016/11/08 18:05:54
Done.
| |
| 60 contents->GetRenderWidgetHostView()); | |
| 61 rwhv->set_synchronous_compositor_client(client); | |
| 62 } | |
| 63 | |
| 49 WebContentsView* CreateWebContentsView( | 64 WebContentsView* CreateWebContentsView( |
| 50 WebContentsImpl* web_contents, | 65 WebContentsImpl* web_contents, |
| 51 WebContentsViewDelegate* delegate, | 66 WebContentsViewDelegate* delegate, |
| 52 RenderViewHostDelegateView** render_view_host_delegate_view) { | 67 RenderViewHostDelegateView** render_view_host_delegate_view) { |
| 53 WebContentsViewAndroid* rv = new WebContentsViewAndroid( | 68 WebContentsViewAndroid* rv = new WebContentsViewAndroid( |
| 54 web_contents, delegate); | 69 web_contents, delegate); |
| 55 *render_view_host_delegate_view = rv; | 70 *render_view_host_delegate_view = rv; |
| 56 return rv; | 71 return rv; |
| 57 } | 72 } |
| 58 | 73 |
| 59 WebContentsViewAndroid::WebContentsViewAndroid( | 74 WebContentsViewAndroid::WebContentsViewAndroid( |
| 60 WebContentsImpl* web_contents, | 75 WebContentsImpl* web_contents, |
| 61 WebContentsViewDelegate* delegate) | 76 WebContentsViewDelegate* delegate) |
| 62 : web_contents_(web_contents), | 77 : web_contents_(web_contents), |
| 63 content_view_core_(NULL), | 78 content_view_core_(NULL), |
| 64 delegate_(delegate) { | 79 delegate_(delegate), |
| 80 synchronous_compositor_client_(nullptr) { | |
| 65 } | 81 } |
| 66 | 82 |
| 67 WebContentsViewAndroid::~WebContentsViewAndroid() { | 83 WebContentsViewAndroid::~WebContentsViewAndroid() { |
| 68 if (view_.GetLayer()) | 84 if (view_.GetLayer()) |
| 69 view_.GetLayer()->RemoveFromParent(); | 85 view_.GetLayer()->RemoveFromParent(); |
| 70 } | 86 } |
| 71 | 87 |
| 72 void WebContentsViewAndroid::SetContentViewCore( | 88 void WebContentsViewAndroid::SetContentViewCore( |
| 73 ContentViewCoreImpl* content_view_core) { | 89 ContentViewCoreImpl* content_view_core) { |
| 74 content_view_core_ = content_view_core; | 90 content_view_core_ = content_view_core; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 DCHECK(RenderViewHostFactory::has_factory()); | 193 DCHECK(RenderViewHostFactory::has_factory()); |
| 178 return static_cast<RenderWidgetHostViewBase*>( | 194 return static_cast<RenderWidgetHostViewBase*>( |
| 179 render_widget_host->GetView()); | 195 render_widget_host->GetView()); |
| 180 } | 196 } |
| 181 // Note that while this instructs the render widget host to reference | 197 // Note that while this instructs the render widget host to reference |
| 182 // |native_view_|, this has no effect without also instructing the | 198 // |native_view_|, this has no effect without also instructing the |
| 183 // native view (i.e. ContentView) how to obtain a reference to this widget in | 199 // native view (i.e. ContentView) how to obtain a reference to this widget in |
| 184 // order to paint it. See ContentView::GetRenderWidgetHostViewAndroid for an | 200 // order to paint it. See ContentView::GetRenderWidgetHostViewAndroid for an |
| 185 // example of how this is achieved for InterstitialPages. | 201 // example of how this is achieved for InterstitialPages. |
| 186 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(render_widget_host); | 202 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(render_widget_host); |
| 187 return new RenderWidgetHostViewAndroid(rwhi, content_view_core_); | 203 RenderWidgetHostViewAndroid* rwhv = |
| 204 new RenderWidgetHostViewAndroid(rwhi, content_view_core_); | |
| 205 rwhv->set_synchronous_compositor_client(synchronous_compositor_client_); | |
| 206 return rwhv; | |
| 188 } | 207 } |
| 189 | 208 |
| 190 RenderWidgetHostViewBase* WebContentsViewAndroid::CreateViewForPopupWidget( | 209 RenderWidgetHostViewBase* WebContentsViewAndroid::CreateViewForPopupWidget( |
| 191 RenderWidgetHost* render_widget_host) { | 210 RenderWidgetHost* render_widget_host) { |
| 192 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(render_widget_host); | 211 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(render_widget_host); |
| 193 return new RenderWidgetHostViewAndroid(rwhi, NULL); | 212 return new RenderWidgetHostViewAndroid(rwhi, NULL); |
| 194 } | 213 } |
| 195 | 214 |
| 196 void WebContentsViewAndroid::RenderViewCreated(RenderViewHost* host) { | 215 void WebContentsViewAndroid::RenderViewCreated(RenderViewHost* host) { |
| 197 } | 216 } |
| (...skipping 125 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 |