mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Refactor WebContentSettingsClient to dedupe AllowXYZ methods
https://chromium-review.googlesource.com/c/chromium/src/+/2353552
This commit is contained in:
committed by
Samuel Attard
parent
da1fea4401
commit
f1a5414372
@@ -21,22 +21,6 @@ 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())
|
||||
return false;
|
||||
auto origin = blink::WebStringToGURL(frame->GetSecurityOrigin().ToString());
|
||||
if (!origin.IsStandard())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentSettingsObserver::AllowStorage(bool local) {
|
||||
blink::WebFrame* frame = render_frame()->GetWebFrame();
|
||||
if (frame->GetSecurityOrigin().IsOpaque() ||
|
||||
@@ -48,7 +32,13 @@ bool ContentSettingsObserver::AllowStorage(bool local) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentSettingsObserver::AllowIndexedDB() {
|
||||
bool ContentSettingsObserver::AllowStorageAccessSync(StorageType storage_type) {
|
||||
if (storage_type == StorageType::kDatabase &&
|
||||
!base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kEnableWebSQL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
blink::WebFrame* frame = render_frame()->GetWebFrame();
|
||||
if (frame->GetSecurityOrigin().IsOpaque() ||
|
||||
frame->Top()->GetSecurityOrigin().IsOpaque())
|
||||
|
||||
@@ -18,9 +18,8 @@ class ContentSettingsObserver : public content::RenderFrameObserver,
|
||||
~ContentSettingsObserver() override;
|
||||
|
||||
// blink::WebContentSettingsClient implementation.
|
||||
bool AllowDatabase() override;
|
||||
bool AllowStorageAccessSync(StorageType storage_type) override;
|
||||
bool AllowStorage(bool local) override;
|
||||
bool AllowIndexedDB() override;
|
||||
|
||||
private:
|
||||
// content::RenderFrameObserver implementation.
|
||||
|
||||
Reference in New Issue
Block a user