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/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/media/android/browser_media_player_manager.h" | 9 #include "content/browser/media/android/browser_media_player_manager.h" |
| 10 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 10 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 11 #include "content/browser/renderer_host/render_view_host_factory.h" | 11 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 12 #include "content/browser/renderer_host/render_view_host_impl.h" | 12 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 13 #include "content/browser/web_contents/interstitial_page_impl.h" | 13 #include "content/browser/web_contents/interstitial_page_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), |
| 35 compositor_(NULL) { | |
| 34 } | 36 } |
| 35 | 37 |
| 36 WebContentsViewAndroid::~WebContentsViewAndroid() { | 38 WebContentsViewAndroid::~WebContentsViewAndroid() { |
| 37 } | 39 } |
| 38 | 40 |
| 39 void WebContentsViewAndroid::SetContentViewCore( | 41 void WebContentsViewAndroid::SetContentViewCore( |
| 40 ContentViewCoreImpl* content_view_core) { | 42 ContentViewCoreImpl* content_view_core) { |
| 41 content_view_core_ = content_view_core; | 43 content_view_core_ = content_view_core; |
| 42 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( | 44 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( |
| 43 web_contents_->GetRenderWidgetHostView()); | 45 web_contents_->GetRenderWidgetHostView()); |
| 44 if (rwhv) | 46 if (rwhv) |
| 45 rwhv->SetContentViewCore(content_view_core_); | 47 rwhv->SetContentViewCore(content_view_core_); |
| 46 | 48 |
| 47 if (web_contents_->ShowingInterstitialPage()) { | 49 if (web_contents_->ShowingInterstitialPage()) { |
| 48 rwhv = static_cast<RenderWidgetHostViewAndroid*>( | 50 rwhv = static_cast<RenderWidgetHostViewAndroid*>( |
| 49 static_cast<InterstitialPageImpl*>( | 51 static_cast<InterstitialPageImpl*>( |
| 50 web_contents_->GetInterstitialPage())-> | 52 web_contents_->GetInterstitialPage())-> |
| 51 GetRenderViewHost()->GetView()); | 53 GetRenderViewHost()->GetView()); |
| 52 if (rwhv) | 54 if (rwhv) |
| 53 rwhv->SetContentViewCore(content_view_core_); | 55 rwhv->SetContentViewCore(content_view_core_); |
| 54 } | 56 } |
| 55 } | 57 } |
| 56 | 58 |
| 59 void WebContentsViewAndroid::SetCompositor(Compositor* compositor) { | |
| 60 compositor_ = compositor; | |
| 61 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( | |
| 62 web_contents_->GetRenderWidgetHostView()); | |
| 63 | |
| 64 if (rwhv) | |
| 65 rwhv->SetCompositor(compositor_); | |
| 66 } | |
| 67 | |
| 57 #if defined(GOOGLE_TV) | 68 #if defined(GOOGLE_TV) |
| 58 void WebContentsViewAndroid::NotifyExternalSurface( | 69 void WebContentsViewAndroid::NotifyExternalSurface( |
| 59 int player_id, bool is_request, const gfx::RectF& rect) { | 70 int player_id, bool is_request, const gfx::RectF& rect) { |
| 60 if (content_view_core_) | 71 if (content_view_core_) |
| 61 content_view_core_->NotifyExternalSurface(player_id, is_request, rect); | 72 content_view_core_->NotifyExternalSurface(player_id, is_request, rect); |
| 62 } | 73 } |
| 63 #endif | 74 #endif |
| 64 | 75 |
| 65 gfx::NativeView WebContentsViewAndroid::GetNativeView() const { | 76 gfx::NativeView WebContentsViewAndroid::GetNativeView() const { |
| 66 return content_view_core_ ? content_view_core_->GetViewAndroid() : NULL; | 77 return content_view_core_ ? content_view_core_->GetViewAndroid() : NULL; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 // making special ones (which go along with the special views). | 162 // making special ones (which go along with the special views). |
| 152 DCHECK(RenderViewHostFactory::has_factory()); | 163 DCHECK(RenderViewHostFactory::has_factory()); |
| 153 return render_widget_host->GetView(); | 164 return render_widget_host->GetView(); |
| 154 } | 165 } |
| 155 // Note that while this instructs the render widget host to reference | 166 // Note that while this instructs the render widget host to reference |
| 156 // |native_view_|, this has no effect without also instructing the | 167 // |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 | 168 // native view (i.e. ContentView) how to obtain a reference to this widget in |
| 158 // order to paint it. See ContentView::GetRenderWidgetHostViewAndroid for an | 169 // order to paint it. See ContentView::GetRenderWidgetHostViewAndroid for an |
| 159 // example of how this is achieved for InterstitialPages. | 170 // example of how this is achieved for InterstitialPages. |
| 160 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(render_widget_host); | 171 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(render_widget_host); |
| 161 RenderWidgetHostView* view = new RenderWidgetHostViewAndroid( | 172 RenderWidgetHostViewAndroid* view = new RenderWidgetHostViewAndroid( |
| 162 rwhi, content_view_core_); | 173 rwhi, content_view_core_); |
| 174 view->SetCompositor(compositor_); | |
|
David Trainor- moved to gerrit
2013/10/21 15:26:08
Was there one other code path to build a RWHVA?
powei
2013/11/08 21:34:47
No, but there is a path where RWHVA is created bef
| |
| 163 return view; | 175 return view; |
| 164 } | 176 } |
| 165 | 177 |
| 166 RenderWidgetHostView* WebContentsViewAndroid::CreateViewForPopupWidget( | 178 RenderWidgetHostView* WebContentsViewAndroid::CreateViewForPopupWidget( |
| 167 RenderWidgetHost* render_widget_host) { | 179 RenderWidgetHost* render_widget_host) { |
| 168 return RenderWidgetHostViewPort::CreateViewForWidget(render_widget_host); | 180 return RenderWidgetHostViewPort::CreateViewForWidget(render_widget_host); |
| 169 } | 181 } |
| 170 | 182 |
| 171 void WebContentsViewAndroid::RenderViewCreated(RenderViewHost* host) { | 183 void WebContentsViewAndroid::RenderViewCreated(RenderViewHost* host) { |
| 172 } | 184 } |
| (...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 | 230 // 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). | 231 // iterated past the last focusable element on the page). |
| 220 void WebContentsViewAndroid::TakeFocus(bool reverse) { | 232 void WebContentsViewAndroid::TakeFocus(bool reverse) { |
| 221 if (web_contents_->GetDelegate() && | 233 if (web_contents_->GetDelegate() && |
| 222 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse)) | 234 web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse)) |
| 223 return; | 235 return; |
| 224 web_contents_->GetRenderWidgetHostView()->Focus(); | 236 web_contents_->GetRenderWidgetHostView()->Focus(); |
| 225 } | 237 } |
| 226 | 238 |
| 227 } // namespace content | 239 } // namespace content |
| OLD | NEW |