fix: make sure service worker scheme is registered with allowServiceWorkers (#28326)
* Fix custom scheme not registered as service worker scheme * ServiceWorker loaders do not have WebContents associated * Add test for service worker * Revert "Fix custom scheme not registered as service worker scheme" This reverts commit a249235b220a0edcfcb906e0b3b3c0486ece73a6. * Add scheme to ServiceWorkerSchemes
This commit is contained in:
parent
7c36463085
commit
1e9e2f8cf6
4 changed files with 54 additions and 9 deletions
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "base/command_line.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "content/common/url_schemes.h"
|
||||
#include "content/public/browser/child_process_security_policy.h"
|
||||
#include "gin/object_template_builder.h"
|
||||
#include "shell/browser/browser.h"
|
||||
|
@ -124,6 +125,13 @@ void RegisterSchemesAsPrivileged(gin_helper::ErrorThrower thrower,
|
|||
}
|
||||
if (custom_scheme.options.allowServiceWorkers) {
|
||||
service_worker_schemes.push_back(custom_scheme.scheme);
|
||||
// There is no API to add service worker scheme, but there is an API to
|
||||
// return const reference to the schemes vector.
|
||||
// If in future the API is changed to return a copy instead of reference,
|
||||
// the compilation will fail, and we should add a patch at that time.
|
||||
auto& mutable_schemes = const_cast<std::vector<std::string>&>(
|
||||
content::GetServiceWorkerSchemes());
|
||||
mutable_schemes.push_back(custom_scheme.scheme);
|
||||
}
|
||||
if (custom_scheme.options.stream) {
|
||||
g_streaming_schemes.push_back(custom_scheme.scheme);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue