Chromium Code Reviews| 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::Observer::Observer( | |
| 14 WebContents* web_contents, | |
| 15 RenderWidgetHostConnector* connector) | |
| 16 : WebContentsObserver(web_contents), | |
| 17 connector_(connector), | |
| 18 rwhva_(nullptr) {} | |
| 19 | |
| 20 RenderWidgetHostConnector::Observer::~Observer() {} | |
| 21 | |
| 22 void RenderWidgetHostConnector::Observer::RenderViewHostChanged( | |
| 23 RenderViewHost* old_host, | |
| 24 RenderViewHost* new_host) { | |
| 25 auto* old_view = old_host ? static_cast<RenderWidgetHostViewAndroid*>( | |
| 26 old_host->GetWidget()->GetView()) | |
| 27 : nullptr; | |
| 28 auto* new_view = new_host ? static_cast<RenderWidgetHostViewAndroid*>( | |
| 29 new_host->GetWidget()->GetView()) | |
| 30 : nullptr; | |
| 31 UpdateRenderWidgetHostView(old_view, new_view); | |
|
boliu
2017/04/13 03:44:13
hmm, I'm not sure how interstitials are implemente
Jinsuk Kim
2017/04/13 04:20:20
I don't know right now, but that doesn't sound rig
| |
| 32 } | |
| 33 | |
| 34 void RenderWidgetHostConnector::Observer::DidAttachInterstitialPage() { | |
| 35 UpdateRenderWidgetHostView(rwhva_, GetRenderWidgetHostViewAndroid()); | |
| 36 } | |
| 37 | |
| 38 void RenderWidgetHostConnector::Observer::DidDetachInterstitialPage() { | |
| 39 UpdateRenderWidgetHostView(rwhva_, GetRenderWidgetHostViewAndroid()); | |
| 40 } | |
| 41 | |
| 42 void RenderWidgetHostConnector::Observer::WebContentsDestroyed() { | |
| 43 UpdateRenderWidgetHostView(GetRenderWidgetHostViewAndroid(), nullptr); | |
| 44 delete connector_; | |
| 45 } | |
| 46 | |
| 47 void RenderWidgetHostConnector::Observer::RenderWidgetHostViewDestroyed( | |
| 48 RenderWidgetHostViewAndroid* destroyed_rwhva) { | |
| 49 if (GetRenderWidgetHostViewAndroid() == destroyed_rwhva) { | |
| 50 // Null out the raw pointers here and in the connector impl to keep | |
| 51 // them from referencing the rwvha about to be destroyed. | |
| 52 connector_->UpdateRenderProcessConnection(nullptr, nullptr); | |
|
boliu
2017/04/13 03:44:13
why is old null?
Jinsuk Kim
2017/04/13 04:20:20
This is to set the current rwhva cached in the con
boliu
2017/04/13 04:29:41
That's not part of the interface. The interface is
Jinsuk Kim
2017/04/13 04:44:05
Done. This will help ensure ime_adapter_ in rwhva
| |
| 53 rwhva_ = nullptr; | |
| 54 } | |
| 55 } | |
| 56 | |
| 57 void RenderWidgetHostConnector::Observer::UpdateRenderWidgetHostView( | |
| 58 RenderWidgetHostViewAndroid* old_rwhva, | |
| 59 RenderWidgetHostViewAndroid* new_rwhva) { | |
| 60 if (old_rwhva == new_rwhva) | |
| 61 return; | |
| 62 if (new_rwhva) | |
| 63 new_rwhva->add_destruction_observer(this); | |
|
boliu
2017/04/13 03:44:13
you need to remove this from the old_rwhva
Jinsuk Kim
2017/04/13 04:20:20
Done.
| |
| 64 | |
| 65 connector_->UpdateRenderProcessConnection(old_rwhva, new_rwhva); | |
| 66 rwhva_ = new_rwhva; | |
| 67 } | |
| 68 | |
| 69 RenderWidgetHostViewAndroid* | |
| 70 RenderWidgetHostConnector::Observer::GetRenderWidgetHostViewAndroid() const { | |
| 71 RenderWidgetHostView* rwhv = web_contents()->GetRenderWidgetHostView(); | |
| 72 WebContentsImpl* web_contents_impl = | |
| 73 static_cast<WebContentsImpl*>(web_contents()); | |
| 74 if (web_contents_impl->ShowingInterstitialPage()) { | |
| 75 rwhv = web_contents_impl->GetInterstitialPage() | |
| 76 ->GetMainFrame() | |
| 77 ->GetRenderViewHost() | |
| 78 ->GetWidget() | |
| 79 ->GetView(); | |
| 80 } | |
| 81 return static_cast<RenderWidgetHostViewAndroid*>(rwhv); | |
| 82 } | |
| 83 | |
| 84 RenderWidgetHostConnector::RenderWidgetHostConnector(WebContents* web_contents) | |
| 85 : render_widget_observer_(new Observer(web_contents, this)) {} | |
| 86 | |
| 87 RenderWidgetHostConnector::~RenderWidgetHostConnector() {} | |
| 88 | |
| 89 } // namespace content | |
| OLD | NEW |