feat: add 'disableHtmlFullscreenWindowResize' option to webPreferences (#17203)

This option allows users to prevent the window from resizing when the HTML5 FullScreen API is used.
This commit is contained in:
Samuel Maddock 2019-03-07 18:29:37 -05:00 committed by Samuel Attard
parent f3fc4023cf
commit ac88b3ead5
7 changed files with 58 additions and 1 deletions

View file

@ -619,7 +619,17 @@ void CommonWebContentsDelegate::SetHtmlApiFullscreen(bool enter_fullscreen) {
return;
}
owner_window_->SetFullScreen(enter_fullscreen);
// Set fullscreen on window if allowed.
auto* web_preferences = WebContentsPreferences::From(GetWebContents());
bool html_fullscreenable =
web_preferences ? !web_preferences->IsEnabled(
options::kDisableHtmlFullscreenWindowResize)
: true;
if (html_fullscreenable) {
owner_window_->SetFullScreen(enter_fullscreen);
}
html_fullscreen_ = enter_fullscreen;
native_fullscreen_ = false;
}

View file

@ -122,6 +122,7 @@ WebContentsPreferences::WebContentsPreferences(
SetDefaultBoolIfUndefined(options::kNodeIntegration, false);
SetDefaultBoolIfUndefined(options::kNodeIntegrationInSubFrames, false);
SetDefaultBoolIfUndefined(options::kNodeIntegrationInWorker, false);
SetDefaultBoolIfUndefined(options::kDisableHtmlFullscreenWindowResize, false);
SetDefaultBoolIfUndefined(options::kWebviewTag, false);
SetDefaultBoolIfUndefined(options::kSandbox, false);
SetDefaultBoolIfUndefined(options::kNativeWindowOpen, false);
@ -371,6 +372,9 @@ void WebContentsPreferences::AppendCommandLineSwitches(
if (IsEnabled(options::kNodeIntegrationInSubFrames))
command_line->AppendSwitch(switches::kNodeIntegrationInSubFrames);
if (IsEnabled(options::kDisableHtmlFullscreenWindowResize))
command_line->AppendSwitch(switches::kDisableHtmlFullscreenWindowResize);
// We are appending args to a webContents so let's save the current state
// of our preferences object so that during the lifetime of the WebContents
// we can fetch the options used to initally configure the WebContents