[Display Cutout] Support for fullscreen webapps
When a webapp is has the fullscreen display mode set the
fullscreen API is disabled and the activity is in an
"immersive" mode. We should tell WebContents when this
happens so we can support display cutouts in this mode.
BUG=859241
Change-Id: I4ce0a647180aa72f2eb5361ad8335956ecb383a2
Reviewed-on: https://chromium-review.googlesource.com/1121537
Commit-Queue: Becca Hughes <[email protected]>
Reviewed-by: Bo <[email protected]>
Reviewed-by: Mounir Lamouri <[email protected]>
Cr-Commit-Position: refs/heads/master@{#573568}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index c1a8e3e..f22e8d3 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -438,7 +438,28 @@
SetCurrentRenderFrameHost(nullptr);
}
- // Removes any state built up by a render frame.
+ // WebContentsObserver override.
+ void DidFinishNavigation(NavigationHandle* navigation_handle) override {
+ // If the navigation is not in the main frame or if we are a same document
+ // navigation then we should stop now.
+ if (!navigation_handle->IsInMainFrame() ||
+ navigation_handle->IsSameDocument()) {
+ return;
+ }
+
+ // If we finish a main frame navigation and the |WebDisplayMode| is
+ // fullscreen or standalone then we should make the main frame the
+ // current |RenderFrameHost|.
+ RenderWidgetHostImpl* rwh =
+ web_contents_impl()->GetRenderViewHost()->GetWidget();
+ blink::WebDisplayMode mode = web_contents_impl()->GetDisplayMode(rwh);
+ if (mode == blink::WebDisplayMode::kWebDisplayModeFullscreen ||
+ mode == blink::WebDisplayMode::kWebDisplayModeStandalone) {
+ SetCurrentRenderFrameHost(web_contents_impl()->GetMainFrame());
+ }
+ }
+
+ // WebContentsObserver override. Removes any state built up by a render frame.
void RenderFrameDeleted(RenderFrameHost* rfh) override {
values_.erase(rfh);
@@ -447,6 +468,11 @@
SetCurrentRenderFrameHost(nullptr);
}
+ // WebContentsObserver override.
+ void RenderFrameCreated(RenderFrameHost* rfh) override {
+ ViewportFitChangedForFrame(rfh, blink::mojom::ViewportFit::kAuto);
+ }
+
// Updates the safe area insets on the current frame.
void SetDisplayCutoutSafeArea(gfx::Insets insets) {
insets_ = insets;
@@ -4154,13 +4180,6 @@
net::IsCertStatusError(navigation_handle->GetSSLInfo().cert_status));
SetNotWaitingForResponse();
-
- // Reset the viewport fit
- if (display_cutout_host_impl_) {
- display_cutout_host_impl_->ViewportFitChangedForFrame(
- navigation_handle->GetRenderFrameHost(),
- blink::mojom::ViewportFit::kAuto);
- }
}
void WebContentsImpl::DidFinishNavigation(NavigationHandle* navigation_handle) {