| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/browser/android/content_view_core_impl.h" | 8 #include "content/browser/android/content_view_core_impl.h" |
| 9 #include "content/browser/frame_host/interstitial_page_impl.h" | 9 #include "content/browser/frame_host/interstitial_page_impl.h" |
| 10 #include "content/browser/media/android/browser_media_player_manager.h" | 10 #include "content/browser/media/android/browser_media_player_manager.h" |
| 11 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 11 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 12 #include "content/browser/renderer_host/render_view_host_factory.h" | 12 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 13 #include "content/browser/renderer_host/render_view_host_impl.h" | 13 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 14 #include "content/browser/web_contents/web_contents_impl.h" | 14 #include "content/browser/web_contents/web_contents_impl.h" |
| 15 #include "content/public/browser/android/compositor.h" |
| 15 #include "content/public/browser/web_contents_delegate.h" | 16 #include "content/public/browser/web_contents_delegate.h" |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 WebContentsViewPort* CreateWebContentsView( | 19 WebContentsViewPort* CreateWebContentsView( |
| 19 WebContentsImpl* web_contents, | 20 WebContentsImpl* web_contents, |
| 20 WebContentsViewDelegate* delegate, | 21 WebContentsViewDelegate* delegate, |
| 21 RenderViewHostDelegateView** render_view_host_delegate_view) { | 22 RenderViewHostDelegateView** render_view_host_delegate_view) { |
| 22 WebContentsViewAndroid* rv = new WebContentsViewAndroid( | 23 WebContentsViewAndroid* rv = new WebContentsViewAndroid( |
| 23 web_contents, delegate); | 24 web_contents, delegate); |
| 24 *render_view_host_delegate_view = rv; | 25 *render_view_host_delegate_view = rv; |
| 25 return rv; | 26 return rv; |
| 26 } | 27 } |
| 27 | 28 |
| 28 WebContentsViewAndroid::WebContentsViewAndroid( | 29 WebContentsViewAndroid::WebContentsViewAndroid( |
| 29 WebContentsImpl* web_contents, | 30 WebContentsImpl* web_contents, |
| 30 WebContentsViewDelegate* delegate) | 31 WebContentsViewDelegate* delegate) |
| 31 : web_contents_(web_contents), | 32 : web_contents_(web_contents), |
| 32 content_view_core_(NULL), | 33 content_view_core_(NULL), |
| 33 delegate_(delegate) { | 34 delegate_(delegate), |
| 34 } | 35 compositor_provider_(NULL) {} |
| 35 | 36 |
| 36 WebContentsViewAndroid::~WebContentsViewAndroid() { | 37 WebContentsViewAndroid::~WebContentsViewAndroid() { |
| 37 } | 38 } |
| 38 | 39 |
| 39 void WebContentsViewAndroid::SetContentViewCore( | 40 void WebContentsViewAndroid::SetContentViewCore( |
| 40 ContentViewCoreImpl* content_view_core) { | 41 ContentViewCoreImpl* content_view_core) { |
| 41 content_view_core_ = content_view_core; | 42 content_view_core_ = content_view_core; |
| 42 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( | 43 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( |
| 43 web_contents_->GetRenderWidgetHostView()); | 44 web_contents_->GetRenderWidgetHostView()); |
| 44 if (rwhv) | 45 if (rwhv) |
| 45 rwhv->SetContentViewCore(content_view_core_); | 46 rwhv->SetContentViewCore(content_view_core_); |
| 46 | 47 |
| 47 if (web_contents_->ShowingInterstitialPage()) { | 48 if (web_contents_->ShowingInterstitialPage()) { |
| 48 rwhv = static_cast<RenderWidgetHostViewAndroid*>( | 49 rwhv = static_cast<RenderWidgetHostViewAndroid*>( |
| 49 static_cast<InterstitialPageImpl*>( | 50 static_cast<InterstitialPageImpl*>( |
| 50 web_contents_->GetInterstitialPage())-> | 51 web_contents_->GetInterstitialPage())-> |
| 51 GetRenderViewHost()->GetView()); | 52 GetRenderViewHost()->GetView()); |
| 52 if (rwhv) | 53 if (rwhv) |
| 53 rwhv->SetContentViewCore(content_view_core_); | 54 rwhv->SetContentViewCore(content_view_core_); |
| 54 } | 55 } |
| 55 } | 56 } |
| 56 | 57 |
| 58 void WebContentsViewAndroid::SetCompositorProvider( |
| 59 CompositorProvider* compositor_provider) { |
| 60 compositor_provider_ = compositor_provider; |
| 61 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( |
| 62 web_contents_->GetRenderWidgetHostView()); |
| 63 if (rwhv) |
| 64 rwhv->SetCompositorProvider(compositor_provider_); |
| 65 } |
| 66 |
| 57 #if defined(GOOGLE_TV) | 67 #if defined(GOOGLE_TV) |
| 58 void WebContentsViewAndroid::NotifyExternalSurface( | 68 void WebContentsViewAndroid::NotifyExternalSurface( |
| 59 int player_id, bool is_request, const gfx::RectF& rect) { | 69 int player_id, bool is_request, const gfx::RectF& rect) { |
| 60 if (content_view_core_) | 70 if (content_view_core_) |
| 61 content_view_core_->NotifyExternalSurface(player_id, is_request, rect); | 71 content_view_core_->NotifyExternalSurface(player_id, is_request, rect); |
| 62 } | 72 } |
| 63 #endif | 73 #endif |
| 64 | 74 |
| 65 gfx::NativeView WebContentsViewAndroid::GetNativeView() const { | 75 gfx::NativeView WebContentsViewAndroid::GetNativeView() const { |
| 66 return content_view_core_ ? content_view_core_->GetViewAndroid() : NULL; | 76 return content_view_core_ ? content_view_core_->GetViewAndroid() : NULL; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 DCHECK(RenderViewHostFactory::has_factory()); | 162 DCHECK(RenderViewHostFactory::has_factory()); |
| 153 return render_widget_host->GetView(); | 163 return render_widget_host->GetView(); |
| 154 } | 164 } |
| 155 // Note that while this instructs the render widget host to reference | 165 // Note that while this instructs the render widget host to reference |
| 156 // |native_view_|, this has no effect without also instructing the | 166 // |native_view_|, this has no effect without also instructing the |
| 157 // native view (i.e. ContentView) how to obtain a reference to this widget in | 167 // native view (i.e. ContentView) how to obtain a reference to this widget in |
| 158 // order to paint it. See ContentView::GetRenderWidgetHostViewAndroid for an | 168 // order to paint it. See ContentView::GetRenderWidgetHostViewAndroid for an |
| 159 // example of how this is achieved for InterstitialPages. | 169 // example of how this is achieved for InterstitialPages. |
| 160 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(render_widget_host); | 170 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(render_widget_host); |
| 161 RenderWidgetHostView* view = new RenderWidgetHostViewAndroid( | 171 RenderWidgetHostView* view = new RenderWidgetHostViewAndroid( |
| 162 rwhi, content_view_core_); | 172 rwhi, content_view_core_, compositor_provider_); |
| 163 return view; | 173 return view; |
| 164 } | 174 } |
| 165 | 175 |
| 166 RenderWidgetHostView* WebContentsViewAndroid::CreateViewForPopupWidget( | 176 RenderWidgetHostView* WebContentsViewAndroid::CreateViewForPopupWidget( |
| 167 RenderWidgetHost* render_widget_host) { | 177 RenderWidgetHost* render_widget_host) { |
| 168 return RenderWidgetHostViewPort::CreateViewForWidget(render_widget_host); | 178 return RenderWidgetHostViewPort::CreateViewForWidget(render_widget_host); |
| 169 } | 179 } |
| 170 | 180 |
| 171 void WebContentsViewAndroid::RenderViewCreated(RenderViewHost* host) { | 181 void WebContentsViewAndroid::RenderViewCreated(RenderViewHost* host) { |
| 172 } | 182 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 // This is called when we the renderer asks us to take focus back (i.e., it has | 228 // This is called when we the renderer asks us to take focus back (i.e., it has |
| 219 // iterated past the last focusable element on the page). | 229 // iterated past the last focusable element on the page). |
| 220 void WebContentsViewAndroid::TakeFocus(bool reverse) { | 230 void WebContentsViewAndroid::TakeFocus(bool reverse) { |
| 221 if (web_contents_->GetDelegate() && | 231 if (web_contents_->GetDelegate() && |
| 222 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse)) | 232 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse)) |
| 223 return; | 233 return; |
| 224 web_contents_->GetRenderWidgetHostView()->Focus(); | 234 web_contents_->GetRenderWidgetHostView()->Focus(); |
| 225 } | 235 } |
| 226 | 236 |
| 227 } // namespace content | 237 } // namespace content |
| OLD | NEW |