| 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 "content/browser/android/content_view_core_impl.h" | 11 #include "content/browser/android/content_view_core_impl.h" |
| 11 #include "content/browser/frame_host/interstitial_page_impl.h" | 12 #include "content/browser/frame_host/interstitial_page_impl.h" |
| 12 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 13 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 13 #include "content/browser/renderer_host/render_view_host_factory.h" | 14 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 14 #include "content/browser/renderer_host/render_view_host_impl.h" | 15 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 15 #include "content/browser/web_contents/web_contents_impl.h" | 16 #include "content/browser/web_contents/web_contents_impl.h" |
| 16 #include "content/public/browser/render_widget_host.h" | 17 #include "content/public/browser/render_widget_host.h" |
| 17 #include "content/public/browser/web_contents_delegate.h" | 18 #include "content/public/browser/web_contents_delegate.h" |
| 18 #include "content/public/common/drop_data.h" | 19 #include "content/public/common/drop_data.h" |
| 19 #include "ui/display/screen.h" | 20 #include "ui/display/screen.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 58 |
| 58 WebContentsViewAndroid::WebContentsViewAndroid( | 59 WebContentsViewAndroid::WebContentsViewAndroid( |
| 59 WebContentsImpl* web_contents, | 60 WebContentsImpl* web_contents, |
| 60 WebContentsViewDelegate* delegate) | 61 WebContentsViewDelegate* delegate) |
| 61 : web_contents_(web_contents), | 62 : web_contents_(web_contents), |
| 62 content_view_core_(NULL), | 63 content_view_core_(NULL), |
| 63 delegate_(delegate) { | 64 delegate_(delegate) { |
| 64 } | 65 } |
| 65 | 66 |
| 66 WebContentsViewAndroid::~WebContentsViewAndroid() { | 67 WebContentsViewAndroid::~WebContentsViewAndroid() { |
| 68 if (view_.GetLayer()) |
| 69 view_.GetLayer()->RemoveFromParent(); |
| 67 } | 70 } |
| 68 | 71 |
| 69 void WebContentsViewAndroid::SetContentViewCore( | 72 void WebContentsViewAndroid::SetContentViewCore( |
| 70 ContentViewCoreImpl* content_view_core) { | 73 ContentViewCoreImpl* content_view_core) { |
| 71 content_view_core_ = content_view_core; | 74 content_view_core_ = content_view_core; |
| 72 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( | 75 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( |
| 73 web_contents_->GetRenderWidgetHostView()); | 76 web_contents_->GetRenderWidgetHostView()); |
| 74 if (rwhv) | 77 if (rwhv) |
| 75 rwhv->SetContentViewCore(content_view_core_); | 78 rwhv->SetContentViewCore(content_view_core_); |
| 76 | 79 |
| 77 if (web_contents_->ShowingInterstitialPage()) { | 80 if (web_contents_->ShowingInterstitialPage()) { |
| 78 rwhv = static_cast<RenderWidgetHostViewAndroid*>( | 81 rwhv = static_cast<RenderWidgetHostViewAndroid*>( |
| 79 web_contents_->GetInterstitialPage() | 82 web_contents_->GetInterstitialPage() |
| 80 ->GetMainFrame() | 83 ->GetMainFrame() |
| 81 ->GetRenderViewHost() | 84 ->GetRenderViewHost() |
| 82 ->GetWidget() | 85 ->GetWidget() |
| 83 ->GetView()); | 86 ->GetView()); |
| 84 if (rwhv) | 87 if (rwhv) |
| 85 rwhv->SetContentViewCore(content_view_core_); | 88 rwhv->SetContentViewCore(content_view_core_); |
| 86 } | 89 } |
| 87 } | 90 } |
| 88 | 91 |
| 89 gfx::NativeView WebContentsViewAndroid::GetNativeView() const { | 92 gfx::NativeView WebContentsViewAndroid::GetNativeView() const { |
| 90 return content_view_core_ ? content_view_core_->GetViewAndroid() : nullptr; | 93 return const_cast<gfx::NativeView>(&view_); |
| 91 } | 94 } |
| 92 | 95 |
| 93 gfx::NativeView WebContentsViewAndroid::GetContentNativeView() const { | 96 gfx::NativeView WebContentsViewAndroid::GetContentNativeView() const { |
| 94 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); | 97 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); |
| 95 if (rwhv) | 98 if (rwhv) |
| 96 return rwhv->GetNativeView(); | 99 return rwhv->GetNativeView(); |
| 97 | 100 |
| 98 // TODO(sievers): This should return null. | 101 // TODO(sievers): This should return null. |
| 99 return GetNativeView(); | 102 return GetNativeView(); |
| 100 } | 103 } |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 // 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 |
| 321 // iterated past the last focusable element on the page). | 324 // iterated past the last focusable element on the page). |
| 322 void WebContentsViewAndroid::TakeFocus(bool reverse) { | 325 void WebContentsViewAndroid::TakeFocus(bool reverse) { |
| 323 if (web_contents_->GetDelegate() && | 326 if (web_contents_->GetDelegate() && |
| 324 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse)) | 327 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse)) |
| 325 return; | 328 return; |
| 326 web_contents_->GetRenderWidgetHostView()->Focus(); | 329 web_contents_->GetRenderWidgetHostView()->Focus(); |
| 327 } | 330 } |
| 328 | 331 |
| 329 } // namespace content | 332 } // namespace content |
| OLD | NEW |