Skip to content

Commit

Permalink
fix: propagate unsafely-treat-insecure-origin-as-secure to renderer c…
Browse files Browse the repository at this point in the history
…hildren
  • Loading branch information
nornagon committed Mar 8, 2022
1 parent f45aaea commit 3aa82fe
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions shell/browser/electron_browser_client.cc
Expand Up @@ -21,6 +21,7 @@
#include "base/no_destructor.h"
#include "base/path_service.h"
#include "base/stl_util.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
Expand Down Expand Up @@ -63,6 +64,8 @@
#include "printing/buildflags/buildflags.h"
#include "services/device/public/cpp/geolocation/location_provider.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/is_potentially_trustworthy.h"
#include "services/network/public/cpp/network_switches.h"
#include "services/network/public/cpp/resource_request_body.h"
#include "services/network/public/cpp/self_deleting_url_loader_factory.h"
#include "shell/app/electron_crash_reporter_client.h"
Expand Down Expand Up @@ -625,16 +628,27 @@ void ElectronBrowserClient::AppendExtraCommandLineSwitches(
command_line->AppendSwitch("profile-electron-init");
}

content::RenderProcessHost* process =
content::RenderProcessHost::FromID(process_id);

// Extension background pages don't have WebContentsPreferences, but they
// support WebSQL by default.
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
content::RenderProcessHost* process =
content::RenderProcessHost::FromID(process_id);
if (extensions::ProcessMap::Get(process->GetBrowserContext())
->Contains(process_id))
command_line->AppendSwitch(switches::kEnableWebSQL);
#endif

if (process) {
std::vector<std::string> allowlist =
network::SecureOriginAllowlist::GetInstance().GetCurrentAllowlist();
if (!allowlist.empty()) {
command_line->AppendSwitchASCII(
network::switches::kUnsafelyTreatInsecureOriginAsSecure,
base::JoinString(allowlist, ","));
}
}

content::WebContents* web_contents =
GetWebContentsFromProcessID(process_id);
if (web_contents) {
Expand Down

0 comments on commit 3aa82fe

Please sign in to comment.