Use blink::SchemeRegistry over WebSecurityPolicy

The latter is removing some APIs we use.
This commit is contained in:
Cheng Zhao 2017-04-11 17:22:12 +09:00
parent 481b04358e
commit e43b34b8f8

View file

@ -23,8 +23,8 @@
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebScriptExecutionCallback.h"
#include "third_party/WebKit/public/web/WebScriptSource.h"
#include "third_party/WebKit/public/web/WebSecurityPolicy.h"
#include "third_party/WebKit/public/web/WebView.h"
#include "third_party/WebKit/Source/platform/weborigin/SchemeRegistry.h"
#include "atom/common/node_includes.h"
@ -146,12 +146,14 @@ void WebFrame::SetSpellCheckProvider(mate::Arguments* args,
void WebFrame::RegisterURLSchemeAsSecure(const std::string& scheme) {
// TODO(pfrazee): Remove 2.0
blink::SchemeRegistry::registerURLSchemeAsSecure(
WTF::String::fromUTF8(scheme.data(), scheme.length()));
}
void WebFrame::RegisterURLSchemeAsBypassingCSP(const std::string& scheme) {
// Register scheme to bypass pages's Content Security Policy.
blink::WebSecurityPolicy::registerURLSchemeAsBypassingContentSecurityPolicy(
blink::WebString::fromUTF8(scheme));
blink::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(
WTF::String::fromUTF8(scheme.data(), scheme.length()));
}
void WebFrame::RegisterURLSchemeAsPrivileged(const std::string& scheme,
@ -173,25 +175,26 @@ 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));
WTF::String privileged_scheme(
WTF::String::fromUTF8(scheme.data(), scheme.length()));
if (secure) {
// TODO(pfrazee): Remove 2.0
blink::WebSecurityPolicy::registerURLSchemeAsSecure(privileged_scheme);
blink::SchemeRegistry::registerURLSchemeAsSecure(privileged_scheme);
}
if (bypassCSP) {
blink::WebSecurityPolicy::registerURLSchemeAsBypassingContentSecurityPolicy(
blink::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(
privileged_scheme);
}
if (allowServiceWorkers) {
blink::WebSecurityPolicy::registerURLSchemeAsAllowingServiceWorkers(
blink::SchemeRegistry::registerURLSchemeAsAllowingServiceWorkers(
privileged_scheme);
}
if (supportFetchAPI) {
blink::WebSecurityPolicy::registerURLSchemeAsSupportingFetchAPI(
blink::SchemeRegistry::registerURLSchemeAsSupportingFetchAPI(
privileged_scheme);
}
if (corsEnabled) {
blink::WebSecurityPolicy::registerURLSchemeAsCORSEnabled(privileged_scheme);
blink::SchemeRegistry::registerURLSchemeAsCORSEnabled(privileged_scheme);
}
}