| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/android/render_widget_host_connector.h" |
| 6 |
| 7 #include "content/browser/frame_host/interstitial_page_impl.h" |
| 8 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 9 #include "content/browser/web_contents/web_contents_impl.h" |
| 10 |
| 11 namespace content { |
| 12 |
| 13 RenderWidgetHostConnector::RenderWidgetHostConnector(WebContents* web_contents) |
| 14 : WebContentsObserver(web_contents) {} |
| 15 |
| 16 RenderWidgetHostConnector::~RenderWidgetHostConnector() {} |
| 17 |
| 18 void RenderWidgetHostConnector::RenderViewHostChanged( |
| 19 RenderViewHost* old_host, |
| 20 RenderViewHost* new_host) { |
| 21 auto* old_view = old_host ? static_cast<RenderWidgetHostViewAndroid*>( |
| 22 old_host->GetWidget()->GetView()) |
| 23 : nullptr; |
| 24 auto* new_view = new_host ? static_cast<RenderWidgetHostViewAndroid*>( |
| 25 new_host->GetWidget()->GetView()) |
| 26 : nullptr; |
| 27 if (old_view != new_view) |
| 28 UpdateRenderWidgetHostView(old_view, new_view); |
| 29 } |
| 30 |
| 31 void RenderWidgetHostConnector::WebContentsDestroyed() { |
| 32 auto* rwhva = GetRenderWidgetHostView(); |
| 33 if (rwhva != nullptr) |
| 34 UpdateRenderWidgetHostView(rwhva, nullptr); |
| 35 } |
| 36 |
| 37 RenderWidgetHostViewAndroid* |
| 38 RenderWidgetHostConnector::GetRenderWidgetHostView() const { |
| 39 RenderWidgetHostView* rwhv = web_contents()->GetRenderWidgetHostView(); |
| 40 WebContentsImpl* web_contents_impl = |
| 41 static_cast<WebContentsImpl*>(web_contents()); |
| 42 if (web_contents_impl->ShowingInterstitialPage()) { |
| 43 rwhv = web_contents_impl->GetInterstitialPage() |
| 44 ->GetMainFrame() |
| 45 ->GetRenderViewHost() |
| 46 ->GetWidget() |
| 47 ->GetView(); |
| 48 } |
| 49 return static_cast<RenderWidgetHostViewAndroid*>(rwhv); |
| 50 } |
| 51 |
| 52 } // namespace content |
| OLD | NEW |