Refactor WebContentSettingsClient to dedupe AllowXYZ methods

https://chromium-review.googlesource.com/c/chromium/src/+/2353552
This commit is contained in:
deepak1556
2020-09-10 21:14:09 -07:00
committed by Samuel Attard
parent da1fea4401
commit f1a5414372
2 changed files with 8 additions and 19 deletions

View File

@@ -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())

View File

@@ -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.