From 4bca6fe6728f68d83ae66c4164cb3f3654f88ecb Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 8 Dec 2016 15:33:51 -0800 Subject: [PATCH] Add isolated world web preference option --- atom/browser/web_contents_preferences.cc | 5 +++++ atom/common/options_switches.cc | 1 + atom/common/options_switches.h | 1 + 3 files changed, 7 insertions(+) diff --git a/atom/browser/web_contents_preferences.cc b/atom/browser/web_contents_preferences.cc index dec52501cfd0..300c2b88ae09 100644 --- a/atom/browser/web_contents_preferences.cc +++ b/atom/browser/web_contents_preferences.cc @@ -119,6 +119,11 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches( LOG(ERROR) << "preload url must be file:// protocol."; } + // Run Electron APIs and preload script in isolated world + bool isolated; + if (web_preferences.GetBoolean("isolated", &isolated) && isolated) + command_line->AppendSwitch(switches::kIsolatedWorld); + // --background-color. std::string color; if (web_preferences.GetString(options::kBackgroundColor, &color)) diff --git a/atom/common/options_switches.cc b/atom/common/options_switches.cc index 30aa48b987d7..cb33972dc425 100644 --- a/atom/common/options_switches.cc +++ b/atom/common/options_switches.cc @@ -163,6 +163,7 @@ const char kZoomFactor[] = "zoom-factor"; const char kPreloadScript[] = "preload"; const char kPreloadURL[] = "preload-url"; const char kNodeIntegration[] = "node-integration"; +const char kIsolatedWorld[] = "isolated-world"; const char kGuestInstanceID[] = "guest-instance-id"; const char kOpenerID[] = "opener-id"; const char kScrollBounce[] = "scroll-bounce"; diff --git a/atom/common/options_switches.h b/atom/common/options_switches.h index c930cabe34de..3ce8dadb32d6 100644 --- a/atom/common/options_switches.h +++ b/atom/common/options_switches.h @@ -86,6 +86,7 @@ extern const char kZoomFactor[]; extern const char kPreloadScript[]; extern const char kPreloadURL[]; extern const char kNodeIntegration[]; +extern const char kIsolatedWorld[]; extern const char kGuestInstanceID[]; extern const char kOpenerID[]; extern const char kScrollBounce[];