Skip to content

Commit

Permalink
Bring back SchemeRegistry::RegisterURLSchemeAsCORSEnabled()
Browse files Browse the repository at this point in the history
Removed in https://crrev.com/c/530888 and https://crrev.com/c/584663.

It is used by Electron to implement API method
`webFrame.registerURLSchemeAsPrivileged()` [1].
`corsEnabled` option of this method defaults to `true` and removing it
without having an alternative way to mark a certain URL scheme
as CORS enabled would break some application that use Electron.

It would be great if Chromium could keep `RegisterURLSchemeAsCORSEnabled()`
method to make Electron's maintainers and users life a little bit easier.

[1] https://electron.atom.io/docs/api/web-frame/#webframeregisterurlschemeasprivilegedscheme-options

R=mkwst@chromium.org, tyoshino@chromium.org

Bug: 
Change-Id: Ifc548df6472db45111e8c32fe9efea4a50baa2a0
Reviewed-on: https://chromium-review.googlesource.com/768808
Commit-Queue: Takeshi Yoshino <tyoshino@chromium.org>
Reviewed-by: Takeshi Yoshino <tyoshino@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519055}
  • Loading branch information
alexeykuzmin authored and Commit Bot committed Nov 24, 2017
1 parent 497b42b commit 175d399
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Alexandre Abreu <wiss1976@gmail.com>
Alexandru Chiculita <achicu@adobe.com>
Alexey Korepanov <alexkorep@gmail.com>
Alexey Kuts <kruntuid@gmail.com>
Alexey Kuzmin <alex.s.kuzmin@gmail.com>
Alexis Brenon <brenon.alexis@gmail.com>
Alexis La Goutte <alexis.lagoutte@gmail.com>
Alexis Menard <alexis.menard@intel.com>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ bool SchemeRegistry::ShouldTreatURLSchemeAsNotAllowingJavascriptURLs(
scheme);
}

void SchemeRegistry::RegisterURLSchemeAsCORSEnabled(const String& scheme) {
DCHECK_EQ(scheme, scheme.DeprecatedLower());
GetMutableURLSchemesRegistry().cors_enabled_schemes.insert(scheme);
}

bool SchemeRegistry::ShouldTreatURLSchemeAsCORSEnabled(const String& scheme) {
DCHECK_EQ(scheme, scheme.DeprecatedLower());
if (scheme.IsEmpty())
Expand Down
5 changes: 5 additions & 0 deletions third_party/WebKit/Source/platform/weborigin/SchemeRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ class PLATFORM_EXPORT SchemeRegistry {
const String& scheme);

// Allow non-HTTP schemes to be registered to allow CORS requests.
// This is not used in Chromium anymore but left here intentionally
// to allow other embedders of Blink to add more schemes
// to the CORS-enabled schemes list.
// As for now (Nov 2017) it is used by Electron.
static void RegisterURLSchemeAsCORSEnabled(const String& scheme);
static bool ShouldTreatURLSchemeAsCORSEnabled(const String& scheme);

// Serialize the registered schemes in a comma-separated list.
Expand Down

0 comments on commit 175d399

Please sign in to comment.