fix: add service worker schemes from command line in renderer (#29425)
This commit is contained in:
parent
038359a7d8
commit
d18dbdd72b
5 changed files with 77 additions and 7 deletions
|
@ -87,6 +87,16 @@ std::vector<std::string> GetStandardSchemes() {
|
|||
return g_standard_schemes;
|
||||
}
|
||||
|
||||
void AddServiceWorkerScheme(const std::string& 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(scheme);
|
||||
}
|
||||
|
||||
void RegisterSchemesAsPrivileged(gin_helper::ErrorThrower thrower,
|
||||
v8::Local<v8::Value> val) {
|
||||
std::vector<CustomScheme> custom_schemes;
|
||||
|
@ -123,13 +133,7 @@ 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);
|
||||
AddServiceWorkerScheme(custom_scheme.scheme);
|
||||
}
|
||||
if (custom_scheme.options.stream) {
|
||||
g_streaming_schemes.push_back(custom_scheme.scheme);
|
||||
|
|
|
@ -22,6 +22,8 @@ namespace api {
|
|||
|
||||
std::vector<std::string> GetStandardSchemes();
|
||||
|
||||
void AddServiceWorkerScheme(const std::string& scheme);
|
||||
|
||||
void RegisterSchemesAsPrivileged(gin_helper::ErrorThrower thrower,
|
||||
v8::Local<v8::Value> val);
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "electron/buildflags/buildflags.h"
|
||||
#include "media/blink/multibuffer_data_source.h"
|
||||
#include "printing/buildflags/buildflags.h"
|
||||
#include "shell/browser/api/electron_api_protocol.h"
|
||||
#include "shell/common/api/electron_api_native_image.h"
|
||||
#include "shell/common/color_util.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
|
@ -111,6 +112,11 @@ RendererClientBase* g_renderer_client_base = nullptr;
|
|||
|
||||
RendererClientBase::RendererClientBase() {
|
||||
auto* command_line = base::CommandLine::ForCurrentProcess();
|
||||
// Parse --service-worker-schemes=scheme1,scheme2
|
||||
std::vector<std::string> service_worker_schemes_list =
|
||||
ParseSchemesCLISwitch(command_line, switches::kServiceWorkerSchemes);
|
||||
for (const std::string& scheme : service_worker_schemes_list)
|
||||
electron::api::AddServiceWorkerScheme(scheme);
|
||||
// Parse --standard-schemes=scheme1,scheme2
|
||||
std::vector<std::string> standard_schemes_list =
|
||||
ParseSchemesCLISwitch(command_line, switches::kStandardSchemes);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue