From d427ae10301be73844deea427f144e94bf457e94 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Thu, 19 Nov 2015 00:39:45 -0800 Subject: [PATCH 01/23] Support the "desktop" window type on Mac OS X Adds the desktop window type referenced in https://github.com/atom/electron/issues/2899 for compatiblity with the linux version. Note that on Mac OS X, the desktop window cannot receive input events (seems to be a limitation of being behind the desktop). In this diff I also removed the `standardWindow` option from the docs, in favor of an additional `textured` value for window `type` on Mac OS X. The old `standardWindow` option continues to work, but seemed more confusing. If this seems like a bad idea, I can revert that change. --- atom/browser/native_window_mac.mm | 34 +++++++++++++++++++++++++++++-- docs/api/browser-window.md | 19 +++++++++-------- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index b129ded6f85e..5564f9116e4b 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -211,6 +211,8 @@ bool ScopedDisableResize::disable_resize_ = false; } @property BOOL acceptsFirstMouse; @property BOOL disableAutoHideCursor; +@property BOOL disableKeyOrMainWindow; + - (void)setShell:(atom::NativeWindowMac*)shell; - (void)setEnableLargerThanScreen:(bool)enable; @end @@ -257,6 +259,16 @@ bool ScopedDisableResize::disable_resize_ = false; return [children filteredArrayUsingPredicate:predicate]; } +- (BOOL)canBecomeMainWindow +{ + return !self.disableKeyOrMainWindow; +} + +- (BOOL)canBecomeKeyWindow +{ + return !self.disableKeyOrMainWindow; +} + @end @interface ControlRegionView : NSView @@ -330,8 +342,6 @@ NativeWindowMac::NativeWindowMac( width, height); - bool useStandardWindow = true; - options.Get(options::kStandardWindow, &useStandardWindow); bool resizable = true; options.Get(options::kResizable, &resizable); @@ -340,6 +350,17 @@ NativeWindowMac::NativeWindowMac( if (base::mac::IsOSYosemiteOrLater()) options.Get(options::kTitleBarStyle, &titleBarStyle); + std::string windowType; + options.Get(options::kType, &windowType); + + bool useStandardWindow = true; + // eventually deprecate separate "standardWindow" option in favor of + // standard / textured window types + options.Get(options::kStandardWindow, &useStandardWindow); + if (windowType == "textured") { + useStandardWindow = false; + } + NSUInteger styleMask = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask; if (!useStandardWindow || transparent() || !has_frame()) { @@ -371,6 +392,15 @@ NativeWindowMac::NativeWindowMac( [window_ setBackgroundColor:[NSColor clearColor]]; } + if (windowType == "desktop") { + [window_ setLevel:kCGDesktopWindowLevel - 1]; + [window_ setDisableKeyOrMainWindow: YES]; + [window_ setCollectionBehavior: + (NSWindowCollectionBehaviorCanJoinAllSpaces | + NSWindowCollectionBehaviorStationary | + NSWindowCollectionBehaviorIgnoresCycle)]; + } + // Remove non-transparent corners, see http://git.io/vfonD. if (!has_frame()) [window_ setOpaque:NO]; diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index f9b2a53ff595..a78531277e9e 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -66,11 +66,14 @@ It creates a new `BrowserWindow` with native properties as set by the `options`. * `darkTheme` Boolean - Forces using dark theme for the window, only works on some GTK+3 desktop environments. * `transparent` Boolean - Makes the window [transparent](frameless-window.md). -* `type` String - Specifies the type of the window, possible types are - `desktop`, `dock`, `toolbar`, `splash`, `notification`. This only works on - Linux. -* `standardWindow` Boolean - Uses the OS X's standard window instead of the - textured window. Defaults to `true`. +* `type` String - Specifies the type of the window, which applies + additional platform-specific properties. + - On Linux, possible types are `desktop`, `dock`, `toolbar`, `splash`, `notification`. + - On Mac OS X: + - `textured`: Adds metal gradient appearance (NSTexturedBackgroundWindowMask) + - `desktop`: Places the window at the desktop background window level (kCGDesktopWindowLevel - 1). + Note that the window will not receive focus, keyboard or mouse events, but + you can use `globalShortcut` to receive input sparingly. * `titleBarStyle` String, OS X - specifies the style of window title bar. This option is supported on OS X 10.10 Yosemite and newer. There are three possible values: @@ -86,11 +89,11 @@ It creates a new `BrowserWindow` with native properties as set by the `options`. is `true`. * `preload` String - Specifies a script that will be loaded before other scripts run in the page. This script will always have access to node APIs - no matter whether node integration is turned on or off. The value should + no matter whether node integration is turned on or off. The value should be the absolute file path to the script. - When node integration is turned off, the preload script can reintroduce - Node global symbols back to the global scope. See example + When node integration is turned off, the preload script can reintroduce + Node global symbols back to the global scope. See example [here](process.md#event-loaded). * `partition` String - Sets the session used by the page. If `partition` starts with `persist:`, the page will use a persistent session available to From 47d7d49d192e79770c2dd4b73e2279a199d450cd Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 19 Nov 2015 20:47:11 +0800 Subject: [PATCH 02/23] Add session module --- atom/browser/api/lib/app.coffee | 6 ------ atom/browser/api/lib/exports/electron.coffee | 3 +++ atom/browser/api/lib/session.coffee | 17 +++++++++++++++++ atom/browser/api/lib/web-contents.coffee | 2 +- filenames.gypi | 1 + 5 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 atom/browser/api/lib/session.coffee diff --git a/atom/browser/api/lib/app.coffee b/atom/browser/api/lib/app.coffee index 3db4582abc7c..9f9f5811d76a 100644 --- a/atom/browser/api/lib/app.coffee +++ b/atom/browser/api/lib/app.coffee @@ -2,7 +2,6 @@ electron = require 'electron' {EventEmitter} = require 'events' bindings = process.atomBinding 'app' -sessionBindings = process.atomBinding 'session' downloadItemBindings = process.atomBinding 'download_item' app = bindings.app @@ -61,11 +60,6 @@ deprecate.event app, 'activate-with-no-open-windows', 'activate', (event, hasVis deprecate.event app, 'select-certificate', 'select-client-certificate' # Wrappers for native classes. -wrapSession = (session) -> - # session is an EventEmitter. - session.__proto__ = EventEmitter.prototype -sessionBindings._setWrapSession wrapSession - wrapDownloadItem = (downloadItem) -> # downloadItem is an EventEmitter. downloadItem.__proto__ = EventEmitter.prototype diff --git a/atom/browser/api/lib/exports/electron.coffee b/atom/browser/api/lib/exports/electron.coffee index f0c3b87c987b..3f7d9b1a13fe 100644 --- a/atom/browser/api/lib/exports/electron.coffee +++ b/atom/browser/api/lib/exports/electron.coffee @@ -42,6 +42,9 @@ Object.defineProperties module.exports, screen: enumerable: true get: -> require '../screen' + session: + enumerable: true + get: -> require '../session' Tray: enumerable: true get: -> require '../tray' diff --git a/atom/browser/api/lib/session.coffee b/atom/browser/api/lib/session.coffee new file mode 100644 index 000000000000..e0fc7b6e0bca --- /dev/null +++ b/atom/browser/api/lib/session.coffee @@ -0,0 +1,17 @@ +{EventEmitter} = require 'events' + +bindings = process.atomBinding 'session' + +PERSIST_PERFIX = 'persist:' + +exports.fromPartition = (partition='') -> + if partition.startsWith PERSIST_PERFIX + bindings.fromPartition partition.substr(PERSIST_PERFIX.length), false + else + bindings.fromPartition partition, true + +wrapSession = (session) -> + # session is an EventEmitter. + session.__proto__ = EventEmitter.prototype + +bindings._setWrapSession wrapSession diff --git a/atom/browser/api/lib/web-contents.coffee b/atom/browser/api/lib/web-contents.coffee index 1a224c7416f5..335928dcea81 100644 --- a/atom/browser/api/lib/web-contents.coffee +++ b/atom/browser/api/lib/web-contents.coffee @@ -1,5 +1,5 @@ {EventEmitter} = require 'events' -{deprecate, ipcMain, NavigationController, Menu} = require 'electron' +{deprecate, ipcMain, session, NavigationController, Menu} = require 'electron' binding = process.atomBinding 'web_contents' diff --git a/filenames.gypi b/filenames.gypi index 7e1f3e1827e0..7157079178ee 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -26,6 +26,7 @@ 'atom/browser/api/lib/power-monitor.coffee', 'atom/browser/api/lib/power-save-blocker.coffee', 'atom/browser/api/lib/protocol.coffee', + 'atom/browser/api/lib/session.coffee', 'atom/browser/api/lib/screen.coffee', 'atom/browser/api/lib/tray.coffee', 'atom/browser/api/lib/web-contents.coffee', From 1392873cbc2c522877448cec2990c73517f29912 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 19 Nov 2015 21:03:42 +0800 Subject: [PATCH 03/23] Add session.defaultSession and remove app.defaultSession The latter has never been a public API, no need to keep it. --- atom/browser/api/atom_api_app.cc | 18 +----------------- atom/browser/api/atom_api_app.h | 3 --- atom/browser/api/lib/app.coffee | 10 +++++----- atom/browser/api/lib/browser-window.coffee | 4 +++- atom/browser/api/lib/session.coffee | 6 ++++++ 5 files changed, 15 insertions(+), 26 deletions(-) diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 28c3b4c15983..697d6eca6aab 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -206,14 +206,6 @@ void App::OnWillFinishLaunching() { } void App::OnFinishLaunching() { - // Create the defaultSession. - v8::Locker locker(isolate()); - v8::HandleScope handle_scope(isolate()); - auto browser_context = static_cast( - AtomBrowserMainParts::Get()->browser_context()); - auto handle = Session::CreateFrom(isolate(), browser_context); - default_session_.Reset(isolate(), handle.ToV8()); - Emit("ready"); } @@ -325,13 +317,6 @@ std::string App::GetLocale() { return l10n_util::GetApplicationLocale(""); } -v8::Local App::DefaultSession(v8::Isolate* isolate) { - if (default_session_.IsEmpty()) - return v8::Null(isolate); - else - return v8::Local::New(isolate, default_session_); -} - bool App::MakeSingleInstance( const ProcessSingleton::NotificationCallback& callback) { if (process_singleton_.get()) @@ -382,8 +367,7 @@ mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder( .SetMethod("allowNTLMCredentialsForAllDomains", &App::AllowNTLMCredentialsForAllDomains) .SetMethod("getLocale", &App::GetLocale) - .SetMethod("makeSingleInstance", &App::MakeSingleInstance) - .SetProperty("defaultSession", &App::DefaultSession); + .SetMethod("makeSingleInstance", &App::MakeSingleInstance); } // static diff --git a/atom/browser/api/atom_api_app.h b/atom/browser/api/atom_api_app.h index ee7e02079125..a6f99d65e0af 100644 --- a/atom/browser/api/atom_api_app.h +++ b/atom/browser/api/atom_api_app.h @@ -87,9 +87,6 @@ class App : public AtomBrowserClient::Delegate, bool MakeSingleInstance( const ProcessSingleton::NotificationCallback& callback); std::string GetLocale(); - v8::Local DefaultSession(v8::Isolate* isolate); - - v8::Global default_session_; scoped_ptr process_singleton_; diff --git a/atom/browser/api/lib/app.coffee b/atom/browser/api/lib/app.coffee index 9f9f5811d76a..c2116fb7bca4 100644 --- a/atom/browser/api/lib/app.coffee +++ b/atom/browser/api/lib/app.coffee @@ -1,4 +1,4 @@ -electron = require 'electron' +{deprecate, session, Menu} = require 'electron' {EventEmitter} = require 'events' bindings = process.atomBinding 'app' @@ -8,10 +8,10 @@ app = bindings.app app.__proto__ = EventEmitter.prototype app.setApplicationMenu = (menu) -> - electron.Menu.setApplicationMenu menu + Menu.setApplicationMenu menu app.getApplicationMenu = -> - electron.Menu.getApplicationMenu() + Menu.getApplicationMenu() app.commandLine = appendSwitch: bindings.appendSwitch, @@ -35,7 +35,8 @@ app.getAppPath = -> appPath # Helpers. -app.resolveProxy = (url, callback) -> @defaultSession.resolveProxy url, callback +app.resolveProxy = (url, callback) -> + session.defaultSession.resolveProxy url, callback # Routes the events to webContents. for name in ['login', 'certificate-error', 'select-client-certificate'] @@ -44,7 +45,6 @@ for name in ['login', 'certificate-error', 'select-client-certificate'] webContents.emit name, event, args... # Deprecated. -{deprecate} = electron app.getHomeDir = deprecate 'app.getHomeDir', 'app.getPath', -> @getPath 'home' app.getDataPath = deprecate 'app.getDataPath', 'app.getPath', -> diff --git a/atom/browser/api/lib/browser-window.coffee b/atom/browser/api/lib/browser-window.coffee index 99921372f14c..4cdffae87a60 100644 --- a/atom/browser/api/lib/browser-window.coffee +++ b/atom/browser/api/lib/browser-window.coffee @@ -1,10 +1,12 @@ -{app, ipcMain, deprecate} = require 'electron' +{ipcMain, deprecate} = require 'electron' {EventEmitter} = require 'events' {BrowserWindow} = process.atomBinding 'window' BrowserWindow::__proto__ = EventEmitter.prototype BrowserWindow::_init = -> + {app} = require 'electron' # avoid recursive require. + # Simulate the application menu on platforms other than OS X. if process.platform isnt 'darwin' menu = app.getApplicationMenu() diff --git a/atom/browser/api/lib/session.coffee b/atom/browser/api/lib/session.coffee index e0fc7b6e0bca..6abfe7925e69 100644 --- a/atom/browser/api/lib/session.coffee +++ b/atom/browser/api/lib/session.coffee @@ -4,12 +4,18 @@ bindings = process.atomBinding 'session' PERSIST_PERFIX = 'persist:' +# Returns the Session from |partition| string. exports.fromPartition = (partition='') -> if partition.startsWith PERSIST_PERFIX bindings.fromPartition partition.substr(PERSIST_PERFIX.length), false else bindings.fromPartition partition, true +# Returns the default session. +Object.defineProperty exports, 'defaultSession', + enumerable: true + get: -> exports.fromPartition '' + wrapSession = (session) -> # session is an EventEmitter. session.__proto__ = EventEmitter.prototype From dd8ef33e42e46bf5d80776b77ab457d1761bbc33 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 19 Nov 2015 21:10:50 +0800 Subject: [PATCH 04/23] docs: webContents.savePage is placed at wrong place --- docs/api/web-contents.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index be22d947c752..2b2efb7d47ba 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -678,17 +678,6 @@ is in 32bit ARGB format). End subscribing for frame presentation events. -## Instance Properties - -`WebContents` objects also have the following properties: - -### `webContents.devToolsWebContents` - -Get the `WebContents` of DevTools for this `WebContents`. - -**Note:** Users should never store this object because it may become `null` -when the DevTools has been closed. - ### `webContents.savePage(fullPath, saveType, callback)` * `fullPath` String - The full file path. @@ -711,3 +700,14 @@ win.webContents.on('did-finish-load', function() { }); }); ``` + +## Instance Properties + +`WebContents` objects also have the following properties: + +### `webContents.devToolsWebContents` + +Get the `WebContents` of DevTools for this `WebContents`. + +**Note:** Users should never store this object because it may become `null` +when the DevTools has been closed. From 44c562ebd9ec14a421b85dd63967bae2f3166373 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 19 Nov 2015 21:31:39 +0800 Subject: [PATCH 05/23] docs: New session methods --- docs/api/session.md | 79 +++++++++++++++++++++++++++++++++------------ 1 file changed, 58 insertions(+), 21 deletions(-) diff --git a/docs/api/session.md b/docs/api/session.md index 450be7b08e11..b921fc4839bd 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -1,8 +1,10 @@ # session -The `session` object is a property of [`webContents`](web-contents.md) which is -a property of [`BrowserWindow`](browser-window.md). You can access it through an -instance of `BrowserWindow`. For example: +The `session` module can be used to create new `Session` objects. + +You can also access the `session` of existing pages by using the `session` +property of [`webContents`](web-contents.md) which is a property of +[`BrowserWindow`](browser-window.md). ```javascript const BrowserWindow = require('electron').BrowserWindow; @@ -10,12 +12,47 @@ const BrowserWindow = require('electron').BrowserWindow; var win = new BrowserWindow({ width: 800, height: 600 }); win.loadURL("http://github.com"); -var session = win.webContents.session +var ses = win.webContents.session ``` -## Events +## Methods -### Event: 'will-download' +The `session` module has the following methods: + +### session.fromPartition(partition) + +* `partition` String + +Returns a new `Session` instance from `partition` string. + +If `partition` starts with `persist:`, the page will use a persistent session +available to all pages in the app with the same `partition`. if there is no +`persist:` prefix, the page will use an in-memory session. If the `partition` is +empty then default session of the app will be returned. + +## Properties + +The `session` module has the following properties: + +### session.defaultSession + +Returns the default session object of the app. + +## Class: Session + +You can create a `Session` object in the `session` module: + +```javascript +const session = require('electron').session; + +var ses = session.fromPartition('persist:name'); +``` + +### Instance Events + +The following events are available on instances of `Session`: + +#### Event: 'will-download' * `event` Event * `item` [DownloadItem](download-item.md) @@ -34,11 +71,11 @@ session.on('will-download', function(event, item, webContents) { }); ``` -## Methods +### Instance Methods -The `session` object has the following methods: +The following methods are available on instances of `Session`: -### `session.cookies` +#### `ses.cookies` The `cookies` gives you ability to query and modify cookies. For example: @@ -74,7 +111,7 @@ win.webContents.on('did-finish-load', function() { }); ``` -### `session.cookies.get(details, callback)` +#### `ses.cookies.get(details, callback)` `details` Object, properties: @@ -102,7 +139,7 @@ win.webContents.on('did-finish-load', function() { the number of seconds since the UNIX epoch. Not provided for session cookies. -### `session.cookies.set(details, callback)` +#### `ses.cookies.set(details, callback)` `details` Object, properties: @@ -121,23 +158,23 @@ win.webContents.on('did-finish-load', function() { * `callback` Function - function(error) * `error` Error -### `session.cookies.remove(details, callback)` +#### `ses.cookies.remove(details, callback)` -* `details` Object, proprties: +* `details` Object * `url` String - The URL associated with the cookie * `name` String - The name of cookie to remove * `callback` Function - function(error) * `error` Error -### `session.clearCache(callback)` +#### `ses.clearCache(callback)` * `callback` Function - Called when operation is done Clears the session’s HTTP cache. -### `session.clearStorageData([options, ]callback)` +#### `ses.clearStorageData([options, ]callback)` -* `options` Object (optional), proprties: +* `options` Object (optional) * `origin` String - Should follow `window.location.origin`’s representation `scheme://host:port`. * `storages` Array - The types of storages to clear, can contain: @@ -149,7 +186,7 @@ Clears the session’s HTTP cache. Clears the data of web storages. -### `session.setProxy(config, callback)` +#### `ses.setProxy(config, callback)` * `config` String * `callback` Function - Called when operation is done. @@ -187,14 +224,14 @@ proxy-uri = ["://"][":"] URLs. ``` -### `session.setDownloadPath(path)` +#### `ses.setDownloadPath(path)` * `path` String - The download location Sets download saving directory. By default, the download directory will be the `Downloads` under the respective app folder. -### `session.enableNetworkEmulation(options)` +#### `ses.enableNetworkEmulation(options)` * `options` Object * `offline` Boolean - Whether to emulate network outage. @@ -216,12 +253,12 @@ window.webContents.session.enableNetworkEmulation({ window.webContents.session.enableNetworkEmulation({offline: true}); ``` -### `session.disableNetworkEmulation` +#### `ses.disableNetworkEmulation()` Disables any network emulation already active for the `session`. Resets to the original network configuration. -### `session.setCertificateVerifyProc(proc)` +#### `ses.setCertificateVerifyProc(proc)` * `proc` Function From 08c13cf446d509c79770e8ad635f7d4b339092bb Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 19 Nov 2015 21:32:46 +0800 Subject: [PATCH 06/23] Deprecate app.resolveProxy There is now a public API to get default session, this helper is no longer necessary. --- atom/browser/api/lib/app.coffee | 6 ++---- docs/api/app.md | 8 -------- docs/api/session.md | 8 ++++++++ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/atom/browser/api/lib/app.coffee b/atom/browser/api/lib/app.coffee index c2116fb7bca4..a2fdb847e1c5 100644 --- a/atom/browser/api/lib/app.coffee +++ b/atom/browser/api/lib/app.coffee @@ -34,10 +34,6 @@ app.setAppPath = (path) -> app.getAppPath = -> appPath -# Helpers. -app.resolveProxy = (url, callback) -> - session.defaultSession.resolveProxy url, callback - # Routes the events to webContents. for name in ['login', 'certificate-error', 'select-client-certificate'] do (name) -> @@ -51,6 +47,8 @@ app.getDataPath = deprecate 'app.getDataPath', 'app.getPath', -> @getPath 'userData' app.setDataPath = deprecate 'app.setDataPath', 'app.setPath', (path) -> @setPath 'userData', path +app.resolveProxy = deprecate 'app.resolveProxy', 'session.defaultSession.resolveProxy', (url, callback) -> + session.defaultSession.resolveProxy url, callback deprecate.rename app, 'terminate', 'quit' deprecate.event app, 'finish-launching', 'ready', -> setImmediate => # give default app a chance to setup default menu. diff --git a/docs/api/app.md b/docs/api/app.md index d7850c4cb92c..a1d87d2fe993 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -311,14 +311,6 @@ preferred over `name` by Electron. Returns the current application locale. -### `app.resolveProxy(url, callback)` - -* `url` URL -* `callback` Function - -Resolves the proxy information for `url`. The `callback` will be called with -`callback(proxy)` when the request is performed. - ### `app.addRecentDocument(path)` _OS X_ _Windows_ * `path` String diff --git a/docs/api/session.md b/docs/api/session.md index b921fc4839bd..a69c5939ed65 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -224,6 +224,14 @@ proxy-uri = ["://"][":"] URLs. ``` +### `ses.resolveProxy(url, callback)` + +* `url` URL +* `callback` Function + +Resolves the proxy information for `url`. The `callback` will be called with +`callback(proxy)` when the request is performed. + #### `ses.setDownloadPath(path)` * `path` String - The download location From 611f87d17f3fa80529e667199de112954c8d9982 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 19 Nov 2015 21:42:22 +0800 Subject: [PATCH 07/23] spec: Use session.defaultSession in tests --- spec/api-session-spec.coffee | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/api-session-spec.coffee b/spec/api-session-spec.coffee index bf91bdd6fc77..6d0a8ac167c0 100644 --- a/spec/api-session-spec.coffee +++ b/spec/api-session-spec.coffee @@ -4,7 +4,7 @@ path = require 'path' fs = require 'fs' {ipcRenderer, remote} = require 'electron' -{app, ipcMain, BrowserWindow} = remote.require 'electron' +{app, ipcMain, session, BrowserWindow} = remote describe 'session module', -> @timeout 10000 @@ -35,9 +35,9 @@ describe 'session module', -> done('Can not find cookie') it 'should over-write the existent cookie', (done) -> - app.defaultSession.cookies.set {url: url, name: '1', value: '1'}, (error) -> + session.defaultSession.cookies.set {url: url, name: '1', value: '1'}, (error) -> return done(error) if error - app.defaultSession.cookies.get {url: url}, (error, list) -> + session.defaultSession.cookies.get {url: url}, (error, list) -> return done(error) if error for cookie in list when cookie.name is '1' if cookie.value is '1' @@ -47,11 +47,11 @@ describe 'session module', -> done('Can not find cookie') it 'should remove cookies', (done) -> - app.defaultSession.cookies.set {url: url, name: '2', value: '2'}, (error) -> + session.defaultSession.cookies.set {url: url, name: '2', value: '2'}, (error) -> return done(error) if error - app.defaultSession.cookies.remove {url: url, name: '2'}, (error) -> + session.defaultSession.cookies.remove {url: url, name: '2'}, (error) -> return done(error) if error - app.defaultSession.cookies.get {url: url}, (error, list) -> + session.defaultSession.cookies.get {url: url}, (error, list) -> return done(error) if error for cookie in list when cookie.name is '2' return done('Cookie not deleted') From 1b464c82e1e99dce6d95f0ac302d601c8e268b3d Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 19 Nov 2015 21:48:45 +0800 Subject: [PATCH 08/23] docs: Put webContents.session under Properties --- docs/api/web-contents.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 2b2efb7d47ba..a716bdc593a7 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -225,12 +225,6 @@ The usage is the same with [the `login` event of `app`](app.md#event-login). The `webContents` object has the following instance methods: -### `webContents.session` - -Returns the `session` object used by this webContents. - -See [session documentation](session.md) for this object's methods. - ### `webContents.loadURL(url[, options])` * `url` URL @@ -705,6 +699,10 @@ win.webContents.on('did-finish-load', function() { `WebContents` objects also have the following properties: +### `webContents.session` + +Returns the [session](session.md) object used by this webContents. + ### `webContents.devToolsWebContents` Get the `WebContents` of DevTools for this `WebContents`. From 65c823407dbd792e4227222b83c110422a1fc179 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Thu, 19 Nov 2015 10:04:28 -0800 Subject: [PATCH 09/23] Address feedback --- docs/api/browser-window.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index a78531277e9e..46b7c96ae594 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -68,12 +68,14 @@ It creates a new `BrowserWindow` with native properties as set by the `options`. * `transparent` Boolean - Makes the window [transparent](frameless-window.md). * `type` String - Specifies the type of the window, which applies additional platform-specific properties. - - On Linux, possible types are `desktop`, `dock`, `toolbar`, `splash`, `notification`. - - On Mac OS X: - - `textured`: Adds metal gradient appearance (NSTexturedBackgroundWindowMask) - - `desktop`: Places the window at the desktop background window level (kCGDesktopWindowLevel - 1). - Note that the window will not receive focus, keyboard or mouse events, but - you can use `globalShortcut` to receive input sparingly. + * On Linux, possible types are `desktop`, `dock`, `toolbar`, `splash`, + `notification`. + * On OS X, possible types are `desktop`, `textured`. The `textured` type adds + metal gradient appearance (NSTexturedBackgroundWindowMask). The `desktop` + type places the window at the desktop background window level + (kCGDesktopWindowLevel - 1). Note that desktop window will not receive focus, + keyboard or mouse events, but you can use `globalShortcut` to receive input + sparingly. * `titleBarStyle` String, OS X - specifies the style of window title bar. This option is supported on OS X 10.10 Yosemite and newer. There are three possible values: From 784d2633a9e36c19f301c489f7257f66a65ad3cb Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 20 Nov 2015 10:33:57 +0800 Subject: [PATCH 10/23] Make child_process.execFileSync support asar --- atom/common/lib/asar.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/atom/common/lib/asar.coffee b/atom/common/lib/asar.coffee index e7f845bba928..f7eeceb3f314 100644 --- a/atom/common/lib/asar.coffee +++ b/atom/common/lib/asar.coffee @@ -355,3 +355,4 @@ exports.wrapFsWithAsar = (fs) -> overrideAPISync process, 'dlopen', 1 overrideAPISync require('module')._extensions, '.node', 1 overrideAPISync fs, 'openSync' + overrideAPISync child_process, 'execFileSync' From 8e2faba8f728267df4934cb89e43525999832fac Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 20 Nov 2015 13:06:42 +0800 Subject: [PATCH 11/23] Small style fix --- atom/browser/native_window_mac.mm | 12 +++++------- docs/api/browser-window.md | 8 ++++---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 5564f9116e4b..7959eb04f55b 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -259,14 +259,12 @@ bool ScopedDisableResize::disable_resize_ = false; return [children filteredArrayUsingPredicate:predicate]; } -- (BOOL)canBecomeMainWindow -{ - return !self.disableKeyOrMainWindow; +- (BOOL)canBecomeMainWindow { + return !self.disableKeyOrMainWindow; } -- (BOOL)canBecomeKeyWindow -{ - return !self.disableKeyOrMainWindow; +- (BOOL)canBecomeKeyWindow { + return !self.disableKeyOrMainWindow; } @end @@ -394,7 +392,7 @@ NativeWindowMac::NativeWindowMac( if (windowType == "desktop") { [window_ setLevel:kCGDesktopWindowLevel - 1]; - [window_ setDisableKeyOrMainWindow: YES]; + [window_ setDisableKeyOrMainWindow:YES]; [window_ setCollectionBehavior: (NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorStationary | diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 46b7c96ae594..52b1bb8d5c5e 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -71,11 +71,11 @@ It creates a new `BrowserWindow` with native properties as set by the `options`. * On Linux, possible types are `desktop`, `dock`, `toolbar`, `splash`, `notification`. * On OS X, possible types are `desktop`, `textured`. The `textured` type adds - metal gradient appearance (NSTexturedBackgroundWindowMask). The `desktop` + metal gradient appearance (`NSTexturedBackgroundWindowMask`). The `desktop` type places the window at the desktop background window level - (kCGDesktopWindowLevel - 1). Note that desktop window will not receive focus, - keyboard or mouse events, but you can use `globalShortcut` to receive input - sparingly. + (`kCGDesktopWindowLevel - 1`). Note that desktop window will not receive + focus, keyboard or mouse events, but you can use `globalShortcut` to receive + input sparingly. * `titleBarStyle` String, OS X - specifies the style of window title bar. This option is supported on OS X 10.10 Yosemite and newer. There are three possible values: From 153c751fd70a982c432ef721b365e7452d69908a Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 20 Nov 2015 13:32:54 +0800 Subject: [PATCH 12/23] Update brightray for #3493 --- vendor/brightray | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/brightray b/vendor/brightray index 57472ef51d5b..d4fab33427eb 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 57472ef51d5bd70c65c5e304ba4626395b5d92aa +Subproject commit d4fab33427eb728a553896527f1931887ce6d9d9 From 29052b04986daf55ecda4163bb94adaf522d1a10 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 20 Nov 2015 13:36:59 +0800 Subject: [PATCH 13/23] Bump v0.35.1 --- atom.gyp | 2 +- atom/browser/resources/mac/Info.plist | 4 ++-- atom/browser/resources/win/atom.rc | 8 ++++---- atom/common/atom_version.h | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/atom.gyp b/atom.gyp index 2e8db6e59d10..9d667410523e 100644 --- a/atom.gyp +++ b/atom.gyp @@ -4,7 +4,7 @@ 'product_name%': 'Electron', 'company_name%': 'GitHub, Inc', 'company_abbr%': 'github', - 'version%': '0.35.0', + 'version%': '0.35.1', }, 'includes': [ 'filenames.gypi', diff --git a/atom/browser/resources/mac/Info.plist b/atom/browser/resources/mac/Info.plist index 33f66581cbc9..481945b8e893 100644 --- a/atom/browser/resources/mac/Info.plist +++ b/atom/browser/resources/mac/Info.plist @@ -17,9 +17,9 @@ CFBundleIconFile atom.icns CFBundleVersion - 0.35.0 + 0.35.1 CFBundleShortVersionString - 0.35.0 + 0.35.1 LSApplicationCategoryType public.app-category.developer-tools LSMinimumSystemVersion diff --git a/atom/browser/resources/win/atom.rc b/atom/browser/resources/win/atom.rc index 84f5522231ed..875727cdaff8 100644 --- a/atom/browser/resources/win/atom.rc +++ b/atom/browser/resources/win/atom.rc @@ -56,8 +56,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,35,0,0 - PRODUCTVERSION 0,35,0,0 + FILEVERSION 0,35,1,0 + PRODUCTVERSION 0,35,1,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -74,12 +74,12 @@ BEGIN BEGIN VALUE "CompanyName", "GitHub, Inc." VALUE "FileDescription", "Electron" - VALUE "FileVersion", "0.35.0" + VALUE "FileVersion", "0.35.1" VALUE "InternalName", "electron.exe" VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved." VALUE "OriginalFilename", "electron.exe" VALUE "ProductName", "Electron" - VALUE "ProductVersion", "0.35.0" + VALUE "ProductVersion", "0.35.1" VALUE "SquirrelAwareVersion", "1" END END diff --git a/atom/common/atom_version.h b/atom/common/atom_version.h index ec2c81951fe3..093da7b5c601 100644 --- a/atom/common/atom_version.h +++ b/atom/common/atom_version.h @@ -7,7 +7,7 @@ #define ATOM_MAJOR_VERSION 0 #define ATOM_MINOR_VERSION 35 -#define ATOM_PATCH_VERSION 0 +#define ATOM_PATCH_VERSION 1 #define ATOM_VERSION_IS_RELEASE 1 From 9341b9d6407447803731acf019976dc7b0859ea1 Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Sat, 21 Nov 2015 02:26:59 +0200 Subject: [PATCH 14/23] Make links to docs, point to the correct version - Links to docs in the default app, pointed to the docs in the master branch. I changed them to point to the docs that match Electron's version. - Added Electron's version to the header of the default app, so it will be easier to figure out what version is currently running. --- atom/browser/default_app/index.html | 20 +++++++++++++++++--- atom/browser/default_app/main.js | 12 ++++++++++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/atom/browser/default_app/index.html b/atom/browser/default_app/index.html index e55cdf77b7fd..ec16a38bc423 100644 --- a/atom/browser/default_app/index.html +++ b/atom/browser/default_app/index.html @@ -76,7 +76,11 @@ }; -

Welcome to Electron

+

+ +

To run your app with Electron, execute the following command under your @@ -87,8 +91,18 @@

The path-to-your-app should be the path to your own Electron - app, you can read the quick start - guide in Electron's docs + app, you can read the + + guide in Electron's + on how to write one.

diff --git a/atom/browser/default_app/main.js b/atom/browser/default_app/main.js index 3916cfb2884e..49016c05ad2e 100644 --- a/atom/browser/default_app/main.js +++ b/atom/browser/default_app/main.js @@ -148,7 +148,11 @@ app.once('ready', function() { }, { label: 'Documentation', - click: function() { shell.openExternal('https://github.com/atom/electron/tree/master/docs#readme') } + click: function() { + shell.openExternal( + `https://github.com/atom/electron/tree/v${process.versions.electron}/docs#readme` + ) + } }, { label: 'Community Discussions', @@ -249,7 +253,11 @@ if (option.file && !option.webdriver) { } catch(e) { if (e.code == 'MODULE_NOT_FOUND') { app.focus(); - dialog.showErrorBox('Error opening app', 'The app provided is not a valid electron app, please read the docs on how to write one:\nhttps://github.com/atom/electron/tree/master/docs\n\n' + e.toString()); + dialog.showErrorBox( + 'Error opening app', + 'The app provided is not a valid Electron app, please read the docs on how to write one:\n' + + `https://github.com/atom/electron/tree/v${process.versions.electron}/docs\n\n${e.toString()}` + ); process.exit(1); } else { console.error('App threw an error when running', e); From 4d4bb0a73e2fd01347dfe569d177e56572ed23da Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Sat, 21 Nov 2015 02:32:53 +0200 Subject: [PATCH 15/23] Added ctags cache files to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b8a221c9e52f..eb9aedb4e2f4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store +.tags* /.idea/ /build/ /dist/ From 5730d588d0debf86d25781d540c7e6c8aee5bb0d Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Sat, 21 Nov 2015 03:31:52 +0200 Subject: [PATCH 16/23] Add a note to readme about docs versioning Added a note to readme about using the correct docs version. Hopefully this will reduce users confusion. --- docs/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/README.md b/docs/README.md index 208ff8bf47b6..a1c8526e6ef5 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,3 +1,10 @@ +Please make sure that you use the documents that match your Electron version. +The version number should be a part of the URL. If it's not, you are probably +using the documentation of a development branch which may contain API changes +that are not compatible with your Electron version. +When in doubt, run Electron without supplying an app path, and click on the +`docs` link. + ## Guides * [Supported Platforms](tutorial/supported-platforms.md) From df8cc85d2c207e0e5f33de59e32079f4e9f5d7f1 Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Sat, 21 Nov 2015 04:22:16 +0200 Subject: [PATCH 17/23] Rephrased the note --- docs/README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/README.md b/docs/README.md index a1c8526e6ef5..9b6372524bd3 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,9 +1,11 @@ Please make sure that you use the documents that match your Electron version. -The version number should be a part of the URL. If it's not, you are probably -using the documentation of a development branch which may contain API changes -that are not compatible with your Electron version. -When in doubt, run Electron without supplying an app path, and click on the -`docs` link. +The version number should be a part of the page URL. If it's not, you are +probably using the documentation of a development branch which may contain API +changes that are not compatible with your Electron version. If that's the case, +you can switch to a different version of the documentation at the +[available versions](http://electron.atom.io/docs/) list on atom.io, or if +you're using the GitHub interface, open the "Switch branches/tags" dropdown and +select the tag that matches your version. ## Guides From 18de28c3ff4340e88bf01265604d7e78c84cef27 Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Sat, 21 Nov 2015 06:22:19 +0200 Subject: [PATCH 18/23] Make BrowserWindow options argument optional Resolves #3473 --- atom/browser/api/atom_api_window.cc | 14 ++++++++++++-- atom/browser/api/atom_api_window.h | 3 +-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index 7f5b78a79780..a5aa4a126687 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -261,13 +261,23 @@ void Window::OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) { #endif // static -mate::Wrappable* Window::New(v8::Isolate* isolate, - const mate::Dictionary& options) { +mate::Wrappable* Window::New(v8::Isolate* isolate, mate::Arguments* args) { if (!Browser::Get()->is_ready()) { isolate->ThrowException(v8::Exception::Error(mate::StringToV8( isolate, "Cannot create BrowserWindow before app is ready"))); return nullptr; } + + if (args->Length() > 1) { + args->ThrowError(); + return nullptr; + } + + mate::Dictionary options; + if (!(args->Length() == 1 && args->GetNext(&options))) { + options = mate::Dictionary::CreateEmpty(isolate); + } + return new Window(isolate, options); } diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index 4161584206a7..757abd205b31 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -38,8 +38,7 @@ class WebContents; class Window : public mate::TrackableObject, public NativeWindowObserver { public: - static mate::Wrappable* New(v8::Isolate* isolate, - const mate::Dictionary& options); + static mate::Wrappable* New(v8::Isolate* isolate, mate::Arguments* args); static void BuildPrototype(v8::Isolate* isolate, v8::Local prototype); From ab693ca571fce1682f43092f34e7bea157d79e92 Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Sat, 21 Nov 2015 06:42:40 +0200 Subject: [PATCH 19/23] Update docs --- docs/api/browser-window.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 52b1bb8d5c5e..f86f6e685655 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -25,17 +25,17 @@ You can also create a window without chrome by using It creates a new `BrowserWindow` with native properties as set by the `options`. -### `new BrowserWindow(options)` +### `new BrowserWindow([options])` -`options` Object, properties: +`options` Object (optional), properties: -* `width` Integer - Window's width. -* `height` Integer - Window's height. +* `width` Integer - Window's width. Default is 800 pixels. +* `height` Integer - Window's height. Default is 600 pixels. * `x` Integer - Window's left offset from screen. * `y` Integer - Window's top offset from screen. * `useContentSize` Boolean - The `width` and `height` would be used as web page's size, which means the actual window's size will include window - frame's size and be slightly larger. + frame's size and be slightly larger. Default is `false`. * `center` Boolean - Show window in the center of the screen. * `minWidth` Integer - Window's minimum width. * `minHeight` Integer - Window's minimum height. @@ -51,7 +51,8 @@ It creates a new `BrowserWindow` with native properties as set by the `options`. * `title` String - Default window title. * `icon` [NativeImage](native-image.md) - The window icon, when omitted on Windows the executable's icon would be used as window icon. -* `show` Boolean - Whether window should be shown when created. +* `show` Boolean - Whether window should be shown when created. Default is +`true`. * `frame` Boolean - Specify `false` to create a [Frameless Window](frameless-window.md). * `acceptFirstMouse` Boolean - Whether the web view accepts a single From 4027d04662542b94ed5196a6bb190539c516171f Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Sat, 21 Nov 2015 06:58:17 +0200 Subject: [PATCH 20/23] Add test --- spec/api-browser-window-spec.coffee | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/api-browser-window-spec.coffee b/spec/api-browser-window-spec.coffee index 00437ae412ba..8df4c9a9479e 100644 --- a/spec/api-browser-window-spec.coffee +++ b/spec/api-browser-window-spec.coffee @@ -322,3 +322,11 @@ describe 'browser-window module', -> done() w.loadURL "file://#{fixtures}/pages/save_page/index.html" + + describe 'BrowserWindow options argument is optional', -> + it 'should create a window with default size (800x600)', -> + w.destroy() + w = new BrowserWindow() + size = w.getSize() + assert.equal size[0], 800 + assert.equal size[1], 600 From 651254424d1427d21a7446e827d366f2820d2e92 Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Sat, 21 Nov 2015 21:50:23 +0200 Subject: [PATCH 21/23] Expand the descriptions of options with defaults Resolves #3367 --- docs/api/browser-window.md | 93 ++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 40 deletions(-) diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index f86f6e685655..15135d5eb464 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -29,46 +29,54 @@ It creates a new `BrowserWindow` with native properties as set by the `options`. `options` Object (optional), properties: -* `width` Integer - Window's width. Default is 800 pixels. -* `height` Integer - Window's height. Default is 600 pixels. -* `x` Integer - Window's left offset from screen. -* `y` Integer - Window's top offset from screen. +* `width` Integer - Window's width in pixels. Default is `800`. +* `height` Integer - Window's height in pixels. Default is `600`. +* `x` Integer - Window's left offset from screen. Default is to center the +window. +* `y` Integer - Window's top offset from screen. Default is to center the +window. * `useContentSize` Boolean - The `width` and `height` would be used as web page's size, which means the actual window's size will include window frame's size and be slightly larger. Default is `false`. * `center` Boolean - Show window in the center of the screen. -* `minWidth` Integer - Window's minimum width. -* `minHeight` Integer - Window's minimum height. -* `maxWidth` Integer - Window's maximum width. -* `maxHeight` Integer - Window's maximum height. -* `resizable` Boolean - Whether window is resizable. +* `minWidth` Integer - Window's minimum width. Default is `0`. +* `minHeight` Integer - Window's minimum height. Default is `0`. +* `maxWidth` Integer - Window's maximum width. Default is no limit. +* `maxHeight` Integer - Window's maximum height. Default is no limit. +* `resizable` Boolean - Whether window is resizable. Default is `true`. * `alwaysOnTop` Boolean - Whether the window should always stay on top of - other windows. + other windows. Default is `false`. * `fullscreen` Boolean - Whether the window should show in fullscreen. When set to `false` the fullscreen button will be hidden or disabled on OS X. -* `skipTaskbar` Boolean - Whether to show the window in taskbar. -* `kiosk` Boolean - The kiosk mode. -* `title` String - Default window title. + Default is `false`. +* `skipTaskbar` Boolean - Whether to show the window in taskbar. Default is +`false`. +* `kiosk` Boolean - The kiosk mode. Default is `false`. +* `title` String - Default window title. Default is `"Electron"`. * `icon` [NativeImage](native-image.md) - The window icon, when omitted on Windows the executable's icon would be used as window icon. * `show` Boolean - Whether window should be shown when created. Default is `true`. * `frame` Boolean - Specify `false` to create a -[Frameless Window](frameless-window.md). +[Frameless Window](frameless-window.md). Default is `true`. * `acceptFirstMouse` Boolean - Whether the web view accepts a single - mouse-down event that simultaneously activates the window. -* `disableAutoHideCursor` Boolean - Whether to hide cursor when typing. + mouse-down event that simultaneously activates the window. Default is `false`. +* `disableAutoHideCursor` Boolean - Whether to hide cursor when typing. Default +is `false`. * `autoHideMenuBar` Boolean - Auto hide the menu bar unless the `Alt` - key is pressed. + key is pressed. Default is `false`. * `enableLargerThanScreen` Boolean - Enable the window to be resized larger - than screen. + than screen. Default is `false`. * `backgroundColor` String - Window's background color as Hexadecimal value, like `#66CD00` or `#FFF`. This is only implemented on Linux and Windows. + Default is `#000` (black). * `darkTheme` Boolean - Forces using dark theme for the window, only works on - some GTK+3 desktop environments. + some GTK+3 desktop environments. Default is `false`. * `transparent` Boolean - Makes the window [transparent](frameless-window.md). +Default is `false`. * `type` String - Specifies the type of the window, which applies - additional platform-specific properties. + additional platform-specific properties. By default it's undefined and you'll + get a regular app window. Supported values: * On Linux, possible types are `desktop`, `dock`, `toolbar`, `splash`, `notification`. * On OS X, possible types are `desktop`, `textured`. The `textured` type adds @@ -80,7 +88,7 @@ It creates a new `BrowserWindow` with native properties as set by the `options`. * `titleBarStyle` String, OS X - specifies the style of window title bar. This option is supported on OS X 10.10 Yosemite and newer. There are three possible values: - * `default` or not specified results in the standard gray opaque Mac title + * `default` or not specified, results in the standard gray opaque Mac title bar. * `hidden` results in a hidden title bar and a full size content window, yet the title bar still has the standard window controls ("traffic lights") in @@ -105,33 +113,38 @@ It creates a new `BrowserWindow` with native properties as set by the `options`. `partition`, multiple pages can share the same session. If the `partition` is unset then default session of the app will be used. * `zoomFactor` Number - The default zoom factor of the page, `3.0` represents - `300%`. - * `javascript` Boolean + `300%`. Default is `1.0`. + * `javascript` Boolean - Enables JavaScript support. Default is `true`. * `webSecurity` Boolean - When setting `false`, it will disable the same-origin policy (Usually using testing websites by people), and set `allowDisplayingInsecureContent` and `allowRunningInsecureContent` to - `true` if these two options are not set by user. + `true` if these two options are not set by user. Default is `true`. * `allowDisplayingInsecureContent` Boolean - Allow an https page to display - content like images from http URLs. + content like images from http URLs. Default is `false`. * `allowRunningInsecureContent` Boolean - Allow a https page to run - JavaScript, CSS or plugins from http URLs. - * `images` Boolean - * `java` Boolean - * `textAreasAreResizable` Boolean - * `webgl` Boolean - * `webaudio` Boolean - * `plugins` Boolean - Whether plugins should be enabled. - * `experimentalFeatures` Boolean - * `experimentalCanvasFeatures` Boolean - * `overlayScrollbars` Boolean - * `overlayFullscreenVideo` Boolean - * `sharedWorker` Boolean - * `directWrite` Boolean - Whether the DirectWrite font rendering system on - Windows is enabled. + JavaScript, CSS or plugins from http URLs. Default is `false`. + * `images` Boolean - Enables image support. Default is `true`. + * `java` Boolean - Enables Java support. Default is `false`. + * `textAreasAreResizable` Boolean - Make TextArea elements resizable. Default + is `true`. + * `webgl` Boolean - Enables WebGL support. Default is `true`. + * `webaudio` Boolean - Enables WebAudio support. Default is `true`. + * `plugins` Boolean - Whether plugins should be enabled. Default is `false`. + * `experimentalFeatures` Boolean - Enables Chromium's experimental features. + Default is `false`. + * `experimentalCanvasFeatures` Boolean - Enables Chromium's experimental + canvas features. Default is `false`. + * `overlayScrollbars` Boolean - Enables overlay scrollbars. Default is + `false`. + * `overlayFullscreenVideo` Boolean - Enables overlay fullscreen video. Default + is `false` + * `sharedWorker` Boolean - Enables Shared Worker support. Default is `false`. + * `directWrite` Boolean - Enables DirectWrite font rendering system on + Windows. Default is `true`. * `pageVisibility` Boolean - Page would be forced to be always in visible or hidden state once set, instead of reflecting current window's visibility. Users can set it to `true` to prevent throttling of DOM - timers. + timers. Default is `false`. ## Events From 6db6842c14c3cd179c31581a42c51c7f71ae7f69 Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Sun, 22 Nov 2015 01:13:57 +0200 Subject: [PATCH 22/23] Fix menu-item using deprecated API Some of the roles in menu-item use methods on BrowserWindow instead of WebContents which outputs a deprecation warning. I changed it to use the correct methods. --- atom/browser/api/lib/menu-item.coffee | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/atom/browser/api/lib/menu-item.coffee b/atom/browser/api/lib/menu-item.coffee index 92e2283b417d..57beb6ffdae3 100644 --- a/atom/browser/api/lib/menu-item.coffee +++ b/atom/browser/api/lib/menu-item.coffee @@ -13,6 +13,11 @@ rolesMap = minimize: 'minimize' close: 'close' +# Maps methods that should be called directly on the BrowserWindow instance +methodInBrowserWindow = + minimize: true + close: true + class MenuItem @types = ['normal', 'separator', 'submenu', 'checkbox', 'radio'] @@ -42,8 +47,12 @@ class MenuItem # Manually flip the checked flags when clicked. @checked = !@checked if @type in ['checkbox', 'radio'] - if @role and rolesMap[@role] and process.platform isnt 'darwin' - focusedWindow?[rolesMap[@role]]() + if @role and rolesMap[@role] and process.platform isnt 'darwin' and focusedWindow? + methodName = rolesMap[@role] + if methodInBrowserWindow[methodName] + focusedWindow[methodName]() + else + focusedWindow.webContents?[methodName]() else if typeof click is 'function' click this, focusedWindow else if typeof @selector is 'string' From ba8b448c366b796869437bd65491026117eb18cb Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 23 Nov 2015 16:59:15 +0800 Subject: [PATCH 23/23] docs: Add indent for items in list Some markdown renderers require it to be able to render the list correctly. --- docs/api/browser-window.md | 25 ++++++++++++------------- docs/api/web-contents.md | 2 +- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 15135d5eb464..a987e2924615 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -32,9 +32,9 @@ It creates a new `BrowserWindow` with native properties as set by the `options`. * `width` Integer - Window's width in pixels. Default is `800`. * `height` Integer - Window's height in pixels. Default is `600`. * `x` Integer - Window's left offset from screen. Default is to center the -window. + window. * `y` Integer - Window's top offset from screen. Default is to center the -window. + window. * `useContentSize` Boolean - The `width` and `height` would be used as web page's size, which means the actual window's size will include window frame's size and be slightly larger. Default is `false`. @@ -50,19 +50,19 @@ window. set to `false` the fullscreen button will be hidden or disabled on OS X. Default is `false`. * `skipTaskbar` Boolean - Whether to show the window in taskbar. Default is -`false`. + `false`. * `kiosk` Boolean - The kiosk mode. Default is `false`. * `title` String - Default window title. Default is `"Electron"`. * `icon` [NativeImage](native-image.md) - The window icon, when omitted on Windows the executable's icon would be used as window icon. * `show` Boolean - Whether window should be shown when created. Default is -`true`. + `true`. * `frame` Boolean - Specify `false` to create a -[Frameless Window](frameless-window.md). Default is `true`. + [Frameless Window](frameless-window.md). Default is `true`. * `acceptFirstMouse` Boolean - Whether the web view accepts a single mouse-down event that simultaneously activates the window. Default is `false`. * `disableAutoHideCursor` Boolean - Whether to hide cursor when typing. Default -is `false`. + is `false`. * `autoHideMenuBar` Boolean - Auto hide the menu bar unless the `Alt` key is pressed. Default is `false`. * `enableLargerThanScreen` Boolean - Enable the window to be resized larger @@ -73,7 +73,7 @@ is `false`. * `darkTheme` Boolean - Forces using dark theme for the window, only works on some GTK+3 desktop environments. Default is `false`. * `transparent` Boolean - Makes the window [transparent](frameless-window.md). -Default is `false`. + Default is `false`. * `type` String - Specifies the type of the window, which applies additional platform-specific properties. By default it's undefined and you'll get a regular app window. Supported values: @@ -102,7 +102,6 @@ Default is `false`. scripts run in the page. This script will always have access to node APIs no matter whether node integration is turned on or off. The value should be the absolute file path to the script. - When node integration is turned off, the preload script can reintroduce Node global symbols back to the global scope. See example [here](process.md#event-loaded). @@ -126,18 +125,18 @@ Default is `false`. * `images` Boolean - Enables image support. Default is `true`. * `java` Boolean - Enables Java support. Default is `false`. * `textAreasAreResizable` Boolean - Make TextArea elements resizable. Default - is `true`. + is `true`. * `webgl` Boolean - Enables WebGL support. Default is `true`. * `webaudio` Boolean - Enables WebAudio support. Default is `true`. * `plugins` Boolean - Whether plugins should be enabled. Default is `false`. * `experimentalFeatures` Boolean - Enables Chromium's experimental features. - Default is `false`. + Default is `false`. * `experimentalCanvasFeatures` Boolean - Enables Chromium's experimental - canvas features. Default is `false`. + canvas features. Default is `false`. * `overlayScrollbars` Boolean - Enables overlay scrollbars. Default is - `false`. + `false`. * `overlayFullscreenVideo` Boolean - Enables overlay fullscreen video. Default - is `false` + is `false` * `sharedWorker` Boolean - Enables Shared Worker support. Default is `false`. * `directWrite` Boolean - Enables DirectWrite font rendering system on Windows. Default is `true`. diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index a716bdc593a7..2612d6212279 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -349,7 +349,7 @@ this limitation. ### `webContents.setAudioMuted(muted)` -+ `muted` Boolean +* `muted` Boolean Mute the audio on the current web page.