| 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*>( |  | 
| 60       contents->GetRenderWidgetHostView()); |  | 
| 61   if (rwhv) |  | 
| 62     rwhv->SetSynchronousCompositorClient(client); |  | 
| 63 } |  | 
| 64 |  | 
| 65 WebContentsView* CreateWebContentsView( | 49 WebContentsView* CreateWebContentsView( | 
| 66     WebContentsImpl* web_contents, | 50     WebContentsImpl* web_contents, | 
| 67     WebContentsViewDelegate* delegate, | 51     WebContentsViewDelegate* delegate, | 
| 68     RenderViewHostDelegateView** render_view_host_delegate_view) { | 52     RenderViewHostDelegateView** render_view_host_delegate_view) { | 
| 69   WebContentsViewAndroid* rv = new WebContentsViewAndroid( | 53   WebContentsViewAndroid* rv = new WebContentsViewAndroid( | 
| 70       web_contents, delegate); | 54       web_contents, delegate); | 
| 71   *render_view_host_delegate_view = rv; | 55   *render_view_host_delegate_view = rv; | 
| 72   return rv; | 56   return rv; | 
| 73 } | 57 } | 
| 74 | 58 | 
| 75 WebContentsViewAndroid::WebContentsViewAndroid( | 59 WebContentsViewAndroid::WebContentsViewAndroid( | 
| 76     WebContentsImpl* web_contents, | 60     WebContentsImpl* web_contents, | 
| 77     WebContentsViewDelegate* delegate) | 61     WebContentsViewDelegate* delegate) | 
| 78     : web_contents_(web_contents), | 62     : web_contents_(web_contents), | 
| 79       content_view_core_(NULL), | 63       content_view_core_(NULL), | 
| 80       delegate_(delegate), | 64       delegate_(delegate) { | 
| 81       synchronous_compositor_client_(nullptr) { |  | 
| 82 } | 65 } | 
| 83 | 66 | 
| 84 WebContentsViewAndroid::~WebContentsViewAndroid() { | 67 WebContentsViewAndroid::~WebContentsViewAndroid() { | 
| 85   if (view_.GetLayer()) | 68   if (view_.GetLayer()) | 
| 86     view_.GetLayer()->RemoveFromParent(); | 69     view_.GetLayer()->RemoveFromParent(); | 
| 87 } | 70 } | 
| 88 | 71 | 
| 89 void WebContentsViewAndroid::SetContentViewCore( | 72 void WebContentsViewAndroid::SetContentViewCore( | 
| 90     ContentViewCoreImpl* content_view_core) { | 73     ContentViewCoreImpl* content_view_core) { | 
| 91   content_view_core_ = content_view_core; | 74   content_view_core_ = content_view_core; | 
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 194     DCHECK(RenderViewHostFactory::has_factory()); | 177     DCHECK(RenderViewHostFactory::has_factory()); | 
| 195     return static_cast<RenderWidgetHostViewBase*>( | 178     return static_cast<RenderWidgetHostViewBase*>( | 
| 196         render_widget_host->GetView()); | 179         render_widget_host->GetView()); | 
| 197   } | 180   } | 
| 198   // Note that while this instructs the render widget host to reference | 181   // Note that while this instructs the render widget host to reference | 
| 199   // |native_view_|, this has no effect without also instructing the | 182   // |native_view_|, this has no effect without also instructing the | 
| 200   // native view (i.e. ContentView) how to obtain a reference to this widget in | 183   // native view (i.e. ContentView) how to obtain a reference to this widget in | 
| 201   // order to paint it. See ContentView::GetRenderWidgetHostViewAndroid for an | 184   // order to paint it. See ContentView::GetRenderWidgetHostViewAndroid for an | 
| 202   // example of how this is achieved for InterstitialPages. | 185   // example of how this is achieved for InterstitialPages. | 
| 203   RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(render_widget_host); | 186   RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(render_widget_host); | 
| 204   RenderWidgetHostViewAndroid* rwhv = | 187   return new RenderWidgetHostViewAndroid(rwhi, content_view_core_); | 
| 205       new RenderWidgetHostViewAndroid(rwhi, content_view_core_); |  | 
| 206   rwhv->SetSynchronousCompositorClient(synchronous_compositor_client_); |  | 
| 207   return rwhv; |  | 
| 208 } | 188 } | 
| 209 | 189 | 
| 210 RenderWidgetHostViewBase* WebContentsViewAndroid::CreateViewForPopupWidget( | 190 RenderWidgetHostViewBase* WebContentsViewAndroid::CreateViewForPopupWidget( | 
| 211     RenderWidgetHost* render_widget_host) { | 191     RenderWidgetHost* render_widget_host) { | 
| 212   RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(render_widget_host); | 192   RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(render_widget_host); | 
| 213   return new RenderWidgetHostViewAndroid(rwhi, NULL); | 193   return new RenderWidgetHostViewAndroid(rwhi, NULL); | 
| 214 } | 194 } | 
| 215 | 195 | 
| 216 void WebContentsViewAndroid::RenderViewCreated(RenderViewHost* host) { | 196 void WebContentsViewAndroid::RenderViewCreated(RenderViewHost* host) { | 
| 217 } | 197 } | 
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 343 // This is called when we the renderer asks us to take focus back (i.e., it has | 323 // This is called when we the renderer asks us to take focus back (i.e., it has | 
| 344 // iterated past the last focusable element on the page). | 324 // iterated past the last focusable element on the page). | 
| 345 void WebContentsViewAndroid::TakeFocus(bool reverse) { | 325 void WebContentsViewAndroid::TakeFocus(bool reverse) { | 
| 346   if (web_contents_->GetDelegate() && | 326   if (web_contents_->GetDelegate() && | 
| 347       web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse)) | 327       web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse)) | 
| 348     return; | 328     return; | 
| 349   web_contents_->GetRenderWidgetHostView()->Focus(); | 329   web_contents_->GetRenderWidgetHostView()->Focus(); | 
| 350 } | 330 } | 
| 351 | 331 | 
| 352 } // namespace content | 332 } // namespace content | 
| OLD | NEW | 
|---|