webframe: api to register scheme as privileged
This commit is contained in:
parent
01a3bf5881
commit
325feca864
3 changed files with 21 additions and 1 deletions
|
@ -98,6 +98,16 @@ void WebFrame::RegisterURLSchemeAsBypassingCsp(const std::string& scheme) {
|
|||
blink::WebString::fromUTF8(scheme));
|
||||
}
|
||||
|
||||
void WebFrame::RegisterURLSchemeAsPrivileged(const std::string& scheme) {
|
||||
// Register scheme to privileged list (https, wss, data, chrome-extension)
|
||||
blink::WebString privileged_scheme(blink::WebString::fromUTF8(scheme));
|
||||
blink::WebSecurityPolicy::registerURLSchemeAsSecure(privileged_scheme);
|
||||
blink::WebSecurityPolicy::registerURLSchemeAsBypassingContentSecurityPolicy(
|
||||
privileged_scheme);
|
||||
blink::WebSecurityPolicy::registerURLSchemeAsAllowingServiceWorkers(
|
||||
privileged_scheme);
|
||||
}
|
||||
|
||||
mate::ObjectTemplateBuilder WebFrame::GetObjectTemplateBuilder(
|
||||
v8::Isolate* isolate) {
|
||||
return mate::ObjectTemplateBuilder(isolate)
|
||||
|
@ -116,7 +126,9 @@ mate::ObjectTemplateBuilder WebFrame::GetObjectTemplateBuilder(
|
|||
.SetMethod("registerUrlSchemeAsSecure",
|
||||
&WebFrame::RegisterURLSchemeAsSecure)
|
||||
.SetMethod("registerUrlSchemeAsBypassingCsp",
|
||||
&WebFrame::RegisterURLSchemeAsBypassingCsp);
|
||||
&WebFrame::RegisterURLSchemeAsBypassingCsp)
|
||||
.SetMethod("registerUrlSchemeAsPrivileged",
|
||||
&WebFrame::RegisterURLSchemeAsPrivileged);
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
|
@ -58,6 +58,7 @@ class WebFrame : public mate::Wrappable {
|
|||
|
||||
void RegisterURLSchemeAsSecure(const std::string& scheme);
|
||||
void RegisterURLSchemeAsBypassingCsp(const std::string& scheme);
|
||||
void RegisterURLSchemeAsPrivileged(const std::string& scheme);
|
||||
|
||||
// mate::Wrappable:
|
||||
virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
|
||||
|
|
|
@ -83,4 +83,11 @@ attackers.
|
|||
Resources will be loaded from this `scheme` regardless of the current page's
|
||||
Content Security Policy.
|
||||
|
||||
### `webFrame.registerUrlSchemeAsPrivileged(scheme)`
|
||||
|
||||
* `scheme` String
|
||||
|
||||
Registers the `scheme` as secure, bypasses content security policy for resources and
|
||||
allows registering ServiceWorker.
|
||||
|
||||
[spellchecker]: https://github.com/atom/node-spellchecker
|
||||
|
|
Loading…
Reference in a new issue