feat: add enableWebSQL webpreference (#23311)
* feat: add enableWebSQL webpreference * chore: update indexedDB test
This commit is contained in:
parent
2a680e107b
commit
a707a3eda3
9 changed files with 187 additions and 3 deletions
|
@ -130,6 +130,7 @@ WebContentsPreferences::WebContentsPreferences(
|
|||
SetDefaultBoolIfUndefined(options::kImages, true);
|
||||
SetDefaultBoolIfUndefined(options::kTextAreasAreResizable, true);
|
||||
SetDefaultBoolIfUndefined(options::kWebGL, true);
|
||||
SetDefaultBoolIfUndefined(options::kEnableWebSQL, true);
|
||||
bool webSecurity = true;
|
||||
SetDefaultBoolIfUndefined(options::kWebSecurity, webSecurity);
|
||||
// If webSecurity was explicity set to false, let's inherit that into
|
||||
|
@ -419,6 +420,10 @@ void WebContentsPreferences::AppendCommandLineSwitches(
|
|||
}
|
||||
#endif
|
||||
|
||||
// Whether to allow the WebSQL api
|
||||
if (IsEnabled(options::kEnableWebSQL))
|
||||
command_line->AppendSwitch(switches::kEnableWebSQL);
|
||||
|
||||
// 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
|
||||
|
|
|
@ -182,6 +182,8 @@ const char kSpellcheck[] = "spellcheck";
|
|||
const char kEnableRemoteModule[] = "enableRemoteModule";
|
||||
#endif
|
||||
|
||||
const char kEnableWebSQL[] = "enableWebSQL";
|
||||
|
||||
} // namespace options
|
||||
|
||||
namespace switches {
|
||||
|
@ -250,6 +252,10 @@ const char kNodeIntegrationInWorker[] = "node-integration-in-worker";
|
|||
// environments will be created in sub-frames.
|
||||
const char kNodeIntegrationInSubFrames[] = "node-integration-in-subframes";
|
||||
|
||||
// Command switch passed to render process to control whether WebSQL api
|
||||
// is allowed.
|
||||
const char kEnableWebSQL[] = "enable-websql";
|
||||
|
||||
// Widevine options
|
||||
// Path to Widevine CDM binaries.
|
||||
const char kWidevineCdmPath[] = "widevine-cdm-path";
|
||||
|
|
|
@ -84,6 +84,7 @@ extern const char kImages[];
|
|||
extern const char kTextAreasAreResizable[];
|
||||
extern const char kWebGL[];
|
||||
extern const char kNavigateOnDragDrop[];
|
||||
extern const char kEnableWebSQL[];
|
||||
|
||||
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
extern const char kSpellcheck[];
|
||||
|
@ -129,6 +130,7 @@ extern const char kWebviewTag[];
|
|||
extern const char kNodeIntegrationInSubFrames[];
|
||||
extern const char kDisableElectronSiteInstanceOverrides[];
|
||||
extern const char kEnableNodeLeakageInRenderers[];
|
||||
extern const char kEnableWebSQL[];
|
||||
|
||||
extern const char kWidevineCdmPath[];
|
||||
extern const char kWidevineCdmVersion[];
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "shell/renderer/content_settings_observer.h"
|
||||
|
||||
#include "content/public/renderer/render_frame.h"
|
||||
#include "shell/common/options_switches.h"
|
||||
#include "third_party/blink/public/platform/url_conversion.h"
|
||||
#include "third_party/blink/public/platform/web_security_origin.h"
|
||||
#include "third_party/blink/public/web/web_local_frame.h"
|
||||
|
@ -20,6 +21,11 @@ ContentSettingsObserver::ContentSettingsObserver(
|
|||
ContentSettingsObserver::~ContentSettingsObserver() = default;
|
||||
|
||||
bool ContentSettingsObserver::AllowDatabase() {
|
||||
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kEnableWebSQL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
blink::WebFrame* frame = render_frame()->GetWebFrame();
|
||||
if (frame->GetSecurityOrigin().IsOpaque() ||
|
||||
frame->Top()->GetSecurityOrigin().IsOpaque())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue