Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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/android/render_widget_host_connector.h" | 5 #include "content/browser/android/render_widget_host_connector.h" |
| 6 | 6 |
| 7 #include "content/browser/frame_host/interstitial_page_impl.h" | 7 #include "content/browser/frame_host/interstitial_page_impl.h" |
| 8 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 8 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 9 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
| 10 | 10 |
| 11 namespace content { | 11 namespace content { |
| 12 | 12 |
| 13 // Observes RenderWidgetHostViewAndroid to keep the instance up to date. | 13 // Observes RenderWidgetHostViewAndroid to keep the instance up to date. |
| 14 class RenderWidgetHostConnector::Observer | 14 class RenderWidgetHostConnector::Observer |
| 15 : public WebContentsObserver, | 15 : public WebContentsObserver, |
| 16 public RenderWidgetHostViewAndroid::DestructionObserver { | 16 public RenderWidgetHostViewAndroid::DestructionObserver { |
| 17 public: | 17 public: |
| 18 Observer(WebContents* web_contents, RenderWidgetHostConnector* connector); | 18 Observer(WebContents* web_contents, RenderWidgetHostConnector* connector); |
| 19 ~Observer() override; | 19 ~Observer() override; |
| 20 | 20 |
| 21 // WebContentsObserver implementation. | 21 // WebContentsObserver implementation. |
| 22 void RenderViewReady() override; | |
| 23 void RenderViewHostChanged(RenderViewHost* old_host, | 22 void RenderViewHostChanged(RenderViewHost* old_host, |
| 24 RenderViewHost* new_host) override; | 23 RenderViewHost* new_host) override; |
| 25 void DidAttachInterstitialPage() override; | 24 void DidAttachInterstitialPage() override; |
| 26 void DidDetachInterstitialPage() override; | 25 void DidDetachInterstitialPage() override; |
| 27 void WebContentsDestroyed() override; | 26 void WebContentsDestroyed() override; |
| 28 | 27 |
| 29 // RenderWidgetHostViewAndroid::DestructionObserver implementation. | 28 // RenderWidgetHostViewAndroid::DestructionObserver implementation. |
| 30 void RenderWidgetHostViewDestroyed( | 29 void RenderWidgetHostViewDestroyed( |
| 31 RenderWidgetHostViewAndroid* rwhva) override; | 30 RenderWidgetHostViewAndroid* rwhva) override; |
| 32 | 31 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 48 WebContents* web_contents, | 47 WebContents* web_contents, |
| 49 RenderWidgetHostConnector* connector) | 48 RenderWidgetHostConnector* connector) |
| 50 : WebContentsObserver(web_contents), | 49 : WebContentsObserver(web_contents), |
| 51 connector_(connector), | 50 connector_(connector), |
| 52 active_rwhva_(nullptr) {} | 51 active_rwhva_(nullptr) {} |
| 53 | 52 |
| 54 RenderWidgetHostConnector::Observer::~Observer() { | 53 RenderWidgetHostConnector::Observer::~Observer() { |
| 55 DCHECK(!active_rwhva_); | 54 DCHECK(!active_rwhva_); |
| 56 } | 55 } |
| 57 | 56 |
| 58 void RenderWidgetHostConnector::Observer::RenderViewReady() { | |
|
boliu
2017/04/24 16:35:41
why is this not needed anymore?
| |
| 59 UpdateRenderWidgetHostView(GetRenderWidgetHostViewAndroid()); | |
| 60 } | |
| 61 | |
| 62 void RenderWidgetHostConnector::Observer::RenderViewHostChanged( | 57 void RenderWidgetHostConnector::Observer::RenderViewHostChanged( |
| 63 RenderViewHost* old_host, | 58 RenderViewHost* old_host, |
| 64 RenderViewHost* new_host) { | 59 RenderViewHost* new_host) { |
| 65 // |RenderViewHostChanged| is called only for main rwhva change. | 60 // |RenderViewHostChanged| is called only for main rwhva change. |
| 66 // No need to update connection if an interstitial page is active. | 61 // No need to update connection if an interstitial page is active. |
| 67 if (web_contents()->ShowingInterstitialPage()) | 62 if (web_contents()->ShowingInterstitialPage()) |
| 68 return; | 63 return; |
| 69 | 64 |
| 70 auto* new_view = new_host ? static_cast<RenderWidgetHostViewAndroid*>( | 65 auto* new_view = new_host ? static_cast<RenderWidgetHostViewAndroid*>( |
| 71 new_host->GetWidget()->GetView()) | 66 new_host->GetWidget()->GetView()) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 } | 127 } |
| 133 | 128 |
| 134 RenderWidgetHostConnector::~RenderWidgetHostConnector() {} | 129 RenderWidgetHostConnector::~RenderWidgetHostConnector() {} |
| 135 | 130 |
| 136 RenderWidgetHostViewAndroid* RenderWidgetHostConnector::GetRWHVAForTesting() | 131 RenderWidgetHostViewAndroid* RenderWidgetHostConnector::GetRWHVAForTesting() |
| 137 const { | 132 const { |
| 138 return render_widget_observer_->active_rwhva(); | 133 return render_widget_observer_->active_rwhva(); |
| 139 } | 134 } |
| 140 | 135 |
| 141 } // namespace content | 136 } // namespace content |
| OLD | NEW |