]> khamidou — GitHub mirrors - electron.git/commitdiff
Node integration option is now only true/false
authorCheng Zhao <zcbenz@gmail.com>
Sat, 25 Oct 2014 11:20:04 +0000 (19:20 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Sat, 25 Oct 2014 11:20:04 +0000 (19:20 +0800)
atom/browser/default_app/default_app.js
atom/browser/native_window.cc
atom/browser/native_window.h
atom/renderer/lib/init.coffee
docs/api/browser-window.md

index 84fafadbce6c759b2b5d02efa11230e6f99e9033..14ca8719c55b7ac3e42b198c7747aeaeb8814066 100644 (file)
@@ -16,7 +16,7 @@ app.on('ready', function() {
     width: 800,
     height: 600,
     resizable: false,
-    'node-integration': 'disable',
+    'node-integration': true,
     'auto-hide-menu-bar': true,
     'use-content-size': true,
     'web-preferences': {
index dfd589049638cd9177ee02cee7e58fdab2cbe961..0921340f140d91b6db45b0aeec89b2339e16fe73 100644 (file)
@@ -84,7 +84,7 @@ NativeWindow::NativeWindow(content::WebContents* web_contents,
       has_frame_(true),
       enable_larger_than_screen_(false),
       is_closed_(false),
-      node_integration_("except-iframe"),
+      node_integration_(true),
       has_dialog_attached_(false),
       zoom_factor_(1.0),
       weak_factory_(this),
@@ -94,12 +94,16 @@ NativeWindow::NativeWindow(content::WebContents* web_contents,
 
   options.Get(switches::kFrame, &has_frame_);
   options.Get(switches::kEnableLargerThanScreen, &enable_larger_than_screen_);
+  options.Get(switches::kNodeIntegration, &node_integration_);
 
   // Read icon before window is created.
   options.Get(switches::kIcon, &icon_);
 
-  // Read iframe security before any navigation.
-  options.Get(switches::kNodeIntegration, &node_integration_);
+  // Be compatible with old API of "node-integration" option.
+  std::string old_string_token;
+  if (options.Get(switches::kNodeIntegration, &old_string_token) &&
+      old_string_token != "disable")
+    node_integration_ = true;
 
   // Read the web preferences.
   options.Get(switches::kWebPreferences, &web_preferences_);
@@ -341,7 +345,7 @@ void NativeWindow::AppendExtraCommandLineSwitches(
     base::CommandLine* command_line, int child_process_id) {
   // Append --node-integration to renderer process.
   command_line->AppendSwitchASCII(switches::kNodeIntegration,
-                                  node_integration_);
+                                  node_integration_ ? "true" : "false");
 
   // Append --zoom-factor.
   if (zoom_factor_ != 1.0)
index 2b9fbfa09b4eccd91352edae832c207e2baac3f3..9accb93f0cdc8814496f49f63342668fb084412d 100644 (file)
@@ -288,8 +288,8 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
   // The windows has been closed.
   bool is_closed_;
 
-  // The security token of iframe.
-  std::string node_integration_;
+  // Whether node integration is enabled.
+  bool node_integration_;
 
   // There is a dialog that has been attached to window.
   bool has_dialog_attached_;
index 5892ef7fd22b7648c43cf7136014d1e89632e8e6..9f1de44a19c2a24707d93e16f3c641c268fbc95a 100644 (file)
@@ -22,7 +22,7 @@ require path.resolve(__dirname, '..', '..', 'common', 'lib', 'init.js')
 
 # Process command line arguments.
 isGuest = false
-nodeIntegration = 'all'
+nodeIntegration = 'false'
 for arg in process.argv
   if arg is '--guest'
     # This is a guest web view.
index 0a8cda9d5c022d95d2e0aa50593b853ac97d8e5e..dd0bd4bd06b154628eb6464094aee7ae67550239 100644 (file)
@@ -51,8 +51,8 @@ You can also create a window without chrome by using
   * `show` Boolean - Whether window should be shown when created
   * `frame` Boolean - Specify `false` to create a
     [Frameless Window](frameless-window.md)
-  * `node-integration` String - Default value is `except-iframe`, can also be
-    `all`, `manual-enable-iframe` or `disable`.
+  * `node-integration` Boolean - Whether node integration is enabled, default
+     is `true`
   * `accept-first-mouse` Boolean - Whether the web view accepts a single
      mouse-down event that simultaneously activates the window
   * `auto-hide-menu-bar` Boolean - Auto hide the menu bar unless the `Alt`