From 6cf6cb9a79e02a93efe09ba7738c1bffb1b48999 Mon Sep 17 00:00:00 2001 From: Plusb Preco Date: Sat, 19 Sep 2015 15:30:30 +0900 Subject: [PATCH 001/165] Update as upstream, change name the translation folder * Update as upstream * Change name the translation folder (ko to ko-KR) --- README-ko.md | 2 +- README.md | 2 +- docs-translations/{ko => ko-KR}/README.md | 0 docs-translations/{ko => ko-KR}/api/accelerator.md | 0 docs-translations/{ko => ko-KR}/api/auto-updater.md | 0 .../{ko => ko-KR}/api/chrome-command-line-switches.md | 0 docs-translations/{ko => ko-KR}/api/clipboard.md | 0 docs-translations/{ko => ko-KR}/api/content-tracing.md | 0 docs-translations/{ko => ko-KR}/api/crash-reporter.md | 0 docs-translations/{ko => ko-KR}/api/dialog.md | 0 docs-translations/{ko => ko-KR}/api/file-object.md | 0 docs-translations/{ko => ko-KR}/api/frameless-window.md | 0 docs-translations/{ko => ko-KR}/api/global-shortcut.md | 0 docs-translations/{ko => ko-KR}/api/ipc-main-process.md | 0 docs-translations/{ko => ko-KR}/api/ipc-renderer.md | 0 docs-translations/{ko => ko-KR}/api/menu-item.md | 0 docs-translations/{ko => ko-KR}/api/menu.md | 0 docs-translations/{ko => ko-KR}/api/native-image.md | 0 docs-translations/{ko => ko-KR}/api/power-monitor.md | 0 docs-translations/{ko => ko-KR}/api/power-save-blocker.md | 0 docs-translations/{ko => ko-KR}/api/process.md | 0 docs-translations/{ko => ko-KR}/api/protocol.md | 0 docs-translations/{ko => ko-KR}/api/remote.md | 2 +- docs-translations/{ko => ko-KR}/api/screen.md | 0 docs-translations/{ko => ko-KR}/api/session.md | 0 docs-translations/{ko => ko-KR}/api/shell.md | 0 docs-translations/{ko => ko-KR}/api/synopsis.md | 0 docs-translations/{ko => ko-KR}/api/tray.md | 0 docs-translations/{ko => ko-KR}/api/web-frame.md | 0 docs-translations/{ko => ko-KR}/api/web-view-tag.md | 8 ++++++++ docs-translations/{ko => ko-KR}/api/window-open.md | 0 .../development/atom-shell-vs-node-webkit.md | 0 .../{ko => ko-KR}/development/build-instructions-linux.md | 0 .../{ko => ko-KR}/development/build-instructions-osx.md | 0 .../development/build-instructions-windows.md | 0 .../{ko => ko-KR}/development/build-system-overview.md | 0 .../{ko => ko-KR}/development/coding-style.md | 0 .../{ko => ko-KR}/development/setting-up-symbol-server.md | 0 .../development/source-code-directory-structure.md | 0 docs-translations/{ko => ko-KR}/styleguide.md | 0 .../{ko => ko-KR}/tutorial/application-distribution.md | 0 .../{ko => ko-KR}/tutorial/application-packaging.md | 0 .../{ko => ko-KR}/tutorial/debugging-main-process.md | 0 .../tutorial/desktop-environment-integration.md | 0 .../{ko => ko-KR}/tutorial/devtools-extension.md | 0 .../{ko => ko-KR}/tutorial/online-offline-events.md | 0 docs-translations/{ko => ko-KR}/tutorial/quick-start.md | 0 .../{ko => ko-KR}/tutorial/using-native-node-modules.md | 0 .../{ko => ko-KR}/tutorial/using-pepper-flash-plugin.md | 0 .../tutorial/using-selenium-and-webdriver.md | 0 50 files changed, 11 insertions(+), 3 deletions(-) rename docs-translations/{ko => ko-KR}/README.md (100%) rename docs-translations/{ko => ko-KR}/api/accelerator.md (100%) rename docs-translations/{ko => ko-KR}/api/auto-updater.md (100%) rename docs-translations/{ko => ko-KR}/api/chrome-command-line-switches.md (100%) rename docs-translations/{ko => ko-KR}/api/clipboard.md (100%) rename docs-translations/{ko => ko-KR}/api/content-tracing.md (100%) rename docs-translations/{ko => ko-KR}/api/crash-reporter.md (100%) rename docs-translations/{ko => ko-KR}/api/dialog.md (100%) rename docs-translations/{ko => ko-KR}/api/file-object.md (100%) rename docs-translations/{ko => ko-KR}/api/frameless-window.md (100%) rename docs-translations/{ko => ko-KR}/api/global-shortcut.md (100%) rename docs-translations/{ko => ko-KR}/api/ipc-main-process.md (100%) rename docs-translations/{ko => ko-KR}/api/ipc-renderer.md (100%) rename docs-translations/{ko => ko-KR}/api/menu-item.md (100%) rename docs-translations/{ko => ko-KR}/api/menu.md (100%) rename docs-translations/{ko => ko-KR}/api/native-image.md (100%) rename docs-translations/{ko => ko-KR}/api/power-monitor.md (100%) rename docs-translations/{ko => ko-KR}/api/power-save-blocker.md (100%) rename docs-translations/{ko => ko-KR}/api/process.md (100%) rename docs-translations/{ko => ko-KR}/api/protocol.md (100%) rename docs-translations/{ko => ko-KR}/api/remote.md (99%) rename docs-translations/{ko => ko-KR}/api/screen.md (100%) rename docs-translations/{ko => ko-KR}/api/session.md (100%) rename docs-translations/{ko => ko-KR}/api/shell.md (100%) rename docs-translations/{ko => ko-KR}/api/synopsis.md (100%) rename docs-translations/{ko => ko-KR}/api/tray.md (100%) rename docs-translations/{ko => ko-KR}/api/web-frame.md (100%) rename docs-translations/{ko => ko-KR}/api/web-view-tag.md (98%) rename docs-translations/{ko => ko-KR}/api/window-open.md (100%) rename docs-translations/{ko => ko-KR}/development/atom-shell-vs-node-webkit.md (100%) rename docs-translations/{ko => ko-KR}/development/build-instructions-linux.md (100%) rename docs-translations/{ko => ko-KR}/development/build-instructions-osx.md (100%) rename docs-translations/{ko => ko-KR}/development/build-instructions-windows.md (100%) rename docs-translations/{ko => ko-KR}/development/build-system-overview.md (100%) rename docs-translations/{ko => ko-KR}/development/coding-style.md (100%) rename docs-translations/{ko => ko-KR}/development/setting-up-symbol-server.md (100%) rename docs-translations/{ko => ko-KR}/development/source-code-directory-structure.md (100%) rename docs-translations/{ko => ko-KR}/styleguide.md (100%) rename docs-translations/{ko => ko-KR}/tutorial/application-distribution.md (100%) rename docs-translations/{ko => ko-KR}/tutorial/application-packaging.md (100%) rename docs-translations/{ko => ko-KR}/tutorial/debugging-main-process.md (100%) rename docs-translations/{ko => ko-KR}/tutorial/desktop-environment-integration.md (100%) rename docs-translations/{ko => ko-KR}/tutorial/devtools-extension.md (100%) rename docs-translations/{ko => ko-KR}/tutorial/online-offline-events.md (100%) rename docs-translations/{ko => ko-KR}/tutorial/quick-start.md (100%) rename docs-translations/{ko => ko-KR}/tutorial/using-native-node-modules.md (100%) rename docs-translations/{ko => ko-KR}/tutorial/using-pepper-flash-plugin.md (100%) rename docs-translations/{ko => ko-KR}/tutorial/using-selenium-and-webdriver.md (100%) diff --git a/README-ko.md b/README-ko.md index 83634370eb..1481e7ce3d 100644 --- a/README-ko.md +++ b/README-ko.md @@ -41,7 +41,7 @@ Electron을 빌드 하는 방법과 프로젝트에 기여하는 방법도 문 ## 참조 문서 (번역) - [브라질 포르투칼어](https://github.com/atom/electron/tree/master/docs-translations/pt-BR) -- [한국어](https://github.com/atom/electron/tree/master/docs-translations/ko) +- [한국어](https://github.com/atom/electron/tree/master/docs-translations/ko-KR) - [일본어](https://github.com/atom/electron/tree/master/docs-translations/jp) - [스페인어](https://github.com/atom/electron/tree/master/docs-translations/es) - [중국어 간체](https://github.com/atom/electron/tree/master/docs-translations/zh-CN) diff --git a/README.md b/README.md index 54b6af5fa3..0bf29fbc3e 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ contains documents describing how to build and contribute to Electron. ## Documentation Translations - [Brazilian Portuguese](https://github.com/atom/electron/tree/master/docs-translations/pt-BR) -- [Korean](https://github.com/atom/electron/tree/master/docs-translations/ko) +- [Korean](https://github.com/atom/electron/tree/master/docs-translations/ko-KR) - [Japanese](https://github.com/atom/electron/tree/master/docs-translations/jp) - [Spanish](https://github.com/atom/electron/tree/master/docs-translations/es) - [Simplified Chinese](https://github.com/atom/electron/tree/master/docs-translations/zh-CN) diff --git a/docs-translations/ko/README.md b/docs-translations/ko-KR/README.md similarity index 100% rename from docs-translations/ko/README.md rename to docs-translations/ko-KR/README.md diff --git a/docs-translations/ko/api/accelerator.md b/docs-translations/ko-KR/api/accelerator.md similarity index 100% rename from docs-translations/ko/api/accelerator.md rename to docs-translations/ko-KR/api/accelerator.md diff --git a/docs-translations/ko/api/auto-updater.md b/docs-translations/ko-KR/api/auto-updater.md similarity index 100% rename from docs-translations/ko/api/auto-updater.md rename to docs-translations/ko-KR/api/auto-updater.md diff --git a/docs-translations/ko/api/chrome-command-line-switches.md b/docs-translations/ko-KR/api/chrome-command-line-switches.md similarity index 100% rename from docs-translations/ko/api/chrome-command-line-switches.md rename to docs-translations/ko-KR/api/chrome-command-line-switches.md diff --git a/docs-translations/ko/api/clipboard.md b/docs-translations/ko-KR/api/clipboard.md similarity index 100% rename from docs-translations/ko/api/clipboard.md rename to docs-translations/ko-KR/api/clipboard.md diff --git a/docs-translations/ko/api/content-tracing.md b/docs-translations/ko-KR/api/content-tracing.md similarity index 100% rename from docs-translations/ko/api/content-tracing.md rename to docs-translations/ko-KR/api/content-tracing.md diff --git a/docs-translations/ko/api/crash-reporter.md b/docs-translations/ko-KR/api/crash-reporter.md similarity index 100% rename from docs-translations/ko/api/crash-reporter.md rename to docs-translations/ko-KR/api/crash-reporter.md diff --git a/docs-translations/ko/api/dialog.md b/docs-translations/ko-KR/api/dialog.md similarity index 100% rename from docs-translations/ko/api/dialog.md rename to docs-translations/ko-KR/api/dialog.md diff --git a/docs-translations/ko/api/file-object.md b/docs-translations/ko-KR/api/file-object.md similarity index 100% rename from docs-translations/ko/api/file-object.md rename to docs-translations/ko-KR/api/file-object.md diff --git a/docs-translations/ko/api/frameless-window.md b/docs-translations/ko-KR/api/frameless-window.md similarity index 100% rename from docs-translations/ko/api/frameless-window.md rename to docs-translations/ko-KR/api/frameless-window.md diff --git a/docs-translations/ko/api/global-shortcut.md b/docs-translations/ko-KR/api/global-shortcut.md similarity index 100% rename from docs-translations/ko/api/global-shortcut.md rename to docs-translations/ko-KR/api/global-shortcut.md diff --git a/docs-translations/ko/api/ipc-main-process.md b/docs-translations/ko-KR/api/ipc-main-process.md similarity index 100% rename from docs-translations/ko/api/ipc-main-process.md rename to docs-translations/ko-KR/api/ipc-main-process.md diff --git a/docs-translations/ko/api/ipc-renderer.md b/docs-translations/ko-KR/api/ipc-renderer.md similarity index 100% rename from docs-translations/ko/api/ipc-renderer.md rename to docs-translations/ko-KR/api/ipc-renderer.md diff --git a/docs-translations/ko/api/menu-item.md b/docs-translations/ko-KR/api/menu-item.md similarity index 100% rename from docs-translations/ko/api/menu-item.md rename to docs-translations/ko-KR/api/menu-item.md diff --git a/docs-translations/ko/api/menu.md b/docs-translations/ko-KR/api/menu.md similarity index 100% rename from docs-translations/ko/api/menu.md rename to docs-translations/ko-KR/api/menu.md diff --git a/docs-translations/ko/api/native-image.md b/docs-translations/ko-KR/api/native-image.md similarity index 100% rename from docs-translations/ko/api/native-image.md rename to docs-translations/ko-KR/api/native-image.md diff --git a/docs-translations/ko/api/power-monitor.md b/docs-translations/ko-KR/api/power-monitor.md similarity index 100% rename from docs-translations/ko/api/power-monitor.md rename to docs-translations/ko-KR/api/power-monitor.md diff --git a/docs-translations/ko/api/power-save-blocker.md b/docs-translations/ko-KR/api/power-save-blocker.md similarity index 100% rename from docs-translations/ko/api/power-save-blocker.md rename to docs-translations/ko-KR/api/power-save-blocker.md diff --git a/docs-translations/ko/api/process.md b/docs-translations/ko-KR/api/process.md similarity index 100% rename from docs-translations/ko/api/process.md rename to docs-translations/ko-KR/api/process.md diff --git a/docs-translations/ko/api/protocol.md b/docs-translations/ko-KR/api/protocol.md similarity index 100% rename from docs-translations/ko/api/protocol.md rename to docs-translations/ko-KR/api/protocol.md diff --git a/docs-translations/ko/api/remote.md b/docs-translations/ko-KR/api/remote.md similarity index 99% rename from docs-translations/ko/api/remote.md rename to docs-translations/ko-KR/api/remote.md index 15c82ff0d2..756acd429a 100644 --- a/docs-translations/ko/api/remote.md +++ b/docs-translations/ko-KR/api/remote.md @@ -62,7 +62,7 @@ exports.withLocalCallback = function() { ```javascript // 랜더러 프로세스 -var mapNumbers = require("remote").require("mapNumbers"); +var mapNumbers = require("remote").require("./mapNumbers"); var withRendererCb = mapNumbers.withRendererCallback(function(x) { return x + 1; diff --git a/docs-translations/ko/api/screen.md b/docs-translations/ko-KR/api/screen.md similarity index 100% rename from docs-translations/ko/api/screen.md rename to docs-translations/ko-KR/api/screen.md diff --git a/docs-translations/ko/api/session.md b/docs-translations/ko-KR/api/session.md similarity index 100% rename from docs-translations/ko/api/session.md rename to docs-translations/ko-KR/api/session.md diff --git a/docs-translations/ko/api/shell.md b/docs-translations/ko-KR/api/shell.md similarity index 100% rename from docs-translations/ko/api/shell.md rename to docs-translations/ko-KR/api/shell.md diff --git a/docs-translations/ko/api/synopsis.md b/docs-translations/ko-KR/api/synopsis.md similarity index 100% rename from docs-translations/ko/api/synopsis.md rename to docs-translations/ko-KR/api/synopsis.md diff --git a/docs-translations/ko/api/tray.md b/docs-translations/ko-KR/api/tray.md similarity index 100% rename from docs-translations/ko/api/tray.md rename to docs-translations/ko-KR/api/tray.md diff --git a/docs-translations/ko/api/web-frame.md b/docs-translations/ko-KR/api/web-frame.md similarity index 100% rename from docs-translations/ko/api/web-frame.md rename to docs-translations/ko-KR/api/web-frame.md diff --git a/docs-translations/ko/api/web-view-tag.md b/docs-translations/ko-KR/api/web-view-tag.md similarity index 98% rename from docs-translations/ko/api/web-view-tag.md rename to docs-translations/ko-KR/api/web-view-tag.md index 90f5acb938..b3f05de7f3 100644 --- a/docs-translations/ko/api/web-view-tag.md +++ b/docs-translations/ko-KR/api/web-view-tag.md @@ -335,6 +335,14 @@ Webview 페이지를 PDF 형식으로 인쇄합니다. `webContents.printToPDF(o 예제는 [WebContents.send](web-contents.md#webcontentssendchannel-args)를 참고하세요. +### `.sendInputEvent(event)` + +* `event` Object + +페이지에 input `event`를 보냅니다. + +`event` 객체에 대해 자세한 내용을 알아보려면 [WebContents.sendInputEvent](web-contents.md##webcontentssendinputeventevent)를 참고하세요. + ## DOM 이벤트 `webview` 태그는 다음과 같은 DOM 이벤트를 가지고 있습니다: diff --git a/docs-translations/ko/api/window-open.md b/docs-translations/ko-KR/api/window-open.md similarity index 100% rename from docs-translations/ko/api/window-open.md rename to docs-translations/ko-KR/api/window-open.md diff --git a/docs-translations/ko/development/atom-shell-vs-node-webkit.md b/docs-translations/ko-KR/development/atom-shell-vs-node-webkit.md similarity index 100% rename from docs-translations/ko/development/atom-shell-vs-node-webkit.md rename to docs-translations/ko-KR/development/atom-shell-vs-node-webkit.md diff --git a/docs-translations/ko/development/build-instructions-linux.md b/docs-translations/ko-KR/development/build-instructions-linux.md similarity index 100% rename from docs-translations/ko/development/build-instructions-linux.md rename to docs-translations/ko-KR/development/build-instructions-linux.md diff --git a/docs-translations/ko/development/build-instructions-osx.md b/docs-translations/ko-KR/development/build-instructions-osx.md similarity index 100% rename from docs-translations/ko/development/build-instructions-osx.md rename to docs-translations/ko-KR/development/build-instructions-osx.md diff --git a/docs-translations/ko/development/build-instructions-windows.md b/docs-translations/ko-KR/development/build-instructions-windows.md similarity index 100% rename from docs-translations/ko/development/build-instructions-windows.md rename to docs-translations/ko-KR/development/build-instructions-windows.md diff --git a/docs-translations/ko/development/build-system-overview.md b/docs-translations/ko-KR/development/build-system-overview.md similarity index 100% rename from docs-translations/ko/development/build-system-overview.md rename to docs-translations/ko-KR/development/build-system-overview.md diff --git a/docs-translations/ko/development/coding-style.md b/docs-translations/ko-KR/development/coding-style.md similarity index 100% rename from docs-translations/ko/development/coding-style.md rename to docs-translations/ko-KR/development/coding-style.md diff --git a/docs-translations/ko/development/setting-up-symbol-server.md b/docs-translations/ko-KR/development/setting-up-symbol-server.md similarity index 100% rename from docs-translations/ko/development/setting-up-symbol-server.md rename to docs-translations/ko-KR/development/setting-up-symbol-server.md diff --git a/docs-translations/ko/development/source-code-directory-structure.md b/docs-translations/ko-KR/development/source-code-directory-structure.md similarity index 100% rename from docs-translations/ko/development/source-code-directory-structure.md rename to docs-translations/ko-KR/development/source-code-directory-structure.md diff --git a/docs-translations/ko/styleguide.md b/docs-translations/ko-KR/styleguide.md similarity index 100% rename from docs-translations/ko/styleguide.md rename to docs-translations/ko-KR/styleguide.md diff --git a/docs-translations/ko/tutorial/application-distribution.md b/docs-translations/ko-KR/tutorial/application-distribution.md similarity index 100% rename from docs-translations/ko/tutorial/application-distribution.md rename to docs-translations/ko-KR/tutorial/application-distribution.md diff --git a/docs-translations/ko/tutorial/application-packaging.md b/docs-translations/ko-KR/tutorial/application-packaging.md similarity index 100% rename from docs-translations/ko/tutorial/application-packaging.md rename to docs-translations/ko-KR/tutorial/application-packaging.md diff --git a/docs-translations/ko/tutorial/debugging-main-process.md b/docs-translations/ko-KR/tutorial/debugging-main-process.md similarity index 100% rename from docs-translations/ko/tutorial/debugging-main-process.md rename to docs-translations/ko-KR/tutorial/debugging-main-process.md diff --git a/docs-translations/ko/tutorial/desktop-environment-integration.md b/docs-translations/ko-KR/tutorial/desktop-environment-integration.md similarity index 100% rename from docs-translations/ko/tutorial/desktop-environment-integration.md rename to docs-translations/ko-KR/tutorial/desktop-environment-integration.md diff --git a/docs-translations/ko/tutorial/devtools-extension.md b/docs-translations/ko-KR/tutorial/devtools-extension.md similarity index 100% rename from docs-translations/ko/tutorial/devtools-extension.md rename to docs-translations/ko-KR/tutorial/devtools-extension.md diff --git a/docs-translations/ko/tutorial/online-offline-events.md b/docs-translations/ko-KR/tutorial/online-offline-events.md similarity index 100% rename from docs-translations/ko/tutorial/online-offline-events.md rename to docs-translations/ko-KR/tutorial/online-offline-events.md diff --git a/docs-translations/ko/tutorial/quick-start.md b/docs-translations/ko-KR/tutorial/quick-start.md similarity index 100% rename from docs-translations/ko/tutorial/quick-start.md rename to docs-translations/ko-KR/tutorial/quick-start.md diff --git a/docs-translations/ko/tutorial/using-native-node-modules.md b/docs-translations/ko-KR/tutorial/using-native-node-modules.md similarity index 100% rename from docs-translations/ko/tutorial/using-native-node-modules.md rename to docs-translations/ko-KR/tutorial/using-native-node-modules.md diff --git a/docs-translations/ko/tutorial/using-pepper-flash-plugin.md b/docs-translations/ko-KR/tutorial/using-pepper-flash-plugin.md similarity index 100% rename from docs-translations/ko/tutorial/using-pepper-flash-plugin.md rename to docs-translations/ko-KR/tutorial/using-pepper-flash-plugin.md diff --git a/docs-translations/ko/tutorial/using-selenium-and-webdriver.md b/docs-translations/ko-KR/tutorial/using-selenium-and-webdriver.md similarity index 100% rename from docs-translations/ko/tutorial/using-selenium-and-webdriver.md rename to docs-translations/ko-KR/tutorial/using-selenium-and-webdriver.md From c626ee6e92353c7c754ecce0d7e3b7c597de3908 Mon Sep 17 00:00:00 2001 From: Indrek Ardel Date: Sat, 19 Sep 2015 21:17:23 +0300 Subject: [PATCH 002/165] Fix a typo --- atom/common/lib/asar.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/common/lib/asar.coffee b/atom/common/lib/asar.coffee index 900a686d44..22d0e70b34 100644 --- a/atom/common/lib/asar.coffee +++ b/atom/common/lib/asar.coffee @@ -329,7 +329,7 @@ exports.wrapFsWithAsar = (fs) -> buffer = new Buffer(info.size) fd = archive.getFd() - retrun undefined unless fd >= 0 + return undefined unless fd >= 0 fs.readSync fd, buffer, 0, info.size, info.offset buffer.toString 'utf8' From 76b7cd0908d23a6a95b4d18d7782c9f46c0c0fec Mon Sep 17 00:00:00 2001 From: Robert Hencke Date: Sat, 19 Sep 2015 17:11:29 -0400 Subject: [PATCH 003/165] Fix small typo in debug message. --- atom/browser/web_contents_preferences.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/browser/web_contents_preferences.cc b/atom/browser/web_contents_preferences.cc index db55eddf7e..d34b67d785 100644 --- a/atom/browser/web_contents_preferences.cc +++ b/atom/browser/web_contents_preferences.cc @@ -94,7 +94,7 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches( if (base::FilePath(preload).IsAbsolute()) command_line->AppendSwitchNative(switches::kPreloadScript, preload); else - LOG(ERROR) << "preload script must have abosulute path."; + LOG(ERROR) << "preload script must have absolute path."; } else if (web_preferences.GetString(switches::kPreloadUrl, &preload)) { // Translate to file path if there is "preload-url" option. base::FilePath preload_path; From 87b9b0bc31a8b7aa1b69cfbb185188a78c8b67f9 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Sun, 20 Sep 2015 18:45:34 +0800 Subject: [PATCH 004/165] Implement session.setOpenDownloadDialog() API. --- atom/browser/api/atom_api_session.cc | 11 +++++++- atom/browser/api/atom_api_session.h | 2 ++ .../browser/atom_download_manager_delegate.cc | 25 +++++++++++++------ atom/browser/atom_download_manager_delegate.h | 2 ++ 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index f07ab8b780..062c7500ef 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -9,6 +9,7 @@ #include "atom/browser/api/atom_api_cookies.h" #include "atom/browser/atom_browser_context.h" +#include "atom/browser/atom_download_manager_delegate.h" #include "atom/browser/api/atom_api_web_contents.h" #include "atom/common/native_mate_converters/callback.h" #include "atom/common/native_mate_converters/gurl_converter.h" @@ -245,7 +246,7 @@ Session::~Session() { } void Session::OnDownloadCreated(content::DownloadManager* manager, - content::DownloadItem* item) { + content::DownloadItem* item) { auto web_contents = item->GetWebContents(); bool prevent_default = Emit("will-download", item, api::WebContents::CreateFrom(isolate(), @@ -305,6 +306,13 @@ void Session::SetDownloadPath(const base::FilePath& path) { prefs::kDownloadDefaultDirectory, path); } +void Session::SetOpenDownloadDialog(bool open_download_dialog) { + AtomDownloadManagerDelegate* delegate = + static_cast( + browser_context()->GetDownloadManagerDelegate()); + delegate->SetOpenDownloadDialog(open_download_dialog); +} + v8::Local Session::Cookies(v8::Isolate* isolate) { if (cookies_.IsEmpty()) { auto handle = atom::api::Cookies::Create(isolate, browser_context()); @@ -321,6 +329,7 @@ mate::ObjectTemplateBuilder Session::GetObjectTemplateBuilder( .SetMethod("clearStorageData", &Session::ClearStorageData) .SetMethod("setProxy", &Session::SetProxy) .SetMethod("setDownloadPath", &Session::SetDownloadPath) + .SetMethod("setOpenDownloadDialog", &Session::SetOpenDownloadDialog) .SetProperty("cookies", &Session::Cookies); } diff --git a/atom/browser/api/atom_api_session.h b/atom/browser/api/atom_api_session.h index 14406e57af..2c53cfdac5 100644 --- a/atom/browser/api/atom_api_session.h +++ b/atom/browser/api/atom_api_session.h @@ -43,6 +43,8 @@ class Session: public mate::TrackableObject, AtomBrowserContext* browser_context() const { return browser_context_.get(); } + void SetOpenDownloadDialog(bool open_download_dialog); + protected: explicit Session(AtomBrowserContext* browser_context); ~Session(); diff --git a/atom/browser/atom_download_manager_delegate.cc b/atom/browser/atom_download_manager_delegate.cc index b573a39633..7cc2c17145 100644 --- a/atom/browser/atom_download_manager_delegate.cc +++ b/atom/browser/atom_download_manager_delegate.cc @@ -23,7 +23,8 @@ namespace atom { AtomDownloadManagerDelegate::AtomDownloadManagerDelegate( content::DownloadManager* manager) : download_manager_(manager), - weak_ptr_factory_(this) {} + weak_ptr_factory_(this), + open_download_dialog_(true) {} AtomDownloadManagerDelegate::~AtomDownloadManagerDelegate() { if (download_manager_) { @@ -74,22 +75,30 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated( window = relay->window.get(); file_dialog::Filters filters; - base::FilePath path; - if (!file_dialog::ShowSaveDialog(window, item->GetURL().spec(), default_path, + base::FilePath path = default_path; + if (open_download_dialog_ && + !file_dialog::ShowSaveDialog(window, item->GetURL().spec(), default_path, filters, &path)) { return; } - // Remeber the last selected download directory. - AtomBrowserContext* browser_context = static_cast( - download_manager_->GetBrowserContext()); - browser_context->prefs()->SetFilePath(prefs::kDownloadDefaultDirectory, - path.DirName()); + if (open_download_dialog_) { + // Remeber the last selected download directory. + AtomBrowserContext* browser_context = static_cast( + download_manager_->GetBrowserContext()); + browser_context->prefs()->SetFilePath(prefs::kDownloadDefaultDirectory, + path.DirName()); + } callback.Run(path, content::DownloadItem::TARGET_DISPOSITION_PROMPT, content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, path); } +void AtomDownloadManagerDelegate::SetOpenDownloadDialog( + bool open_download_dialog) { + open_download_dialog_ = open_download_dialog; +} + void AtomDownloadManagerDelegate::Shutdown() { weak_ptr_factory_.InvalidateWeakPtrs(); download_manager_ = nullptr; diff --git a/atom/browser/atom_download_manager_delegate.h b/atom/browser/atom_download_manager_delegate.h index 2df3a7d45a..d518e16bcb 100644 --- a/atom/browser/atom_download_manager_delegate.h +++ b/atom/browser/atom_download_manager_delegate.h @@ -34,6 +34,7 @@ class AtomDownloadManagerDelegate : public content::DownloadManagerDelegate { void OnDownloadPathGenerated(uint32 download_id, const content::DownloadTargetCallback& callback, const base::FilePath& default_path); + void SetOpenDownloadDialog(bool open_download_dialog); // content::DownloadManagerDelegate: void Shutdown() override; @@ -48,6 +49,7 @@ class AtomDownloadManagerDelegate : public content::DownloadManagerDelegate { private: content::DownloadManager* download_manager_; base::WeakPtrFactory weak_ptr_factory_; + bool open_download_dialog_; DISALLOW_COPY_AND_ASSIGN(AtomDownloadManagerDelegate); }; From 5ec74451ef32e91bcb9fabd6df4b35faa8581091 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Sun, 20 Sep 2015 18:56:10 +0800 Subject: [PATCH 005/165] Introduce DownloadItem for supporting more downloading features. --- atom/browser/api/atom_api_download_item.cc | 131 +++++++++++++++++++++ atom/browser/api/atom_api_download_item.h | 59 ++++++++++ atom/browser/api/atom_api_session.cc | 21 +--- atom/browser/api/lib/app.coffee | 8 ++ atom/common/node_bindings.cc | 1 + filenames.gypi | 2 + 6 files changed, 206 insertions(+), 16 deletions(-) create mode 100644 atom/browser/api/atom_api_download_item.cc create mode 100644 atom/browser/api/atom_api_download_item.h diff --git a/atom/browser/api/atom_api_download_item.cc b/atom/browser/api/atom_api_download_item.cc new file mode 100644 index 0000000000..aa1e719f48 --- /dev/null +++ b/atom/browser/api/atom_api_download_item.cc @@ -0,0 +1,131 @@ +// Copyright (c) 2015 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#include "atom/browser/api/atom_api_download_item.h" + +#include "atom/common/native_mate_converters/callback.h" +#include "atom/common/native_mate_converters/gurl_converter.h" +#include "atom/common/node_includes.h" +#include "native_mate/dictionary.h" + +namespace atom { + +namespace api { + +namespace { +// The wrapDownloadItem funtion which is implemented in JavaScript +using WrapDownloadItemCallback = base::Callback)>; +WrapDownloadItemCallback g_wrap_download_item; +} // namespace + +DownloadItem::DownloadItem(content::DownloadItem* download_item) : + download_item_(download_item) { + download_item_->AddObserver(this); +} + +DownloadItem::~DownloadItem() { + download_item_->RemoveObserver(this); +} + +void DownloadItem::OnDownloadUpdated(content::DownloadItem* item) { + if (download_item_ == item) + download_item_->IsDone() ? Emit("completed") : Emit("updated"); +} + +void DownloadItem::OnDownloadDestroyed(content::DownloadItem* download) { + if (download_item_ == download) { + download_item_->RemoveObserver(this); + } +} + +bool DownloadItem::IsDestroyed() const { + return download_item_ == nullptr; +}; + +void DownloadItem::Destroy() { + download_item_ = nullptr; +}; + +int64 DownloadItem::GetReceivedBytes() { + return download_item_->GetReceivedBytes(); +} + +int64 DownloadItem::GetTotalBytes() { + return download_item_->GetTotalBytes(); +} + +const GURL& DownloadItem::GetURL() { + return download_item_->GetURL(); +} + +std::string DownloadItem::GetMimeType() { + return download_item_->GetMimeType(); +} + +bool DownloadItem::HasUserGesture() { + return download_item_->HasUserGesture(); +} + +std::string DownloadItem::GetSuggestedFilename() { + return download_item_->GetSuggestedFilename(); +} + +void DownloadItem::Pause() { + download_item_->Pause(); +} + +void DownloadItem::Resume() { + download_item_->Resume(); +} + +void DownloadItem::Cancel() { + download_item_->Cancel(true); +} + +mate::ObjectTemplateBuilder DownloadItem::GetObjectTemplateBuilder( + v8::Isolate* isolate) { + return mate::ObjectTemplateBuilder(isolate) + .SetMethod("pause", &DownloadItem::Pause) + .SetMethod("resume", &DownloadItem::Resume) + .SetMethod("cancel", &DownloadItem::Cancel) + .SetMethod("getReceiveBytes", &DownloadItem::GetReceivedBytes) + .SetMethod("getTotalBytes", &DownloadItem::GetTotalBytes) + .SetMethod("getURL", &DownloadItem::GetURL) + .SetMethod("getMimeType", &DownloadItem::GetMimeType) + .SetMethod("hasUserGesture", &DownloadItem::HasUserGesture) + .SetMethod("getSuggestedFilename", &DownloadItem::GetSuggestedFilename); +} + +void SetWrapDownloadItem(const WrapDownloadItemCallback& callback) { + g_wrap_download_item = callback; +} + +void ClearWrapDownloadItem() { + g_wrap_download_item.Reset(); +} + +mate::Handle DownloadItem::Create( + v8::Isolate* isolate, content::DownloadItem* item) { + auto handle = mate::CreateHandle(isolate, new DownloadItem(item)); + g_wrap_download_item.Run(handle.ToV8()); + return handle; +} + +} // namespace api + +} // namespace atom + +namespace { + +void Initialize(v8::Local exports, v8::Local unused, + v8::Local context, void* priv) { + v8::Isolate* isolate = context->GetIsolate(); + mate::Dictionary dict(isolate, exports); + dict.SetMethod("_setWrapDownloadItem", &atom::api::SetWrapDownloadItem); + dict.SetMethod("_clearWrapDownloadItem", &atom::api::ClearWrapDownloadItem); +} + +} // namespace + +NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_download_item, Initialize); diff --git a/atom/browser/api/atom_api_download_item.h b/atom/browser/api/atom_api_download_item.h new file mode 100644 index 0000000000..31546c1c62 --- /dev/null +++ b/atom/browser/api/atom_api_download_item.h @@ -0,0 +1,59 @@ +// Copyright (c) 2015 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#ifndef ATOM_BROWSER_API_ATOM_API_DOWNLOAD_ITEM_H_ +#define ATOM_BROWSER_API_ATOM_API_DOWNLOAD_ITEM_H_ + +#include + +#include "atom/browser/api/trackable_object.h" +#include "content/public/browser/download_item.h" +#include "native_mate/handle.h" +#include "url/gurl.h" + +namespace atom { + +namespace api { + +class DownloadItem : public mate::TrackableObject, + public content::DownloadItem::Observer { + public: + DownloadItem(content::DownloadItem* download_item); + ~DownloadItem(); + static mate::Handle Create(v8::Isolate* isolate, + content::DownloadItem* item); + + // Override content::DownloadItem::Observer methods + void OnDownloadUpdated(content::DownloadItem* download) override; + void OnDownloadDestroyed(content::DownloadItem* download) override; + + void Pause(); + void Resume(); + void Cancel(); + int64 GetReceivedBytes(); + int64 GetTotalBytes(); + std::string GetMimeType(); + bool HasUserGesture(); + std::string GetSuggestedFilename(); + const GURL& GetURL(); + + private: + // mate::Wrappable: + mate::ObjectTemplateBuilder GetObjectTemplateBuilder( + v8::Isolate* isolate) override; + bool IsDestroyed() const override; + + // mate::TrackableObject: + void Destroy() override; + + content::DownloadItem* download_item_; + + DISALLOW_COPY_AND_ASSIGN(DownloadItem); +}; + +} // namespace api + +} // namespace atom + +#endif // ATOM_BROWSER_API_ATOM_API_DOWNLOAD_ITEM_H_ diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index 062c7500ef..27e52e112e 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -8,6 +8,7 @@ #include #include "atom/browser/api/atom_api_cookies.h" +#include "atom/browser/api/atom_api_download_item.h" #include "atom/browser/atom_browser_context.h" #include "atom/browser/atom_download_manager_delegate.h" #include "atom/browser/api/atom_api_web_contents.h" @@ -102,19 +103,6 @@ struct Converter { } }; -template<> -struct Converter { - static v8::Local ToV8(v8::Isolate* isolate, - content::DownloadItem* val) { - mate::Dictionary dict(isolate, v8::Object::New(isolate)); - dict.Set("url", val->GetURL()); - dict.Set("filename", val->GetSuggestedFilename()); - dict.Set("mimeType", val->GetMimeType()); - dict.Set("hasUserGesture", val->HasUserGesture()); - return dict.GetHandle(); - } -}; - } // namespace mate namespace atom { @@ -248,9 +236,10 @@ Session::~Session() { void Session::OnDownloadCreated(content::DownloadManager* manager, content::DownloadItem* item) { auto web_contents = item->GetWebContents(); - bool prevent_default = Emit("will-download", item, - api::WebContents::CreateFrom(isolate(), - web_contents)); + bool prevent_default = Emit( + "will-download", + DownloadItem::Create(isolate(), item), + api::WebContents::CreateFrom(isolate(), web_contents)); if (prevent_default) { item->Cancel(true); item->Remove(); diff --git a/atom/browser/api/lib/app.coffee b/atom/browser/api/lib/app.coffee index f5b137eb0b..39f6395560 100644 --- a/atom/browser/api/lib/app.coffee +++ b/atom/browser/api/lib/app.coffee @@ -2,6 +2,7 @@ EventEmitter = require('events').EventEmitter bindings = process.atomBinding 'app' sessionBindings = process.atomBinding 'session' +downloadItemBindings = process.atomBinding 'download_item' app = bindings.app app.__proto__ = EventEmitter.prototype @@ -10,6 +11,10 @@ wrapSession = (session) -> # session is an Event Emitter. session.__proto__ = EventEmitter.prototype +wrapDownloadItem = (download_item) -> + # download_item is an Event Emitter. + download_item.__proto__ = EventEmitter.prototype + app.setApplicationMenu = (menu) -> require('menu').setApplicationMenu menu @@ -51,5 +56,8 @@ app.on 'activate', (event, hasVisibleWindows) -> @emit 'activate-with-no-open-wi sessionBindings._setWrapSession wrapSession process.once 'exit', sessionBindings._clearWrapSession +downloadItemBindings._setWrapDownloadItem wrapDownloadItem +process.once 'exit', downloadItemBindings._clearWrapDownloadItem + # Only one App object pemitted. module.exports = app diff --git a/atom/common/node_bindings.cc b/atom/common/node_bindings.cc index 5aec200550..2da68854ad 100644 --- a/atom/common/node_bindings.cc +++ b/atom/common/node_bindings.cc @@ -34,6 +34,7 @@ REFERENCE_MODULE(atom_browser_app); REFERENCE_MODULE(atom_browser_auto_updater); REFERENCE_MODULE(atom_browser_content_tracing); REFERENCE_MODULE(atom_browser_dialog); +REFERENCE_MODULE(atom_browser_download_item); REFERENCE_MODULE(atom_browser_menu); REFERENCE_MODULE(atom_browser_power_monitor); REFERENCE_MODULE(atom_browser_power_save_blocker); diff --git a/filenames.gypi b/filenames.gypi index 461c812753..3f40436380 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -71,6 +71,8 @@ 'atom/browser/api/atom_api_content_tracing.cc', 'atom/browser/api/atom_api_cookies.cc', 'atom/browser/api/atom_api_cookies.h', + 'atom/browser/api/atom_api_download_item.cc', + 'atom/browser/api/atom_api_download_item.h', 'atom/browser/api/atom_api_dialog.cc', 'atom/browser/api/atom_api_global_shortcut.cc', 'atom/browser/api/atom_api_global_shortcut.h', From 40b861bc9cb5c4f8b9bdb23cef7f897881861c79 Mon Sep 17 00:00:00 2001 From: Alexander Salas Date: Sun, 20 Sep 2015 17:58:41 -0430 Subject: [PATCH 006/165] err undefined --- docs/api/web-contents.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index e8f72cd24b..3b7363fd56 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -415,7 +415,7 @@ win.webContents.on("did-finish-load", function() { win.webContents.printToPDF({}, function(error, data) { if (error) throw error; fs.writeFile("/tmp/print.pdf", data, function(error) { - if (err) + if (error) throw error; console.log("Write PDF successfully."); }) From dd3813170466b77a5168ba82b804eeaf6db60c1a Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Sun, 20 Sep 2015 19:08:31 +0800 Subject: [PATCH 007/165] :memo: Add DownloadItem doc. --- docs/api/download-item.md | 83 +++++++++++++++++++++++++++++++++++++++ docs/api/session.md | 15 ++++--- 2 files changed, 92 insertions(+), 6 deletions(-) create mode 100644 docs/api/download-item.md diff --git a/docs/api/download-item.md b/docs/api/download-item.md new file mode 100644 index 0000000000..eacff62946 --- /dev/null +++ b/docs/api/download-item.md @@ -0,0 +1,83 @@ +# DownloadItem + +`DownloadItem` is an EventEmitter represents a download item in Electron. It +is used in `will-download` event of `Session` module, and allows users to +control the download item. + +```javascript +// Disable showing the download saving dialog. +win.webContents.session.setOpenDownloadDialog(false); + +win.webContents.session.on('will-download', function(event, item, webContents) { + console.log("Download from " + item.getURL()); + console.log(item.getMimeType()); + console.log(item.getSuggestedFilename()); + console.log(item.getTotalBytes()); + item.on('updated', function() { + console.log('Recived bytes: ' + item.getReceiveBytes()); + }); + item.on('completed', function() { + if (item.getReceiveBytes() >= item.getTotalBytes()) { + console.log("Download successfully"); + } else { + console.log("Download is cancelled or interrupted that can't be resumed"); + } + }); +``` + + +## Events + +### Event: 'updated' + +Emits when the `downloadItem` gets updated. + +### Event: 'completed' + +Emits when the download is in a terminal state. This includes a completed +download, a cancelled download(via `downloadItem.cancel()`), and interrputed +download that can't be resumed. + +## Methods + +The `downloadItem` object has the following methods: + +### `downloadItem.pause()` + +Pauses the download. + +### `downloadItem.resume()` + +Resumes the download that has been paused. + +### `downloadItem.cancel()` + +Cancels the download operation. + +### `downloadItem.getURL()` + +Returns a `String` represents the origin url where the item is downloaded from. + +### `downloadItem.getMimeType()` + +Returns a `String` represents the mime type. + +### `downloadItem.hasUserGesture()` + +Returns a `Boolean` indicates whether the download has user gesture. + +### `downloadItem.getSuggestedFilename()` + +Returns a `String` represents the suggested file name of the download file. + +**Note:** The suggested file name is not always the same as the actual one saved +in local disk. If user changes the file name in a prompted download saving +dialog, the actual name of saved file will be different with the suggested one. + +### `downloadItem.getTotalBytes()` + +Returns a `Integer` represents the total size in bytes of the download item. + +### `downloadItem.getReceivedBytes()` + +Returns a `Integer` represents the received bytes of the download item. diff --git a/docs/api/session.md b/docs/api/session.md index 439cf8514e..2219cf3beb 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -18,11 +18,7 @@ var session = win.webContents.session ### Event: 'will-download' * `event` Event -* `item` Object - * `url` String - * `filename` String - * `mimeType` String - * `hasUserGesture` Boolean +* `item` [DownloadItem](download-item.md) * `webContents` [WebContents](web-contents.md) Fired when Electron is about to download `item` in `webContents`. @@ -32,7 +28,7 @@ Calling `event.preventDefault()` will cancel the download. ```javascript session.on('will-download', function(event, item, webContents) { event.preventDefault(); - require('request')(item.url, function(data) { + require('request')(item.getURL(), function(data) { require('fs').writeFileSync('/somewhere', data); }); }); @@ -195,3 +191,10 @@ proxy-uri = ["://"][":"] Sets download saving directory. By default, the download directory will be the `Downloads` under the respective app folder. + +### `session.setOpenDownloadDialog(openDownloadDialog)` + +* `openDownloadDialog` Boolean - Whether a download saving dialog will be + prompted when the download starts. + +By default, the download saving dialog is enable in Electron. From d0ee30101dbbf6f192966ce163e9fc2c05385e62 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Sun, 20 Sep 2015 19:28:33 +0800 Subject: [PATCH 008/165] Fix cpplint warnings. --- atom/browser/api/atom_api_download_item.cc | 4 ++-- atom/browser/api/atom_api_download_item.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/atom/browser/api/atom_api_download_item.cc b/atom/browser/api/atom_api_download_item.cc index aa1e719f48..2e3068a5d3 100644 --- a/atom/browser/api/atom_api_download_item.cc +++ b/atom/browser/api/atom_api_download_item.cc @@ -41,11 +41,11 @@ void DownloadItem::OnDownloadDestroyed(content::DownloadItem* download) { bool DownloadItem::IsDestroyed() const { return download_item_ == nullptr; -}; +} void DownloadItem::Destroy() { download_item_ = nullptr; -}; +} int64 DownloadItem::GetReceivedBytes() { return download_item_->GetReceivedBytes(); diff --git a/atom/browser/api/atom_api_download_item.h b/atom/browser/api/atom_api_download_item.h index 31546c1c62..ca87a14ae8 100644 --- a/atom/browser/api/atom_api_download_item.h +++ b/atom/browser/api/atom_api_download_item.h @@ -19,7 +19,7 @@ namespace api { class DownloadItem : public mate::TrackableObject, public content::DownloadItem::Observer { public: - DownloadItem(content::DownloadItem* download_item); + explicit DownloadItem(content::DownloadItem* download_item); ~DownloadItem(); static mate::Handle Create(v8::Isolate* isolate, content::DownloadItem* item); From 4391e81dfeae7a5aa9cc45cb53174fe0f8626c3d Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 21 Sep 2015 09:38:06 +0800 Subject: [PATCH 009/165] Keep compatibility with old APIs. --- atom/browser/api/lib/app.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/atom/browser/api/lib/app.coffee b/atom/browser/api/lib/app.coffee index 39f6395560..3bf85c5905 100644 --- a/atom/browser/api/lib/app.coffee +++ b/atom/browser/api/lib/app.coffee @@ -14,6 +14,11 @@ wrapSession = (session) -> wrapDownloadItem = (download_item) -> # download_item is an Event Emitter. download_item.__proto__ = EventEmitter.prototype + # Be compatible with old APIs. + download_item.url = download_item.getURL() + download_item.filename = download_item.getSuggestedFilename() + download_item.mimeType = download_item.getMimeType() + download_item.hasUserGesture = download_item.hasUserGesture() app.setApplicationMenu = (menu) -> require('menu').setApplicationMenu menu From 997ac91fe03b3ed2a3bd133bb27e6ce8151b4498 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 21 Sep 2015 09:38:38 +0800 Subject: [PATCH 010/165] Add `donwloadItem.getContentDisposition()` API. --- atom/browser/api/atom_api_download_item.cc | 7 ++++++- atom/browser/api/atom_api_download_item.h | 1 + docs/api/download-item.md | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/atom/browser/api/atom_api_download_item.cc b/atom/browser/api/atom_api_download_item.cc index 2e3068a5d3..b056695a20 100644 --- a/atom/browser/api/atom_api_download_item.cc +++ b/atom/browser/api/atom_api_download_item.cc @@ -71,6 +71,10 @@ std::string DownloadItem::GetSuggestedFilename() { return download_item_->GetSuggestedFilename(); } +std::string DownloadItem::GetContentDisposition() { + return download_item_->GetContentDisposition(); +} + void DownloadItem::Pause() { download_item_->Pause(); } @@ -94,7 +98,8 @@ mate::ObjectTemplateBuilder DownloadItem::GetObjectTemplateBuilder( .SetMethod("getURL", &DownloadItem::GetURL) .SetMethod("getMimeType", &DownloadItem::GetMimeType) .SetMethod("hasUserGesture", &DownloadItem::HasUserGesture) - .SetMethod("getSuggestedFilename", &DownloadItem::GetSuggestedFilename); + .SetMethod("getSuggestedFilename", &DownloadItem::GetSuggestedFilename) + .SetMethod("getContentDisposition", &DownloadItem::GetContentDisposition); } void SetWrapDownloadItem(const WrapDownloadItemCallback& callback) { diff --git a/atom/browser/api/atom_api_download_item.h b/atom/browser/api/atom_api_download_item.h index ca87a14ae8..e12064c825 100644 --- a/atom/browser/api/atom_api_download_item.h +++ b/atom/browser/api/atom_api_download_item.h @@ -36,6 +36,7 @@ class DownloadItem : public mate::TrackableObject, std::string GetMimeType(); bool HasUserGesture(); std::string GetSuggestedFilename(); + std::string GetContentDisposition(); const GURL& GetURL(); private: diff --git a/docs/api/download-item.md b/docs/api/download-item.md index eacff62946..afbc4aea36 100644 --- a/docs/api/download-item.md +++ b/docs/api/download-item.md @@ -81,3 +81,8 @@ Returns a `Integer` represents the total size in bytes of the download item. ### `downloadItem.getReceivedBytes()` Returns a `Integer` represents the received bytes of the download item. + +### `downloadItem.getContentDisposition()` + +Returns a `String` represents the Content-Disposition field from the response +header. From 717e0f9821a4a30c8a9b787228529ff2ce2b8a8d Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 21 Sep 2015 10:18:38 +0800 Subject: [PATCH 011/165] Add Chromium's licenses to the dist --- script/create-dist.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/script/create-dist.py b/script/create-dist.py index c978641df3..ca7e216428 100755 --- a/script/create-dist.py +++ b/script/create-dist.py @@ -126,6 +126,8 @@ def copy_chrome_binary(binary): def copy_license(): + shutil.copy2(os.path.join(CHROMIUM_DIR, '..', 'LICENSES.chromium.html'), + DIST_DIR) shutil.copy2(os.path.join(SOURCE_ROOT, 'LICENSE'), DIST_DIR) From be600fda553f7c3b6af75aba3428f56e5970a282 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 21 Sep 2015 11:24:05 +0800 Subject: [PATCH 012/165] spec: Prevent callback of beginFrameSubscription being called twice --- spec/api-browser-window-spec.coffee | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/api-browser-window-spec.coffee b/spec/api-browser-window-spec.coffee index bb4d782e7f..64e6271660 100644 --- a/spec/api-browser-window-spec.coffee +++ b/spec/api-browser-window-spec.coffee @@ -306,8 +306,11 @@ describe 'browser-window module', -> describe 'beginFrameSubscription method', -> it 'subscribes frame updates', (done) -> + called = false w.loadUrl "file://#{fixtures}/api/blank.html" w.webContents.beginFrameSubscription (data) -> + return if called + called = true assert.notEqual data.length, 0 w.webContents.endFrameSubscription() done() From 7807d878d2d38a9134c830da85a734e6bcaaf151 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 21 Sep 2015 11:37:17 +0800 Subject: [PATCH 013/165] spec: Add timeout for beginFrameSubscription --- spec/api-browser-window-spec.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/api-browser-window-spec.coffee b/spec/api-browser-window-spec.coffee index 64e6271660..8cfd73d615 100644 --- a/spec/api-browser-window-spec.coffee +++ b/spec/api-browser-window-spec.coffee @@ -305,6 +305,7 @@ describe 'browser-window module', -> w.loadUrl url describe 'beginFrameSubscription method', -> + @timeout 10000 it 'subscribes frame updates', (done) -> called = false w.loadUrl "file://#{fixtures}/api/blank.html" From a567d7a0b6ff50b273456341c5ef776b6953ec7b Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 21 Sep 2015 11:43:10 +0800 Subject: [PATCH 014/165] spec: Suppress beginFrameSubscription on CI --- spec/api-browser-window-spec.coffee | 7 +++---- spec/chromium-spec.coffee | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/spec/api-browser-window-spec.coffee b/spec/api-browser-window-spec.coffee index 8cfd73d615..b2bca533b4 100644 --- a/spec/api-browser-window-spec.coffee +++ b/spec/api-browser-window-spec.coffee @@ -305,13 +305,12 @@ describe 'browser-window module', -> w.loadUrl url describe 'beginFrameSubscription method', -> - @timeout 10000 + # It is not very reliable on Travis CI. + return if process.env.TRAVIS is 'true' + it 'subscribes frame updates', (done) -> - called = false w.loadUrl "file://#{fixtures}/api/blank.html" w.webContents.beginFrameSubscription (data) -> - return if called - called = true assert.notEqual data.length, 0 w.webContents.endFrameSubscription() done() diff --git a/spec/chromium-spec.coffee b/spec/chromium-spec.coffee index 2c42cd9a4c..bb5cc47d65 100644 --- a/spec/chromium-spec.coffee +++ b/spec/chromium-spec.coffee @@ -62,7 +62,7 @@ describe 'chromium feature', -> ipc.removeAllListeners 'opener' it 'is null for main window', (done) -> - ipc.on 'opener', (event, opener) -> + ipc.once 'opener', (event, opener) -> assert.equal opener, null done() BrowserWindow = remote.require 'browser-window' @@ -70,7 +70,7 @@ describe 'chromium feature', -> w.loadUrl url it 'is not null for window opened by window.open', (done) -> - ipc.on 'opener', (event, opener) -> + ipc.once 'opener', (event, opener) -> b.close() done(if opener isnt null then undefined else opener) b = window.open url, '', 'show=no' From 57bf0cb615ec27482154e9742cf6284d27c9262a Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 21 Sep 2015 13:45:42 +0800 Subject: [PATCH 015/165] Refractor in `completed` event in DownloadItem. * Rename `completed` to `done`, making it align with Chromium's style. * Add 'state' in `done` event's result. It can check the download item final status: cancelled, completed, interrupted. --- atom/browser/api/atom_api_download_item.cc | 32 ++++++++++++++++++++-- docs/api/download-item.md | 13 +++++++-- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/atom/browser/api/atom_api_download_item.cc b/atom/browser/api/atom_api_download_item.cc index b056695a20..6c6bb4dae9 100644 --- a/atom/browser/api/atom_api_download_item.cc +++ b/atom/browser/api/atom_api_download_item.cc @@ -9,6 +9,32 @@ #include "atom/common/node_includes.h" #include "native_mate/dictionary.h" +namespace mate { + +template<> +struct Converter { + static v8::Local ToV8(v8::Isolate* isolate, + content::DownloadItem::DownloadState state) { + std::string download_state; + switch (state) { + case content::DownloadItem::COMPLETE: + download_state = "completed"; + break; + case content::DownloadItem::CANCELLED: + download_state = "cancelled"; + break; + case content::DownloadItem::INTERRUPTED: + download_state = "interrputed"; + break; + default: + break; + } + return ConvertToV8(isolate, download_state); + } +}; + +} // namespace mate + namespace atom { namespace api { @@ -29,8 +55,10 @@ DownloadItem::~DownloadItem() { } void DownloadItem::OnDownloadUpdated(content::DownloadItem* item) { - if (download_item_ == item) - download_item_->IsDone() ? Emit("completed") : Emit("updated"); + if (download_item_ == item) { + download_item_->IsDone() ? + Emit("done", item->GetState()) : Emit("updated"); + } } void DownloadItem::OnDownloadDestroyed(content::DownloadItem* download) { diff --git a/docs/api/download-item.md b/docs/api/download-item.md index afbc4aea36..7b496dbc2b 100644 --- a/docs/api/download-item.md +++ b/docs/api/download-item.md @@ -16,8 +16,8 @@ win.webContents.session.on('will-download', function(event, item, webContents) { item.on('updated', function() { console.log('Recived bytes: ' + item.getReceiveBytes()); }); - item.on('completed', function() { - if (item.getReceiveBytes() >= item.getTotalBytes()) { + item.on('done', function(e, state) { + if (state == "completed") { console.log("Download successfully"); } else { console.log("Download is cancelled or interrupted that can't be resumed"); @@ -32,7 +32,13 @@ win.webContents.session.on('will-download', function(event, item, webContents) { Emits when the `downloadItem` gets updated. -### Event: 'completed' +### Event: 'done' + +* `event` Event +* `state` String + * `completed` - The download completed successfully. + * `cancelled` - The download has been cancelled. + * `interrupted` - An error broke the connection with the file server. Emits when the download is in a terminal state. This includes a completed download, a cancelled download(via `downloadItem.cancel()`), and interrputed @@ -77,6 +83,7 @@ dialog, the actual name of saved file will be different with the suggested one. ### `downloadItem.getTotalBytes()` Returns a `Integer` represents the total size in bytes of the download item. +If the size is unknown, it returns 0. ### `downloadItem.getReceivedBytes()` From 477103191ff4946f0b99039874cc56814ba1a372 Mon Sep 17 00:00:00 2001 From: Gohy Leandre Date: Fri, 18 Sep 2015 12:01:31 +0200 Subject: [PATCH 016/165] Add http_response_code, method, referrer, response_headers to did-get-redirect-request event. --- atom/browser/api/atom_api_web_contents.cc | 61 +++++++++++++---------- docs/api/web-contents.md | 4 ++ 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 9791a94bb7..79f359ae8d 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -120,6 +120,33 @@ struct Converter { } }; +template<> +struct Converter { + static v8::Local ToV8(v8::Isolate* isolate, + net::HttpResponseHeaders* headers) { + base::DictionaryValue response_headers; + if (headers) { + void* iter = nullptr; + std::string key; + std::string value; + while (headers->EnumerateHeaderLines(&iter, &key, &value)) { + key = base::StringToLowerASCII(key); + value = base::StringToLowerASCII(value); + if (response_headers.HasKey(key)) { + base::ListValue* values = nullptr; + if (response_headers.GetList(key, &values)) + values->AppendString(value); + } else { + scoped_ptr values(new base::ListValue()); + values->AppendString(value); + response_headers.Set(key, values.Pass()); + } + } + } + return ConvertToV8(isolate, response_headers); + } +}; + } // namespace mate @@ -131,7 +158,7 @@ namespace { v8::Persistent template_; -// The wrapWebContents funtion which is implemented in JavaScript +// The wrapWebContents function which is implemented in JavaScript using WrapWebContentsCallback = base::Callback)>; WrapWebContentsCallback g_wrap_web_contents; @@ -414,30 +441,6 @@ void WebContents::DidStopLoading() { void WebContents::DidGetResourceResponseStart( const content::ResourceRequestDetails& details) { - v8::Locker locker(isolate()); - v8::HandleScope handle_scope(isolate()); - base::DictionaryValue response_headers; - - net::HttpResponseHeaders* headers = details.headers.get(); - if (!headers) - return; - void* iter = nullptr; - std::string key; - std::string value; - while (headers->EnumerateHeaderLines(&iter, &key, &value)) { - key = base::StringToLowerASCII(key); - value = base::StringToLowerASCII(value); - if (response_headers.HasKey(key)) { - base::ListValue* values = nullptr; - if (response_headers.GetList(key, &values)) - values->AppendString(value); - } else { - scoped_ptr values(new base::ListValue()); - values->AppendString(value); - response_headers.Set(key, values.Pass()); - } - } - Emit("did-get-response-details", details.socket_address.IsEmpty(), details.url, @@ -445,7 +448,7 @@ void WebContents::DidGetResourceResponseStart( details.http_response_code, details.method, details.referrer, - response_headers); + details.headers.get()); } void WebContents::DidGetRedirectForResourceRequest( @@ -454,7 +457,11 @@ void WebContents::DidGetRedirectForResourceRequest( Emit("did-get-redirect-request", details.url, details.new_url, - (details.resource_type == content::RESOURCE_TYPE_MAIN_FRAME)); + (details.resource_type == content::RESOURCE_TYPE_MAIN_FRAME), + details.http_response_code, + details.method, + details.referrer, + details.headers.get()); } void WebContents::DidNavigateMainFrame( diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index e8f72cd24b..f971c569ee 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -78,6 +78,10 @@ Returns: * `oldUrl` String * `newUrl` String * `isMainFrame` Boolean +* `httpResponseCode` Integer +* `requestMethod` String +* `referrer` String +* `headers` Object Emitted when a redirect is received while requesting a resource. From 22168bc6d841ff4bfec73718ce058fdf09ef3289 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 21 Sep 2015 14:03:36 +0800 Subject: [PATCH 017/165] Allow emitting 'done' event when user cancel the download saving dialog. --- .../browser/atom_download_manager_delegate.cc | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/atom/browser/atom_download_manager_delegate.cc b/atom/browser/atom_download_manager_delegate.cc index 7cc2c17145..88daec2f46 100644 --- a/atom/browser/atom_download_manager_delegate.cc +++ b/atom/browser/atom_download_manager_delegate.cc @@ -75,20 +75,24 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated( window = relay->window.get(); file_dialog::Filters filters; - base::FilePath path = default_path; - if (open_download_dialog_ && - !file_dialog::ShowSaveDialog(window, item->GetURL().spec(), default_path, - filters, &path)) { - return; + base::FilePath path; + if (!open_download_dialog_) { + // Use default_path if download dialog is disabled. + path = default_path; + } else { + if (file_dialog::ShowSaveDialog(window, item->GetURL().spec(), default_path, + filters, &path)) { + // Remember the last selected download directory. + AtomBrowserContext* browser_context = static_cast( + download_manager_->GetBrowserContext()); + browser_context->prefs()->SetFilePath(prefs::kDownloadDefaultDirectory, + path.DirName()); + } } - if (open_download_dialog_) { - // Remeber the last selected download directory. - AtomBrowserContext* browser_context = static_cast( - download_manager_->GetBrowserContext()); - browser_context->prefs()->SetFilePath(prefs::kDownloadDefaultDirectory, - path.DirName()); - } + // Running the DownloadTargetCallback with an empty FilePath signals that the + // download should be cancelled. + // If user cancels the file save dialog, run the callback with empty FilePath. callback.Run(path, content::DownloadItem::TARGET_DISPOSITION_PROMPT, content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, path); From 5ef9c7e1a19fca478185538838c19663ad2cf8c0 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 21 Sep 2015 21:44:51 +0800 Subject: [PATCH 018/165] Add spec for download item. --- spec/api-session-spec.coffee | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/spec/api-session-spec.coffee b/spec/api-session-spec.coffee index 34a08ee50f..fe5765b45f 100644 --- a/spec/api-session-spec.coffee +++ b/spec/api-session-spec.coffee @@ -2,6 +2,7 @@ assert = require 'assert' remote = require 'remote' http = require 'http' path = require 'path' +fs = require 'fs' app = remote.require 'app' BrowserWindow = remote.require 'browser-window' @@ -72,3 +73,52 @@ describe 'session module', -> quotas: ['persistent'], w.webContents.session.clearStorageData options, -> w.webContents.send 'getcount' + + describe 'DownloadItem', -> + # A 5MB mock pdf. + mockPDF = new Buffer(1024*1024*5) + contentDisposition = 'inline; filename="mock.pdf"' + # TODO(hokein): Change the download directory to spec/fixtures directory. + # We have to use the # default download directory due to the broken + # session.setDownloadPath API is broken. Once the API is fixed, we can make + # this change. + defaultDownloadDir = path.join app.getPath('userData'), 'Downloads' + downloadFilePath = path.join defaultDownloadDir, "mock.pdf" + downloadServer = http.createServer (req, res) -> + res.writeHead 200, { + 'Content-Length': mockPDF.length, + 'Content-Type': 'application/pdf', + 'Content-Disposition': contentDisposition + } + res.end mockPDF + downloadServer.close() + + it 'can download successfully', (done) -> + downloadServer.listen 0, '127.0.0.1', -> + {port} = downloadServer.address() + w.loadUrl "#{url}:#{port}" + w.webContents.session.setOpenDownloadDialog false + + w.webContents.session.once 'will-download', (e, item, webContents) -> + item.on 'done', (e, state) -> + assert.equal state, "completed" + assert.equal item.getContentDisposition(), contentDisposition + assert.equal item.getReceiveBytes(), mockPDF.length + assert.equal item.getTotalBytes(), mockPDF.length + assert fs.existsSync downloadFilePath + fs.unlinkSync downloadFilePath + done() + assert.equal item.getURL(), "#{url}:#{port}/" + assert.equal item.getMimeType(), "application/pdf" + + it 'can cancel download', (done) -> + downloadServer.listen 0, '127.0.0.1', -> + {port} = downloadServer.address() + w.loadUrl "#{url}:#{port}/" + w.webContents.session.setOpenDownloadDialog false + w.webContents.session.once 'will-download', (e, item, webContents) -> + item.pause() + item.on 'done', (e, state) -> + assert.equal state, "cancelled" + done() + item.cancel() From 325feca864d910fda82e5b87f87785e2223e1964 Mon Sep 17 00:00:00 2001 From: Robo Date: Mon, 21 Sep 2015 22:59:59 +0530 Subject: [PATCH 019/165] webframe: api to register scheme as privileged --- atom/renderer/api/atom_api_web_frame.cc | 14 +++++++++++++- atom/renderer/api/atom_api_web_frame.h | 1 + docs/api/web-frame.md | 7 +++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/atom/renderer/api/atom_api_web_frame.cc b/atom/renderer/api/atom_api_web_frame.cc index 6e2054453a..4506658588 100644 --- a/atom/renderer/api/atom_api_web_frame.cc +++ b/atom/renderer/api/atom_api_web_frame.cc @@ -98,6 +98,16 @@ void WebFrame::RegisterURLSchemeAsBypassingCsp(const std::string& scheme) { blink::WebString::fromUTF8(scheme)); } +void WebFrame::RegisterURLSchemeAsPrivileged(const std::string& scheme) { + // Register scheme to privileged list (https, wss, data, chrome-extension) + blink::WebString privileged_scheme(blink::WebString::fromUTF8(scheme)); + blink::WebSecurityPolicy::registerURLSchemeAsSecure(privileged_scheme); + blink::WebSecurityPolicy::registerURLSchemeAsBypassingContentSecurityPolicy( + privileged_scheme); + blink::WebSecurityPolicy::registerURLSchemeAsAllowingServiceWorkers( + privileged_scheme); +} + mate::ObjectTemplateBuilder WebFrame::GetObjectTemplateBuilder( v8::Isolate* isolate) { return mate::ObjectTemplateBuilder(isolate) @@ -116,7 +126,9 @@ mate::ObjectTemplateBuilder WebFrame::GetObjectTemplateBuilder( .SetMethod("registerUrlSchemeAsSecure", &WebFrame::RegisterURLSchemeAsSecure) .SetMethod("registerUrlSchemeAsBypassingCsp", - &WebFrame::RegisterURLSchemeAsBypassingCsp); + &WebFrame::RegisterURLSchemeAsBypassingCsp) + .SetMethod("registerUrlSchemeAsPrivileged", + &WebFrame::RegisterURLSchemeAsPrivileged); } // static diff --git a/atom/renderer/api/atom_api_web_frame.h b/atom/renderer/api/atom_api_web_frame.h index f3895353b9..a3dec6cb76 100644 --- a/atom/renderer/api/atom_api_web_frame.h +++ b/atom/renderer/api/atom_api_web_frame.h @@ -58,6 +58,7 @@ class WebFrame : public mate::Wrappable { void RegisterURLSchemeAsSecure(const std::string& scheme); void RegisterURLSchemeAsBypassingCsp(const std::string& scheme); + void RegisterURLSchemeAsPrivileged(const std::string& scheme); // mate::Wrappable: virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder( diff --git a/docs/api/web-frame.md b/docs/api/web-frame.md index bdf42da300..33597543b7 100644 --- a/docs/api/web-frame.md +++ b/docs/api/web-frame.md @@ -83,4 +83,11 @@ attackers. Resources will be loaded from this `scheme` regardless of the current page's Content Security Policy. +### `webFrame.registerUrlSchemeAsPrivileged(scheme)` + +* `scheme` String + +Registers the `scheme` as secure, bypasses content security policy for resources and +allows registering ServiceWorker. + [spellchecker]: https://github.com/atom/node-spellchecker From eccb5e759074277bfa2670abafe5731f40bd38b5 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 22 Sep 2015 14:29:21 +0800 Subject: [PATCH 020/165] Don't make setImmediate a local variable It makes more troubles than benefits, and somehow it is slowing message loop down. --- atom/common/lib/init.coffee | 9 ++------- vendor/node | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/atom/common/lib/init.coffee b/atom/common/lib/init.coffee index 4bc3e36986..5db6b7dcbb 100644 --- a/atom/common/lib/init.coffee +++ b/atom/common/lib/init.coffee @@ -37,6 +37,8 @@ wrapWithActivateUvLoop = (func) -> process.activateUvLoop() func.apply this, arguments process.nextTick = wrapWithActivateUvLoop process.nextTick +global.setImmediate = wrapWithActivateUvLoop timers.setImmediate +global.clearImmediate = timers.clearImmediate if process.type is 'browser' # setTimeout needs to update the polling timeout of the event loop, when @@ -45,10 +47,3 @@ if process.type is 'browser' # recalculate the timeout in browser process. global.setTimeout = wrapWithActivateUvLoop timers.setTimeout global.setInterval = wrapWithActivateUvLoop timers.setInterval - global.setImmediate = wrapWithActivateUvLoop timers.setImmediate - global.clearImmediate = wrapWithActivateUvLoop timers.clearImmediate -else - # There are no setImmediate under renderer process by default, so we need to - # manually setup them here. - global.setImmediate = setImmediate - global.clearImmediate = clearImmediate diff --git a/vendor/node b/vendor/node index aa9c7a2316..fa54694af4 160000 --- a/vendor/node +++ b/vendor/node @@ -1 +1 @@ -Subproject commit aa9c7a2316ba7762f1d04d091585695be3e6be22 +Subproject commit fa54694af4350bf1720ff47e97a07c7c09325ee2 From 42515c6f41f85c9580de981b96236bfee165d15f Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 22 Sep 2015 14:30:54 +0800 Subject: [PATCH 021/165] No more need of manually setting process as local variable --- atom/common/lib/init.coffee | 9 ++++----- atom/renderer/api/lib/remote.coffee | 1 - atom/renderer/lib/init.coffee | 9 ++++----- atom/renderer/lib/override.coffee | 1 - 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/atom/common/lib/init.coffee b/atom/common/lib/init.coffee index 5db6b7dcbb..acb635edea 100644 --- a/atom/common/lib/init.coffee +++ b/atom/common/lib/init.coffee @@ -1,8 +1,7 @@ -process = global.process -fs = require 'fs' -path = require 'path' -timers = require 'timers' -Module = require 'module' +fs = require 'fs' +path = require 'path' +timers = require 'timers' +Module = require 'module' process.atomBinding = (name) -> try diff --git a/atom/renderer/api/lib/remote.coffee b/atom/renderer/api/lib/remote.coffee index abd86e7eee..00d22ab8cf 100644 --- a/atom/renderer/api/lib/remote.coffee +++ b/atom/renderer/api/lib/remote.coffee @@ -1,4 +1,3 @@ -process = global.process ipc = require 'ipc' v8Util = process.atomBinding 'v8_util' CallbacksRegistry = require 'callbacks-registry' diff --git a/atom/renderer/lib/init.coffee b/atom/renderer/lib/init.coffee index 9825f75be9..274c50ec5f 100644 --- a/atom/renderer/lib/init.coffee +++ b/atom/renderer/lib/init.coffee @@ -1,8 +1,7 @@ -process = global.process -events = require 'events' -path = require 'path' -url = require 'url' -Module = require 'module' +events = require 'events' +path = require 'path' +url = require 'url' +Module = require 'module' # We modified the original process.argv to let node.js load the # atom-renderer.js, we need to restore it here. diff --git a/atom/renderer/lib/override.coffee b/atom/renderer/lib/override.coffee index b60374e047..6e6164a8f2 100644 --- a/atom/renderer/lib/override.coffee +++ b/atom/renderer/lib/override.coffee @@ -1,4 +1,3 @@ -process = global.process ipc = require 'ipc' remote = require 'remote' From 4a9197203745e6462f8f01dc35690725842a01d4 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 22 Sep 2015 14:40:48 +0800 Subject: [PATCH 022/165] spec: Revert back to original behavior of setImmediate --- spec/webview-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/webview-spec.coffee b/spec/webview-spec.coffee index b310b7b129..961da0b9f1 100644 --- a/spec/webview-spec.coffee +++ b/spec/webview-spec.coffee @@ -86,7 +86,7 @@ describe ' tag', -> it 'preload script can still use "process" in required modules when nodeintegration is off', (done) -> webview.addEventListener 'console-message', (e) -> - assert.equal e.message, 'object function object' + assert.equal e.message, 'object undefined object' done() webview.setAttribute 'preload', "#{fixtures}/module/preload-node-off.js" webview.src = "file://#{fixtures}/api/blank.html" From 4cccce6bfe9a18820dc2c18f1be6bfbcecf1da00 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 22 Sep 2015 14:55:35 +0800 Subject: [PATCH 023/165] spec: Suppress beginFrameSubscription for now Since the callback is called asynchronously there is no way to prevent the callback from being called twice. --- spec/api-browser-window-spec.coffee | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/spec/api-browser-window-spec.coffee b/spec/api-browser-window-spec.coffee index b2bca533b4..de713a6545 100644 --- a/spec/api-browser-window-spec.coffee +++ b/spec/api-browser-window-spec.coffee @@ -304,10 +304,7 @@ describe 'browser-window module', -> done() w.loadUrl url - describe 'beginFrameSubscription method', -> - # It is not very reliable on Travis CI. - return if process.env.TRAVIS is 'true' - + xdescribe 'beginFrameSubscription method', -> it 'subscribes frame updates', (done) -> w.loadUrl "file://#{fixtures}/api/blank.html" w.webContents.beginFrameSubscription (data) -> From 619a397ec93332c00545747e6a57819a7b9942b1 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 22 Sep 2015 15:13:50 +0800 Subject: [PATCH 024/165] Bump v0.33.1 --- atom.gyp | 2 +- atom/browser/resources/mac/Info.plist | 2 +- atom/browser/resources/win/atom.rc | 8 ++++---- atom/common/atom_version.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/atom.gyp b/atom.gyp index c9d5f92478..3a46f242a2 100644 --- a/atom.gyp +++ b/atom.gyp @@ -4,7 +4,7 @@ 'product_name%': 'Electron', 'company_name%': 'GitHub, Inc', 'company_abbr%': 'github', - 'version%': '0.33.0', + 'version%': '0.33.1', }, 'includes': [ 'filenames.gypi', diff --git a/atom/browser/resources/mac/Info.plist b/atom/browser/resources/mac/Info.plist index 54ba3546a7..6260173b82 100644 --- a/atom/browser/resources/mac/Info.plist +++ b/atom/browser/resources/mac/Info.plist @@ -17,7 +17,7 @@ CFBundleIconFile atom.icns CFBundleVersion - 0.33.0 + 0.33.1 LSMinimumSystemVersion 10.8.0 NSMainNibFile diff --git a/atom/browser/resources/win/atom.rc b/atom/browser/resources/win/atom.rc index 8863d8be76..0583c2df3b 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,33,0,0 - PRODUCTVERSION 0,33,0,0 + FILEVERSION 0,33,1,0 + PRODUCTVERSION 0,33,1,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -74,12 +74,12 @@ BEGIN BEGIN VALUE "CompanyName", "GitHub, Inc." VALUE "FileDescription", "Electron" - VALUE "FileVersion", "0.33.0" + VALUE "FileVersion", "0.33.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.33.0" + VALUE "ProductVersion", "0.33.1" VALUE "SquirrelAwareVersion", "1" END END diff --git a/atom/common/atom_version.h b/atom/common/atom_version.h index deb0958543..5f9d0f3ca0 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 33 -#define ATOM_PATCH_VERSION 0 +#define ATOM_PATCH_VERSION 1 #define ATOM_VERSION_IS_RELEASE 1 From 7c65d05b02c15267b5aabeceac95f00afafef004 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 22 Sep 2015 19:59:32 +0800 Subject: [PATCH 025/165] Don't print error when window.open failed --- atom/renderer/lib/override.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/atom/renderer/lib/override.coffee b/atom/renderer/lib/override.coffee index 6e6164a8f2..5cffdd486d 100644 --- a/atom/renderer/lib/override.coffee +++ b/atom/renderer/lib/override.coffee @@ -70,7 +70,6 @@ window.open = (url, frameName='', features='') -> if guestId new BrowserWindowProxy(guestId) else - console.error 'It is not allowed to open new window from this WebContents' null # Use the dialog API to implement alert(). From f07fea1936671425ad683b364f89898e60c0231a Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 22 Sep 2015 20:11:05 +0800 Subject: [PATCH 026/165] Add allowpopups attribute for webview --- atom/browser/lib/guest-view-manager.coffee | 2 ++ atom/browser/lib/guest-window-manager.coffee | 2 +- atom/renderer/lib/web-view/web-view-attributes.coffee | 1 + atom/renderer/lib/web-view/web-view-constants.coffee | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/atom/browser/lib/guest-view-manager.coffee b/atom/browser/lib/guest-view-manager.coffee index 1c05b65b2d..455e969812 100644 --- a/atom/browser/lib/guest-view-manager.coffee +++ b/atom/browser/lib/guest-view-manager.coffee @@ -84,6 +84,8 @@ createGuest = (embedder, params) -> if params.allowtransparency? @setAllowTransparency params.allowtransparency + guest.allowPopups = params.allowpopups + # Dispatch events to embedder. for event in supportedWebViewEvents do (event) -> diff --git a/atom/browser/lib/guest-window-manager.coffee b/atom/browser/lib/guest-window-manager.coffee index 861b0d10aa..add366eca8 100644 --- a/atom/browser/lib/guest-window-manager.coffee +++ b/atom/browser/lib/guest-window-manager.coffee @@ -41,7 +41,7 @@ createGuest = (embedder, url, frameName, options) -> ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', (event, args...) -> [url, frameName, options] = args event.sender.emit 'new-window', event, url, frameName, 'new-window' - if event.sender.isGuest() or event.defaultPrevented + if (event.sender.isGuest() and not event.sender.allowPopups) or event.defaultPrevented event.returnValue = null else event.returnValue = createGuest event.sender, args... diff --git a/atom/renderer/lib/web-view/web-view-attributes.coffee b/atom/renderer/lib/web-view/web-view-attributes.coffee index acca826a9e..e980e6c96b 100644 --- a/atom/renderer/lib/web-view/web-view-attributes.coffee +++ b/atom/renderer/lib/web-view/web-view-attributes.coffee @@ -216,6 +216,7 @@ WebViewImpl::setupWebViewAttributes = -> @attributes[webViewConstants.ATTRIBUTE_NODEINTEGRATION] = new BooleanAttribute(webViewConstants.ATTRIBUTE_NODEINTEGRATION, this) @attributes[webViewConstants.ATTRIBUTE_PLUGINS] = new BooleanAttribute(webViewConstants.ATTRIBUTE_PLUGINS, this) @attributes[webViewConstants.ATTRIBUTE_DISABLEWEBSECURITY] = new BooleanAttribute(webViewConstants.ATTRIBUTE_DISABLEWEBSECURITY, this) + @attributes[webViewConstants.ATTRIBUTE_ALLOWPOPUPS] = new BooleanAttribute(webViewConstants.ATTRIBUTE_ALLOWPOPUPS, this) @attributes[webViewConstants.ATTRIBUTE_PRELOAD] = new PreloadAttribute(this) autosizeAttributes = [ diff --git a/atom/renderer/lib/web-view/web-view-constants.coffee b/atom/renderer/lib/web-view/web-view-constants.coffee index deb678e6a1..bfb9376fa7 100644 --- a/atom/renderer/lib/web-view/web-view-constants.coffee +++ b/atom/renderer/lib/web-view/web-view-constants.coffee @@ -13,6 +13,7 @@ module.exports = ATTRIBUTE_NODEINTEGRATION: 'nodeintegration' ATTRIBUTE_PLUGINS: 'plugins' ATTRIBUTE_DISABLEWEBSECURITY: 'disablewebsecurity' + ATTRIBUTE_ALLOWPOPUPS: 'allowpopups' ATTRIBUTE_PRELOAD: 'preload' ATTRIBUTE_USERAGENT: 'useragent' From 9cbdde2ebab977aae6b5ee465bfcabcfc07feb73 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 22 Sep 2015 20:13:49 +0800 Subject: [PATCH 027/165] docs: allowpopups attribute --- docs/api/web-view-tag.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/api/web-view-tag.md b/docs/api/web-view-tag.md index 8eb3857ac9..7b4aa2ebf8 100644 --- a/docs/api/web-view-tag.md +++ b/docs/api/web-view-tag.md @@ -149,6 +149,14 @@ This value can only be modified before the first navigation, since the session of an active renderer process cannot change. Subsequent attempts to modify the value will fail with a DOM exception. +### `allowpopups` + +```html + +``` + +If "on", the guest page will be allowed to open new windows. + ## Methods The `webview` tag has the following methods: @@ -496,7 +504,7 @@ Returns: * `url` String * `frameName` String * `disposition` String - Can be `default`, `foreground-tab`, `background-tab`, - `new-window` and `other` + `new-window` and `other`. Fired when the guest page attempts to open a new browser window. From f06f8ae73b66bbe068bef079896944751b7de856 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 22 Sep 2015 21:17:50 +0800 Subject: [PATCH 028/165] spec: Add test for allowpopups attribute --- spec/fixtures/pages/window-open-hide.html | 12 ++++++++++++ spec/webview-spec.coffee | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 spec/fixtures/pages/window-open-hide.html diff --git a/spec/fixtures/pages/window-open-hide.html b/spec/fixtures/pages/window-open-hide.html new file mode 100644 index 0000000000..d6eb7403ac --- /dev/null +++ b/spec/fixtures/pages/window-open-hide.html @@ -0,0 +1,12 @@ + + + + + + diff --git a/spec/webview-spec.coffee b/spec/webview-spec.coffee index 961da0b9f1..c60af8d74d 100644 --- a/spec/webview-spec.coffee +++ b/spec/webview-spec.coffee @@ -201,6 +201,26 @@ describe ' tag', -> webview.src = "file://#{fixtures}/pages/partition/one.html" document.body.appendChild webview + describe 'allowpopups attribute', -> + it 'can not open new window when not set', (done) -> + listener = (e) -> + assert.equal e.message, 'null' + webview.removeEventListener 'console-message', listener + done() + webview.addEventListener 'console-message', listener + webview.src = "file://#{fixtures}/pages/window-open-hide.html" + document.body.appendChild webview + + it 'can open new window when set', (done) -> + listener = (e) -> + assert.equal e.message, 'window' + webview.removeEventListener 'console-message', listener + done() + webview.addEventListener 'console-message', listener + webview.setAttribute 'allowpopups', 'on' + webview.src = "file://#{fixtures}/pages/window-open-hide.html" + document.body.appendChild webview + describe 'new-window event', -> it 'emits when window.open is called', (done) -> webview.addEventListener 'new-window', (e) -> From de418901968667355a87c45dfef74d74e87ccdcc Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 22 Sep 2015 21:56:56 +0800 Subject: [PATCH 029/165] Inherit parent window's options in window.open --- atom/browser/api/atom_api_web_contents.cc | 11 +++++++++-- atom/browser/api/atom_api_web_contents.h | 3 +++ atom/browser/api/atom_api_window.cc | 4 ++++ atom/browser/lib/guest-window-manager.coffee | 13 ++++++++++++- atom/browser/web_contents_preferences.cc | 3 +++ atom/browser/web_contents_preferences.h | 3 +++ 6 files changed, 34 insertions(+), 3 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 79f359ae8d..bdeb4ed4f8 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -228,7 +228,7 @@ WebContents::WebContents(v8::Isolate* isolate, AttachAsUserData(web_contents); InitWithWebContents(web_contents); - // Save the preferences. + // Save the preferences in C++. base::DictionaryValue web_preferences; mate::ConvertFromV8(isolate, options.GetHandle(), &web_preferences); new WebContentsPreferences(web_contents, &web_preferences); @@ -887,6 +887,12 @@ bool WebContents::IsGuest() const { return type_ == WEB_VIEW; } +v8::Local WebContents::GetWebPreferences(v8::Isolate* isolate) { + WebContentsPreferences* web_preferences = + WebContentsPreferences::FromWebContents(web_contents()); + return mate::ConvertToV8(isolate, *web_preferences->web_preferences()); +} + mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder( v8::Isolate* isolate) { if (template_.IsEmpty()) @@ -942,6 +948,7 @@ mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder( .SetMethod("setSize", &WebContents::SetSize) .SetMethod("setAllowTransparency", &WebContents::SetAllowTransparency) .SetMethod("isGuest", &WebContents::IsGuest) + .SetMethod("getWebPreferences", &WebContents::GetWebPreferences) .SetMethod("hasServiceWorker", &WebContents::HasServiceWorker) .SetMethod("unregisterServiceWorker", &WebContents::UnregisterServiceWorker) @@ -995,7 +1002,7 @@ mate::Handle WebContents::CreateFrom( // static mate::Handle WebContents::Create( v8::Isolate* isolate, const mate::Dictionary& options) { - auto handle = mate::CreateHandle(isolate, new WebContents(isolate, options)); + auto handle = mate::CreateHandle(isolate, new WebContents(isolate, options)); g_wrap_web_contents.Run(handle.ToV8()); return handle; } diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index c8ea6908bc..91750ac613 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -132,6 +132,9 @@ class WebContents : public mate::TrackableObject, void SetAllowTransparency(bool allow); bool IsGuest() const; + // Returns the web preferences of current WebContents. + v8::Local GetWebPreferences(v8::Isolate* isolate); + protected: explicit WebContents(content::WebContents* web_contents); WebContents(v8::Isolate* isolate, const mate::Dictionary& options); diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index 3a44115da2..4d866d1850 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -82,6 +82,10 @@ Window::Window(v8::Isolate* isolate, const mate::Dictionary& options) { web_contents_.Reset(isolate, web_contents.ToV8()); api_web_contents_ = web_contents.get(); + // Keep a copy of the options for later use. + mate::Dictionary(isolate, web_contents->GetWrapper(isolate)).Set( + "browserWindowOptions", options); + // Creates BrowserWindow. window_.reset(NativeWindow::Create(web_contents->managed_web_contents(), options)); diff --git a/atom/browser/lib/guest-window-manager.coffee b/atom/browser/lib/guest-window-manager.coffee index add366eca8..2dc5056a57 100644 --- a/atom/browser/lib/guest-window-manager.coffee +++ b/atom/browser/lib/guest-window-manager.coffee @@ -4,6 +4,17 @@ BrowserWindow = require 'browser-window' frameToGuest = {} +# Merge |options| with the |embedder|'s window's options. +mergeBrowserWindowOptions = (embedder, options) -> + if embedder.browserWindowOptions? + # Inherit the original options if it is a BrowserWindow. + options.__proto__ = embedder.browserWindowOptions + else + # Or only inherit web-preferences if it is a webview. + options['web-preferences'] ?= {} + options['web-preferences'].__proto__ = embedder.getWebPreferences() + options + # Create a new guest created by |embedder| with |options|. createGuest = (embedder, url, frameName, options) -> guest = frameToGuest[frameName] @@ -11,7 +22,7 @@ createGuest = (embedder, url, frameName, options) -> guest.loadUrl url return guest.id - guest = new BrowserWindow(options) + guest = new BrowserWindow(mergeBrowserWindowOptions(embedder, options)) guest.loadUrl url # Remember the embedder, will be used by window.opener methods. diff --git a/atom/browser/web_contents_preferences.cc b/atom/browser/web_contents_preferences.cc index d34b67d785..2856598c0b 100644 --- a/atom/browser/web_contents_preferences.cc +++ b/atom/browser/web_contents_preferences.cc @@ -40,6 +40,9 @@ WebContentsPreferences::WebContentsPreferences( base::DictionaryValue* web_preferences) { web_preferences_.Swap(web_preferences); web_contents->SetUserData(UserDataKey(), this); + + // The "isGuest" is not a preferences field. + web_preferences_.Remove("isGuest", nullptr); } WebContentsPreferences::~WebContentsPreferences() { diff --git a/atom/browser/web_contents_preferences.h b/atom/browser/web_contents_preferences.h index 83b485f449..3e36df0214 100644 --- a/atom/browser/web_contents_preferences.h +++ b/atom/browser/web_contents_preferences.h @@ -37,6 +37,9 @@ class WebContentsPreferences // $.extend(|web_preferences_|, |new_web_preferences|). void Merge(const base::DictionaryValue& new_web_preferences); + // Returns the web preferences. + base::DictionaryValue* web_preferences() { return &web_preferences_; } + private: friend class content::WebContentsUserData; From 4521db459b7fa8bdb4ffe3d4728cb615b337d59e Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 22 Sep 2015 22:36:46 +0800 Subject: [PATCH 030/165] spec: window.open should inherit options of parent window --- spec/chromium-spec.coffee | 10 ++++++++++ spec/fixtures/pages/window-open-size.html | 8 ++++++++ 2 files changed, 18 insertions(+) create mode 100644 spec/fixtures/pages/window-open-size.html diff --git a/spec/chromium-spec.coffee b/spec/chromium-spec.coffee index bb5cc47d65..2c2695aa5e 100644 --- a/spec/chromium-spec.coffee +++ b/spec/chromium-spec.coffee @@ -50,6 +50,16 @@ describe 'chromium feature', -> window.addEventListener 'message', listener b = window.open "file://#{fixtures}/pages/window-opener-node.html", '', 'node-integration=no,show=no' + it 'inherit options of parent window', (done) -> + listener = (event) -> + window.removeEventListener 'message', listener + b.close() + size = remote.getCurrentWindow().getSize() + assert.equal event.data, "size: #{size.width} #{size.height}" + done() + window.addEventListener 'message', listener + b = window.open "file://#{fixtures}/pages/window-open-size.html", '', 'show=no' + describe 'window.opener', -> @timeout 10000 diff --git a/spec/fixtures/pages/window-open-size.html b/spec/fixtures/pages/window-open-size.html new file mode 100644 index 0000000000..7b06cfddf5 --- /dev/null +++ b/spec/fixtures/pages/window-open-size.html @@ -0,0 +1,8 @@ + + + + + From e499bb14de05cf2de8c19c56a742da0096b6b36c Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 22 Sep 2015 22:46:44 +0800 Subject: [PATCH 031/165] docs: Mention window.open inherits options --- docs/api/window-open.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/api/window-open.md b/docs/api/window-open.md index c574d5d036..5d298e61e7 100644 --- a/docs/api/window-open.md +++ b/docs/api/window-open.md @@ -8,6 +8,10 @@ The proxy has limited standard functionality implemented to be compatible with traditional web pages. For full control of the new window you should create a `BrowserWindow` directly. +The newly created `BrowserWindow` will inherit parent window's options by +default, to override inherited options you can set them in the `features` +string. + ### `window.open(url[, frameName][, features])` * `url` String @@ -16,6 +20,9 @@ you should create a `BrowserWindow` directly. Creates a new window and returns an instance of `BrowserWindowProxy` class. +The `features` string follows the format of standard browser, but each feature +has to be a field of `BrowserWindow`'s options. + ### `window.opener.postMessage(message, targetOrigin)` * `message` String From 486f16fffa0956b95135044524a822034440d17e Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 22 Sep 2015 22:48:52 +0800 Subject: [PATCH 032/165] spec: Increase timeout for window.open specs --- spec/chromium-spec.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/chromium-spec.coffee b/spec/chromium-spec.coffee index 2c2695aa5e..4dd39aff5f 100644 --- a/spec/chromium-spec.coffee +++ b/spec/chromium-spec.coffee @@ -35,6 +35,8 @@ describe 'chromium feature', -> assert.notEqual navigator.language, '' describe 'window.open', -> + @timeout 10000 + it 'returns a BrowserWindowProxy object', -> b = window.open 'about:blank', '', 'show=no' assert.equal b.closed, false From f2fa0e96ebcfc4b9876662d53d82a8742c24aa9b Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 22 Sep 2015 23:39:31 +0800 Subject: [PATCH 033/165] Pass options in "new-window" event --- atom/browser/lib/guest-window-manager.coffee | 7 ++++--- atom/renderer/lib/web-view/guest-view-internal.coffee | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/atom/browser/lib/guest-window-manager.coffee b/atom/browser/lib/guest-window-manager.coffee index 2dc5056a57..9a5c0ca349 100644 --- a/atom/browser/lib/guest-window-manager.coffee +++ b/atom/browser/lib/guest-window-manager.coffee @@ -22,7 +22,7 @@ createGuest = (embedder, url, frameName, options) -> guest.loadUrl url return guest.id - guest = new BrowserWindow(mergeBrowserWindowOptions(embedder, options)) + guest = new BrowserWindow(options) guest.loadUrl url # Remember the embedder, will be used by window.opener methods. @@ -51,11 +51,12 @@ createGuest = (embedder, url, frameName, options) -> # Routed window.open messages. ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', (event, args...) -> [url, frameName, options] = args - event.sender.emit 'new-window', event, url, frameName, 'new-window' + options = mergeBrowserWindowOptions event.sender, options + event.sender.emit 'new-window', event, url, frameName, 'new-window', options if (event.sender.isGuest() and not event.sender.allowPopups) or event.defaultPrevented event.returnValue = null else - event.returnValue = createGuest event.sender, args... + event.returnValue = createGuest event.sender, url, frameName, options ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSE', (event, guestId) -> BrowserWindow.fromId(guestId)?.destroy() diff --git a/atom/renderer/lib/web-view/guest-view-internal.coffee b/atom/renderer/lib/web-view/guest-view-internal.coffee index b491184fb8..2852d11228 100644 --- a/atom/renderer/lib/web-view/guest-view-internal.coffee +++ b/atom/renderer/lib/web-view/guest-view-internal.coffee @@ -16,7 +16,7 @@ WEB_VIEW_EVENTS = 'did-get-redirect-request': ['oldUrl', 'newUrl', 'isMainFrame'] 'dom-ready': [] 'console-message': ['level', 'message', 'line', 'sourceId'] - 'new-window': ['url', 'frameName', 'disposition'] + 'new-window': ['url', 'frameName', 'disposition', 'options'] 'close': [] 'crashed': [] 'gpu-crashed': [] From 8bfa3cba63720da7a37e93c549a19ce452bc35c3 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 22 Sep 2015 23:41:08 +0800 Subject: [PATCH 034/165] docs: The options parameter of new-window event --- docs/api/web-contents.md | 2 ++ docs/api/web-view-tag.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index f971c569ee..e858d0211a 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -111,6 +111,8 @@ Returns: * `frameName` String * `disposition` String - Can be `default`, `foreground-tab`, `background-tab`, `new-window` and `other`. +* `options` Object - The options which will be used for creating the new + `BrowserWindow`. Emitted when the page requests to open a new window for a `url`. It could be requested by `window.open` or an external link like ``. diff --git a/docs/api/web-view-tag.md b/docs/api/web-view-tag.md index 7b4aa2ebf8..3fda3a98ed 100644 --- a/docs/api/web-view-tag.md +++ b/docs/api/web-view-tag.md @@ -505,6 +505,8 @@ Returns: * `frameName` String * `disposition` String - Can be `default`, `foreground-tab`, `background-tab`, `new-window` and `other`. +* `options` Object - The options which should be used for creating the new + `BrowserWindow`. Fired when the guest page attempts to open a new browser window. From 748b1387d2d8e4de788b7368d8ddb19dd97fd740 Mon Sep 17 00:00:00 2001 From: Robo Date: Mon, 21 Sep 2015 22:13:32 +0530 Subject: [PATCH 035/165] browser: switch to set minimum version for TLS fallback --- atom/browser/atom_browser_context.cc | 5 +++ atom/browser/atom_browser_context.h | 1 + atom/browser/atom_ssl_config_service.cc | 47 ++++++++++++++++++++++++ atom/browser/atom_ssl_config_service.h | 28 ++++++++++++++ atom/common/options_switches.cc | 4 ++ atom/common/options_switches.h | 1 + docs/api/chrome-command-line-switches.md | 5 +++ filenames.gypi | 2 + 8 files changed, 93 insertions(+) create mode 100644 atom/browser/atom_ssl_config_service.cc create mode 100644 atom/browser/atom_ssl_config_service.h diff --git a/atom/browser/atom_browser_context.cc b/atom/browser/atom_browser_context.cc index d1ef09e70f..6823fbaee9 100644 --- a/atom/browser/atom_browser_context.cc +++ b/atom/browser/atom_browser_context.cc @@ -6,6 +6,7 @@ #include "atom/browser/atom_browser_main_parts.h" #include "atom/browser/atom_download_manager_delegate.h" +#include "atom/browser/atom_ssl_config_service.h" #include "atom/browser/browser.h" #include "atom/browser/net/atom_url_request_job_factory.h" #include "atom/browser/net/asar/asar_protocol_handler.h" @@ -156,6 +157,10 @@ content::BrowserPluginGuestManager* AtomBrowserContext::GetGuestManager() { return guest_manager_.get(); } +net::SSLConfigService* AtomBrowserContext::CreateSSLConfigService() { + return new AtomSSLConfigService; +} + void AtomBrowserContext::RegisterPrefs(PrefRegistrySimple* pref_registry) { pref_registry->RegisterFilePathPref(prefs::kSelectFileLastDirectory, base::FilePath()); diff --git a/atom/browser/atom_browser_context.h b/atom/browser/atom_browser_context.h index c99461ad9a..839359c1ef 100644 --- a/atom/browser/atom_browser_context.h +++ b/atom/browser/atom_browser_context.h @@ -27,6 +27,7 @@ class AtomBrowserContext : public brightray::BrowserContext { content::URLRequestInterceptorScopedVector* interceptors) override; net::HttpCache::BackendFactory* CreateHttpCacheBackendFactory( const base::FilePath& base_path) override; + net::SSLConfigService* CreateSSLConfigService() override; // content::BrowserContext: content::DownloadManagerDelegate* GetDownloadManagerDelegate() override; diff --git a/atom/browser/atom_ssl_config_service.cc b/atom/browser/atom_ssl_config_service.cc new file mode 100644 index 0000000000..f19dbacf7d --- /dev/null +++ b/atom/browser/atom_ssl_config_service.cc @@ -0,0 +1,47 @@ +// Copyright (c) 2015 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#include "atom/browser/atom_ssl_config_service.h" + +#include + +#include "base/command_line.h" +#include "atom/common/options_switches.h" +#include "content/public/browser/browser_thread.h" +#include "net/socket/ssl_client_socket.h" + +namespace atom { + +namespace { + +uint16 GetSSLProtocolVersion(const std::string& version_string) { + uint16 version = 0; // Invalid + if (version_string == "tls1") + version = net::SSL_PROTOCOL_VERSION_TLS1; + else if (version_string == "tls1.1") + version = net::SSL_PROTOCOL_VERSION_TLS1_1; + else if (version_string == "tls1.2") + version = net::SSL_PROTOCOL_VERSION_TLS1_2; + return version; +} + +} // namespace + +AtomSSLConfigService::AtomSSLConfigService() { + auto cmd_line = base::CommandLine::ForCurrentProcess(); + if (cmd_line->HasSwitch(switches::kSSLVersionFallbackMin)) { + auto version_string = + cmd_line->GetSwitchValueASCII(switches::kSSLVersionFallbackMin); + config_.version_fallback_min = GetSSLProtocolVersion(version_string); + } +} + +AtomSSLConfigService::~AtomSSLConfigService() { +} + +void AtomSSLConfigService::GetSSLConfig(net::SSLConfig* config) { + *config = config_; +} + +} // namespace atom diff --git a/atom/browser/atom_ssl_config_service.h b/atom/browser/atom_ssl_config_service.h new file mode 100644 index 0000000000..3fa91c62c4 --- /dev/null +++ b/atom/browser/atom_ssl_config_service.h @@ -0,0 +1,28 @@ +// Copyright (c) 2015 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#ifndef ATOM_BROWSER_ATOM_SSL_CONFIG_SERVICE_H_ +#define ATOM_BROWSER_ATOM_SSL_CONFIG_SERVICE_H_ + +#include "net/ssl/ssl_config_service.h" + +namespace atom { + +class AtomSSLConfigService : public net::SSLConfigService { + public: + AtomSSLConfigService(); + ~AtomSSLConfigService() override; + + // net::SSLConfigService: + void GetSSLConfig(net::SSLConfig* config) override; + + private: + net::SSLConfig config_; + + DISALLOW_COPY_AND_ASSIGN(AtomSSLConfigService); +}; + +} // namespace atom + +#endif // ATOM_BROWSER_ATOM_SSL_CONFIG_SERVICE_H_ diff --git a/atom/common/options_switches.cc b/atom/common/options_switches.cc index c70e1ba4af..46687becf8 100644 --- a/atom/common/options_switches.cc +++ b/atom/common/options_switches.cc @@ -113,6 +113,10 @@ const char kDisableHttpCache[] = "disable-http-cache"; // Register schemes to standard. const char kRegisterStandardSchemes[] = "register-standard-schemes"; +// The minimum SSL/TLS version ("tls1", "tls1.1", or "tls1.2") that +// TLS fallback will accept. +const char kSSLVersionFallbackMin[] = "ssl-version-fallback-min"; + // The browser process app model ID const char kAppUserModelId[] = "app-user-model-id"; diff --git a/atom/common/options_switches.h b/atom/common/options_switches.h index e62f311666..16046d19c8 100644 --- a/atom/common/options_switches.h +++ b/atom/common/options_switches.h @@ -59,6 +59,7 @@ extern const char kPageVisibility[]; extern const char kDisableHttpCache[]; extern const char kRegisterStandardSchemes[]; +extern const char kSSLVersionFallbackMin[]; extern const char kAppUserModelId[]; diff --git a/docs/api/chrome-command-line-switches.md b/docs/api/chrome-command-line-switches.md index 2f995c99b2..cd633fc046 100644 --- a/docs/api/chrome-command-line-switches.md +++ b/docs/api/chrome-command-line-switches.md @@ -87,6 +87,11 @@ Sets the `version` of the pepper flash plugin. Enables net log events to be saved and writes them to `path`. +## --ssl-version-fallback-min=`version` + +Set the minimum SSL/TLS version ("tls1", "tls1.1" or "tls1.2") that TLS +fallback will accept. + ## --v=`log_level` Gives the default maximal active V-logging level; 0 is the default. Normally diff --git a/filenames.gypi b/filenames.gypi index 99d6bc6d50..3258a032de 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -129,6 +129,8 @@ 'atom/browser/atom_quota_permission_context.h', 'atom/browser/atom_speech_recognition_manager_delegate.cc', 'atom/browser/atom_speech_recognition_manager_delegate.h', + 'atom/browser/atom_ssl_config_service.cc', + 'atom/browser/atom_ssl_config_service.h', 'atom/browser/bridge_task_runner.cc', 'atom/browser/bridge_task_runner.h', 'atom/browser/browser.cc', From d8062ab9e102707f5fc6e1c5374b4130aa34298d Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 23 Sep 2015 11:45:51 +0800 Subject: [PATCH 036/165] docs: win.setMenu is not available on OS X --- docs/api/browser-window.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index f1705c2917..a1870bc66a 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -665,7 +665,7 @@ Same as `webContents.loadUrl(url[, options])`. Same as `webContents.reload`. -### `win.setMenu(menu)` _OS X_ +### `win.setMenu(menu)` _Linux_ _Windows_ * `menu` Menu From 6c01cec8d289087741b4e7cee98a290f2f278a2c Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 23 Sep 2015 13:49:43 +0800 Subject: [PATCH 037/165] Update node to not rely on GC to free memory --- vendor/node | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/node b/vendor/node index fa54694af4..d64246490d 160000 --- a/vendor/node +++ b/vendor/node @@ -1 +1 @@ -Subproject commit fa54694af4350bf1720ff47e97a07c7c09325ee2 +Subproject commit d64246490d697f387b888391b1aba65032703a0f From f8f8db7e88f44293fcccca5810d84405ec3443af Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 23 Sep 2015 13:55:14 +0800 Subject: [PATCH 038/165] spec: Test whether ffi works --- spec/modules-spec.coffee | 4 ++++ spec/package.json | 1 + 2 files changed, 5 insertions(+) diff --git a/spec/modules-spec.coffee b/spec/modules-spec.coffee index e7bdac36b3..ed2d9fecb4 100644 --- a/spec/modules-spec.coffee +++ b/spec/modules-spec.coffee @@ -22,6 +22,10 @@ describe 'third-party module', -> assert.equal msg, 'ok' done() + describe 'ffi', -> + it 'does not crash', -> + require 'ffi' + describe 'q', -> Q = require 'q' diff --git a/spec/package.json b/spec/package.json index a3b0d590ef..8f43b711f1 100644 --- a/spec/package.json +++ b/spec/package.json @@ -5,6 +5,7 @@ "version": "0.1.0", "devDependencies": { "basic-auth": "^1.0.0", + "ffi": "2.0.0", "formidable": "1.0.16", "graceful-fs": "3.0.5", "mocha": "2.1.0", From 706deae1b0dc924fc8cb11f992f36c7cf56530ab Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 23 Sep 2015 15:44:50 +0800 Subject: [PATCH 039/165] spec: ffi is crashing on OS X --- spec/modules-spec.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/modules-spec.coffee b/spec/modules-spec.coffee index ed2d9fecb4..1406e0637e 100644 --- a/spec/modules-spec.coffee +++ b/spec/modules-spec.coffee @@ -23,6 +23,7 @@ describe 'third-party module', -> done() describe 'ffi', -> + return if process.platform is 'darwin' it 'does not crash', -> require 'ffi' From 334c28d128e6e04eccfef0d023d739004a3cd89f Mon Sep 17 00:00:00 2001 From: Kostiantyn Kahanskyi Date: Wed, 23 Sep 2015 10:21:03 +0200 Subject: [PATCH 040/165] :memo: Include UTF-8 charset in quick start example Partially fixes #678 --- docs/tutorial/quick-start.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/tutorial/quick-start.md b/docs/tutorial/quick-start.md index 93cd0ebc5b..4ce65a1dc1 100644 --- a/docs/tutorial/quick-start.md +++ b/docs/tutorial/quick-start.md @@ -124,6 +124,7 @@ Finally the `index.html` is the web page you want to show: + Hello World! From 1520ebfe1fe53a10610ef1f242d366812cfa7dd1 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 23 Sep 2015 17:31:26 +0800 Subject: [PATCH 041/165] Update brightray for #2861 --- vendor/brightray | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/brightray b/vendor/brightray index 25f3a9d0a5..8e443520e6 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 25f3a9d0a5b73ec170a65f4e2e4c9ad91e23fc8c +Subproject commit 8e443520e695674fd26585cfa24a0ec0b6140c27 From 22e6f15795dc457c48d5e7c751191ebc219eed49 Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Wed, 23 Sep 2015 11:20:26 -0700 Subject: [PATCH 042/165] Remove GUID from Shell_NotifyIcon calls https://github.com/atom/electron/issues/2468#issuecomment-142684129 has the details --- atom/browser/ui/win/notify_icon.cc | 30 ------------------------------ atom/browser/ui/win/notify_icon.h | 4 ---- 2 files changed, 34 deletions(-) diff --git a/atom/browser/ui/win/notify_icon.cc b/atom/browser/ui/win/notify_icon.cc index 4026d9ec4a..84c2c0252b 100644 --- a/atom/browser/ui/win/notify_icon.cc +++ b/atom/browser/ui/win/notify_icon.cc @@ -30,29 +30,6 @@ NotifyIcon::NotifyIcon(NotifyIconHost* host, message_id_(message), menu_model_(NULL), has_tray_app_id_hash_(false) { - // NB: If we have an App Model ID, we should propagate that to the tray. - // Doing this prevents duplicate items from showing up in the notification - // preferences (i.e. "Always Show / Show notifications only / etc") - PWSTR explicit_app_id; - if (SUCCEEDED(GetCurrentProcessExplicitAppUserModelID(&explicit_app_id))) { - // GUIDs and MD5 hashes are the same length. So convenient! - base::MD5Sum(explicit_app_id, - sizeof(wchar_t) * wcslen(explicit_app_id), - reinterpret_cast(&tray_app_id_hash_)); - - // Set the GUID to version 4 as described in RFC 4122, section 4.4. - // The format of GUID version 4 must be like - // xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx, where y is one of [8, 9, A, B]. - tray_app_id_hash_.Data3 &= 0x0fff; - tray_app_id_hash_.Data3 |= 0x4000; - - // Set y to one of [8, 9, A, B]. - tray_app_id_hash_.Data4[0] = 1; - - has_tray_app_id_hash_ = true; - CoTaskMemFree(explicit_app_id); - } - NOTIFYICONDATA icon_data; InitIconData(&icon_data); icon_data.uFlags |= NIF_MESSAGE; @@ -202,13 +179,6 @@ void NotifyIcon::InitIconData(NOTIFYICONDATA* icon_data) { icon_data->cbSize = sizeof(NOTIFYICONDATA); icon_data->hWnd = window_; icon_data->uID = icon_id_; - - if (has_tray_app_id_hash_) { - icon_data->uFlags |= NIF_GUID; - memcpy(reinterpret_cast(&icon_data->guidItem), - &tray_app_id_hash_, - sizeof(GUID)); - } } } // namespace atom diff --git a/atom/browser/ui/win/notify_icon.h b/atom/browser/ui/win/notify_icon.h index 136186b689..d368dec713 100644 --- a/atom/browser/ui/win/notify_icon.h +++ b/atom/browser/ui/win/notify_icon.h @@ -79,10 +79,6 @@ class NotifyIcon : public TrayIcon { // The context menu. ui::SimpleMenuModel* menu_model_; - // A hash of the app model ID - GUID tray_app_id_hash_; - bool has_tray_app_id_hash_; - DISALLOW_COPY_AND_ASSIGN(NotifyIcon); }; From b0e5039951b8f17f15b0978e873dd4010530ad39 Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Wed, 23 Sep 2015 11:26:57 -0700 Subject: [PATCH 043/165] Fix initializer --- atom/browser/ui/win/notify_icon.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/atom/browser/ui/win/notify_icon.cc b/atom/browser/ui/win/notify_icon.cc index 84c2c0252b..03274abe98 100644 --- a/atom/browser/ui/win/notify_icon.cc +++ b/atom/browser/ui/win/notify_icon.cc @@ -28,8 +28,7 @@ NotifyIcon::NotifyIcon(NotifyIconHost* host, icon_id_(id), window_(window), message_id_(message), - menu_model_(NULL), - has_tray_app_id_hash_(false) { + menu_model_(NULL) { NOTIFYICONDATA icon_data; InitIconData(&icon_data); icon_data.uFlags |= NIF_MESSAGE; From d621755f1386777d12525069a5742f1848327807 Mon Sep 17 00:00:00 2001 From: Plusb Preco Date: Thu, 24 Sep 2015 12:47:30 +0900 Subject: [PATCH 044/165] Update as upstream, improve grammar --- docs-translations/ko-KR/README.md | 6 +++--- .../ko-KR/api/chrome-command-line-switches.md | 10 +++++++--- docs-translations/ko-KR/api/web-view-tag.md | 12 ++++++++++-- docs-translations/ko-KR/api/window-open.md | 4 ++++ 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/docs-translations/ko-KR/README.md b/docs-translations/ko-KR/README.md index 2fb242fae9..1e0ba63e7b 100644 --- a/docs-translations/ko-KR/README.md +++ b/docs-translations/ko-KR/README.md @@ -26,7 +26,7 @@ * [`` 태그](api/web-view-tag.md) * [`window.open` 함수](api/window-open.md) -### 메인 프로세스를 위한 모듈들: +### 메인 프로세스에서 사용할 수 있는 모듈: * [app (0% 번역됨)](api/app.md) * [auto-updater](api/auto-updater.md) @@ -44,13 +44,13 @@ * [web-contents (0% 번역됨)](api/web-contents.md) * [tray](api/tray.md) -### 랜더러 프로세스를 위한 모듈들 (웹 페이지): +### 랜더러 프로세스에서 사용할 수 있는 모듈 (웹 페이지): * [ipc (renderer)](api/ipc-renderer.md) * [remote](api/remote.md) * [web-frame](api/web-frame.md) -### 두 프로세스에서 모두 사용 가능한 모듈들: +### 두 프로세스 모두 사용할 수 있는 모듈: * [clipboard](api/clipboard.md) * [crash-reporter](api/crash-reporter.md) diff --git a/docs-translations/ko-KR/api/chrome-command-line-switches.md b/docs-translations/ko-KR/api/chrome-command-line-switches.md index 5b9bf47220..2d9158fcc2 100644 --- a/docs-translations/ko-KR/api/chrome-command-line-switches.md +++ b/docs-translations/ko-KR/api/chrome-command-line-switches.md @@ -1,6 +1,6 @@ # 크롬 Command-Line 스위치 지원 -다음 Command-Line 스위치들은 크롬 브라우저에서 제공되는 추가 옵션이며 Electron에서도 지원합니다. +크롬 Command-Line 스위치는 크롬 브라우저에서 제공되는 추가 옵션이며 Electron에서도 지원합니다. [app][app]의 [ready][ready]이벤트가 작동하기 전에 [app.commandLine.appendSwitch][append-switch] API를 사용하면 어플리케이션 내부에서 스위치들을 추가할 수 있습니다: @@ -80,7 +80,11 @@ Pepper 플래시 플러그인의 버전을 설정합니다. ## --log-net-log=`path` -Net log 이벤트를 지정한 `path`에 로그로 기록합니다. +Net log 이벤트를 활성화하고 `path`에 로그를 기록합니다. + +## --ssl-version-fallback-min=`version` + +Fallback SSL/TLS 최소 버전을 지정합니다. ("tls1", "tls1.1", "tls1.2") ## --v=`log_level` @@ -93,7 +97,7 @@ Net log 이벤트를 지정한 `path`에 로그로 기록합니다. `--v` 옵션에 전달된 값을 덮어쓰고 모듈당 최대 V-logging 레벨을 지정합니다. 예를 들어 `my_module=2,foo*=3`는 `my_module.*`, `foo*.*`와 같은 파일 이름 패턴을 가진 모든 소스 코드들의 로깅 레벨을 각각 2와 3으로 설정합니다. -슬래시(`/`), 백슬래시(`\`)를 포함하는 모든 패턴은 모듈뿐만 아니라 모든 경로명에 대해서도 테스트 됩니다. +또한 슬래시(`/`) 또는 백슬래시(`\`)를 포함하는 패턴은 지정한 경로에 대해 패턴을 테스트 합니다. 예를 들어 `*/foo/bar/*=2` 표현식은 `foo/bar` 디렉터리 안의 모든 소스 코드의 로깅 레벨을 2로 지정합니다. 모든 크로미움과 관련된 로그를 비활성화하고 어플리케이션의 로그만 활성화 하려면 다음과 같이 코드를 작성하면 됩니다: diff --git a/docs-translations/ko-KR/api/web-view-tag.md b/docs-translations/ko-KR/api/web-view-tag.md index b3f05de7f3..69b94465ae 100644 --- a/docs-translations/ko-KR/api/web-view-tag.md +++ b/docs-translations/ko-KR/api/web-view-tag.md @@ -135,6 +135,14 @@ 즉. 작동중인 랜더러 프로세스의 세션은 변경할 수 없습니다. 이후 이 값을 바꾸려고 시도하면 DOM 예외를 발생시킵니다. +### `allowpopups` + +```html + +``` + +"on"으로 지정하면 페이지에서 새로운 창을 열 수 있도록 허용합니다. + ## Methods `webview` 태그는 다음과 같은 메서드를 가지고 있습니다: @@ -467,8 +475,8 @@ Returns: * `url` String * `frameName` String -* `disposition` String - Can be `default`, `foreground-tab`, `background-tab`, - `new-window` and `other` +* `disposition` String - `default`, `foreground-tab`, `background-tab`, `new-window`, `other`를 사용할 수 있습니다. +* `options` Object - 새로운 `BrowserWindow`를 만들 때 사용되어야 하는 옵션. 페이지가 새로운 브라우저 창을 생성할 때 발생하는 이벤트입니다. diff --git a/docs-translations/ko-KR/api/window-open.md b/docs-translations/ko-KR/api/window-open.md index a4cf3bce5c..828c46e679 100644 --- a/docs-translations/ko-KR/api/window-open.md +++ b/docs-translations/ko-KR/api/window-open.md @@ -6,6 +6,8 @@ 프록시 객체는 브라우저의 웹 페이지 창과 호환될 수 있도록 일부 제한된 표준 기능만 가지고 있습니다. 창의 모든 컨트롤 권한을 가지려면 `BrowserWindow`를 직접 생성해서 사용해야 합니다. +새롭게 생성된 `BrowserWindow`는 기본적으로 부모 창의 옵션을 상속합니다. 이 옵션을 변경하려면 새 창을 열 때 `features` 인자를 지정해야 합니다. + ### `window.open(url[, frameName][, features])` * `url` String @@ -14,6 +16,8 @@ `BrowserWindowProxy` 클래스의 객체를 반환하는 새로운 윈도우를 생성합니다. +`features` 문자열은 표준 브라우저의 포맷을 따르고 있지만, 각 기능은 `BrowserWindow`의 옵션이어야 합니다. + ### `window.opener.postMessage(message, targetOrigin)` * `message` String From 9b1fa04988c2db6653a8537fb7fd645f2c76f24b Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 24 Sep 2015 12:01:57 +0800 Subject: [PATCH 045/165] win: Fix building --- atom/browser/ui/win/notify_icon.cc | 7 ------- 1 file changed, 7 deletions(-) diff --git a/atom/browser/ui/win/notify_icon.cc b/atom/browser/ui/win/notify_icon.cc index 03274abe98..c88d4c810e 100644 --- a/atom/browser/ui/win/notify_icon.cc +++ b/atom/browser/ui/win/notify_icon.cc @@ -4,10 +4,7 @@ #include "atom/browser/ui/win/notify_icon.h" -#include - #include "atom/browser/ui/win/notify_icon_host.h" -#include "base/md5.h" #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" #include "base/win/windows_version.h" @@ -57,10 +54,6 @@ void NotifyIcon::HandleClickEvent(const gfx::Point& cursor_pos, icon_id.uID = icon_id_; icon_id.hWnd = window_; icon_id.cbSize = sizeof(NOTIFYICONIDENTIFIER); - if (has_tray_app_id_hash_) - memcpy(reinterpret_cast(&icon_id.guidItem), - &tray_app_id_hash_, - sizeof(GUID)); RECT rect = { 0 }; Shell_NotifyIconGetRect(&icon_id, &rect); From 9e90ea8734521f249d555256849b83710bb0dc1f Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 24 Sep 2015 12:11:07 +0800 Subject: [PATCH 046/165] win: Fix leaking of fd when reading file in asar --- atom/common/asar/archive.cc | 20 +++++++++----------- atom/common/asar/archive.h | 1 + 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/atom/common/asar/archive.cc b/atom/common/asar/archive.cc index 0b2f59ae0f..969f958956 100644 --- a/atom/common/asar/archive.cc +++ b/atom/common/asar/archive.cc @@ -115,6 +115,14 @@ bool FillFileInfoWithNode(Archive::FileInfo* info, Archive::Archive(const base::FilePath& path) : path_(path), file_(path_, base::File::FLAG_OPEN | base::File::FLAG_READ), +#if defined(OS_WIN) + fd_(_open_osfhandle( + reinterpret_cast(file_.GetPlatformFile()), 0)), +#elif defined(OS_POSIX) + fd_(file_.GetPlatformFile()), +#else + fd_(-1), +#endif header_size_(0) { } @@ -271,17 +279,7 @@ bool Archive::CopyFileOut(const base::FilePath& path, base::FilePath* out) { } int Archive::GetFD() const { - if (!file_.IsValid()) - return -1; - -#if defined(OS_WIN) - return - _open_osfhandle(reinterpret_cast(file_.GetPlatformFile()), 0); -#elif defined(OS_POSIX) - return file_.GetPlatformFile(); -#else - return -1; -#endif + return fd_; } } // namespace asar diff --git a/atom/common/asar/archive.h b/atom/common/asar/archive.h index dda7aa78e0..f2ff2f76d6 100644 --- a/atom/common/asar/archive.h +++ b/atom/common/asar/archive.h @@ -69,6 +69,7 @@ class Archive { private: base::FilePath path_; base::File file_; + int fd_; uint32 header_size_; scoped_ptr header_; From 269f70c12ab8eaeff2da8e0f32ebcfffcb794d8f Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 24 Sep 2015 12:15:18 +0800 Subject: [PATCH 047/165] spec: Reading asar file should not leak fd --- spec/asar-spec.coffee | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/asar-spec.coffee b/spec/asar-spec.coffee index 4ef9337f3a..1e6ee69103 100644 --- a/spec/asar-spec.coffee +++ b/spec/asar-spec.coffee @@ -8,6 +8,10 @@ describe 'asar package', -> describe 'node api', -> describe 'fs.readFileSync', -> + it 'does not leak fd', -> + for i in [1..10000] + fs.readFileSync(path.join(process.resourcesPath, 'atom.asar', 'renderer', 'api', 'lib', 'ipc.js')) + it 'reads a normal file', -> file1 = path.join fixtures, 'asar', 'a.asar', 'file1' assert.equal fs.readFileSync(file1).toString().trim(), 'file1' From 576257470bf1fe4ab7b68887a0526144f3b2f260 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 24 Sep 2015 12:20:29 +0800 Subject: [PATCH 048/165] spec: Remove the will-navigate test It is unreliable to test in renderer process, remove it for now. --- spec/api-browser-window-spec.coffee | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/spec/api-browser-window-spec.coffee b/spec/api-browser-window-spec.coffee index de713a6545..2e4a66b92b 100644 --- a/spec/api-browser-window-spec.coffee +++ b/spec/api-browser-window-spec.coffee @@ -294,16 +294,6 @@ describe 'browser-window module', -> w.show() w.minimize() - describe 'will-navigate event', -> - @timeout 10000 - it 'emits when user starts a navigation', (done) -> - url = "file://#{fixtures}/pages/will-navigate.html" - w.webContents.on 'will-navigate', (event, u) -> - event.preventDefault() - assert.equal u, url - done() - w.loadUrl url - xdescribe 'beginFrameSubscription method', -> it 'subscribes frame updates', (done) -> w.loadUrl "file://#{fixtures}/api/blank.html" From 5ca5c4fb92ab2ba75308d91796e0113869148d8a Mon Sep 17 00:00:00 2001 From: Robo Date: Tue, 22 Sep 2015 22:21:49 +0530 Subject: [PATCH 049/165] browser: hide webcontents when window not shown --- atom/browser/native_window.cc | 7 ++++++- spec/chromium-spec.coffee | 17 +++++++++++++++++ spec/fixtures/pages/document-hidden.html | 7 +++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 spec/fixtures/pages/document-hidden.html diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 4d5f273340..e06633d7b7 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -159,8 +159,13 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) { // Then show it. bool show = true; options.Get(switches::kShow, &show); - if (show) + if (show) { Show(); + } else { + // When RenderView is created it sets to visible, this is to prevent + // breaking the visibility API. + web_contents()->WasHidden(); + } } void NativeWindow::SetSize(const gfx::Size& size) { diff --git a/spec/chromium-spec.coffee b/spec/chromium-spec.coffee index 4dd39aff5f..a782079026 100644 --- a/spec/chromium-spec.coffee +++ b/spec/chromium-spec.coffee @@ -23,6 +23,23 @@ describe 'chromium feature', -> {port} = server.address() $.get "http://127.0.0.1:#{port}" + describe 'document.hidden', -> + BrowserWindow = remote.require 'browser-window' + ipc = remote.require 'ipc' + url = "file://#{fixtures}/pages/document-hidden.html" + w = null + + afterEach -> + w?.destroy() + ipc.removeAllListeners 'hidden' + + it 'is set correctly when window is not shown', (done) -> + ipc.once 'hidden', (event, hidden) -> + assert hidden + done() + w = new BrowserWindow(show:false) + w.loadUrl url + describe 'navigator.webkitGetUserMedia', -> it 'calls its callbacks', (done) -> @timeout 5000 diff --git a/spec/fixtures/pages/document-hidden.html b/spec/fixtures/pages/document-hidden.html new file mode 100644 index 0000000000..17920bff07 --- /dev/null +++ b/spec/fixtures/pages/document-hidden.html @@ -0,0 +1,7 @@ + + + + + From fe2d9ee0f69a96b78edf595e626138f416e26030 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 24 Sep 2015 14:16:45 +0800 Subject: [PATCH 050/165] Update libchromium to have the V8 patch --- script/lib/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/lib/config.py b/script/lib/config.py index 0df68bd773..68f216785d 100644 --- a/script/lib/config.py +++ b/script/lib/config.py @@ -8,7 +8,7 @@ import sys BASE_URL = os.getenv('LIBCHROMIUMCONTENT_MIRROR') or \ 'http://github-janky-artifacts.s3.amazonaws.com/libchromiumcontent' -LIBCHROMIUMCONTENT_COMMIT = '8482fe555913dea3bde8a74f754524e2cfb02bc5' +LIBCHROMIUMCONTENT_COMMIT = '04523758cda2a96d2454f9056fb1fb9a1c1f95f1' PLATFORM = { 'cygwin': 'win32', From 497732fb6f191fab881330b6b5617f3c19754da7 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 24 Sep 2015 15:06:06 +0800 Subject: [PATCH 051/165] Revert "spec: ffi is crashing on OS X" This reverts commit 706deae1b0dc924fc8cb11f992f36c7cf56530ab. --- spec/modules-spec.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/modules-spec.coffee b/spec/modules-spec.coffee index 1406e0637e..ed2d9fecb4 100644 --- a/spec/modules-spec.coffee +++ b/spec/modules-spec.coffee @@ -23,7 +23,6 @@ describe 'third-party module', -> done() describe 'ffi', -> - return if process.platform is 'darwin' it 'does not crash', -> require 'ffi' From e3fab8b5b3ed7ab772e4187992b2d39410c5e711 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 24 Sep 2015 15:08:38 +0800 Subject: [PATCH 052/165] spec: Run an example of ffi --- spec/modules-spec.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/modules-spec.coffee b/spec/modules-spec.coffee index ed2d9fecb4..1cdc6cf0ea 100644 --- a/spec/modules-spec.coffee +++ b/spec/modules-spec.coffee @@ -24,7 +24,9 @@ describe 'third-party module', -> describe 'ffi', -> it 'does not crash', -> - require 'ffi' + ffi = require 'ffi' + libm = ffi.Library('libm', ceil: [ 'double', [ 'double' ] ]) + assert.equal libm.ceil(1.5), 2 describe 'q', -> Q = require 'q' From 0861d5d44bb0e2692535aa63cb46eed303524ac4 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Thu, 24 Sep 2015 15:55:45 +0800 Subject: [PATCH 053/165] Redefine 'will-download' design. --- atom/browser/api/atom_api_download_item.cc | 62 ++++++++++++++----- atom/browser/api/atom_api_download_item.h | 18 ++++-- atom/browser/api/atom_api_session.cc | 9 --- atom/browser/api/atom_api_session.h | 2 - atom/browser/api/lib/app.coffee | 2 +- .../browser/atom_download_manager_delegate.cc | 56 ++++++++--------- atom/browser/atom_download_manager_delegate.h | 1 - docs/api/download-item.md | 17 +++-- docs/api/session.md | 7 --- spec/api-session-spec.coffee | 53 ++++++++-------- spec/static/main.js | 23 +++++++ 11 files changed, 149 insertions(+), 101 deletions(-) diff --git a/atom/browser/api/atom_api_download_item.cc b/atom/browser/api/atom_api_download_item.cc index 6c6bb4dae9..3d150462bd 100644 --- a/atom/browser/api/atom_api_download_item.cc +++ b/atom/browser/api/atom_api_download_item.cc @@ -4,9 +4,13 @@ #include "atom/browser/api/atom_api_download_item.h" +#include + #include "atom/common/native_mate_converters/callback.h" +#include "atom/common/native_mate_converters/file_path_converter.h" #include "atom/common/native_mate_converters/gurl_converter.h" #include "atom/common/node_includes.h" +#include "base/memory/linked_ptr.h" #include "native_mate/dictionary.h" namespace mate { @@ -43,27 +47,36 @@ namespace { // The wrapDownloadItem funtion which is implemented in JavaScript using WrapDownloadItemCallback = base::Callback)>; WrapDownloadItemCallback g_wrap_download_item; + +char kDownloadItemSavePathKey[] = "DownloadItemSavePathKey"; + +std::map>> g_download_item_objects; } // namespace +DownloadItem::SavePathData::SavePathData(const base::FilePath& path) : + path_(path) { +} + +const base::FilePath& DownloadItem::SavePathData::path() { + return path_; +} + DownloadItem::DownloadItem(content::DownloadItem* download_item) : download_item_(download_item) { download_item_->AddObserver(this); } DownloadItem::~DownloadItem() { - download_item_->RemoveObserver(this); + Destroy(); } -void DownloadItem::OnDownloadUpdated(content::DownloadItem* item) { - if (download_item_ == item) { - download_item_->IsDone() ? - Emit("done", item->GetState()) : Emit("updated"); - } -} - -void DownloadItem::OnDownloadDestroyed(content::DownloadItem* download) { - if (download_item_ == download) { +void DownloadItem::Destroy() { + if (download_item_) { download_item_->RemoveObserver(this); + auto iter = g_download_item_objects.find(download_item_->GetId()); + if (iter != g_download_item_objects.end()) + g_download_item_objects.erase(iter); + download_item_ = nullptr; } } @@ -71,8 +84,12 @@ bool DownloadItem::IsDestroyed() const { return download_item_ == nullptr; } -void DownloadItem::Destroy() { - download_item_ = nullptr; +void DownloadItem::OnDownloadUpdated(content::DownloadItem* item) { + download_item_->IsDone() ? Emit("done", item->GetState()) : Emit("updated"); +} + +void DownloadItem::OnDownloadDestroyed(content::DownloadItem* download) { + Destroy(); } int64 DownloadItem::GetReceivedBytes() { @@ -83,7 +100,7 @@ int64 DownloadItem::GetTotalBytes() { return download_item_->GetTotalBytes(); } -const GURL& DownloadItem::GetURL() { +const GURL& DownloadItem::GetUrl() { return download_item_->GetURL(); } @@ -103,6 +120,10 @@ std::string DownloadItem::GetContentDisposition() { return download_item_->GetContentDisposition(); } +void DownloadItem::SetSavePath(const base::FilePath& path) { + download_item_->SetUserData(UserDataKey(), new SavePathData(path)); +} + void DownloadItem::Pause() { download_item_->Pause(); } @@ -121,13 +142,14 @@ mate::ObjectTemplateBuilder DownloadItem::GetObjectTemplateBuilder( .SetMethod("pause", &DownloadItem::Pause) .SetMethod("resume", &DownloadItem::Resume) .SetMethod("cancel", &DownloadItem::Cancel) - .SetMethod("getReceiveBytes", &DownloadItem::GetReceivedBytes) + .SetMethod("getReceivedBytes", &DownloadItem::GetReceivedBytes) .SetMethod("getTotalBytes", &DownloadItem::GetTotalBytes) - .SetMethod("getURL", &DownloadItem::GetURL) + .SetMethod("getUrl", &DownloadItem::GetUrl) .SetMethod("getMimeType", &DownloadItem::GetMimeType) .SetMethod("hasUserGesture", &DownloadItem::HasUserGesture) .SetMethod("getSuggestedFilename", &DownloadItem::GetSuggestedFilename) - .SetMethod("getContentDisposition", &DownloadItem::GetContentDisposition); + .SetMethod("getContentDisposition", &DownloadItem::GetContentDisposition) + .SetMethod("setSavePath", &DownloadItem::SetSavePath); } void SetWrapDownloadItem(const WrapDownloadItemCallback& callback) { @@ -138,13 +160,21 @@ void ClearWrapDownloadItem() { g_wrap_download_item.Reset(); } +// static mate::Handle DownloadItem::Create( v8::Isolate* isolate, content::DownloadItem* item) { auto handle = mate::CreateHandle(isolate, new DownloadItem(item)); g_wrap_download_item.Run(handle.ToV8()); + g_download_item_objects[item->GetId()] = make_linked_ptr( + new v8::Global(isolate, handle.ToV8())); return handle; } +// static +void* DownloadItem::UserDataKey() { + return &kDownloadItemSavePathKey; +} + } // namespace api } // namespace atom diff --git a/atom/browser/api/atom_api_download_item.h b/atom/browser/api/atom_api_download_item.h index e12064c825..3e90ced8a8 100644 --- a/atom/browser/api/atom_api_download_item.h +++ b/atom/browser/api/atom_api_download_item.h @@ -8,6 +8,7 @@ #include #include "atom/browser/api/trackable_object.h" +#include "base/files/file_path.h" #include "content/public/browser/download_item.h" #include "native_mate/handle.h" #include "url/gurl.h" @@ -16,9 +17,17 @@ namespace atom { namespace api { -class DownloadItem : public mate::TrackableObject, +class DownloadItem : public mate::EventEmitter, public content::DownloadItem::Observer { public: + class SavePathData : public base::SupportsUserData::Data { + public: + explicit SavePathData(const base::FilePath& path); + const base::FilePath& path(); + private: + base::FilePath path_; + }; + explicit DownloadItem(content::DownloadItem* download_item); ~DownloadItem(); static mate::Handle Create(v8::Isolate* isolate, @@ -37,16 +46,17 @@ class DownloadItem : public mate::TrackableObject, bool HasUserGesture(); std::string GetSuggestedFilename(); std::string GetContentDisposition(); - const GURL& GetURL(); + const GURL& GetUrl(); + void SetSavePath(const base::FilePath& path); + static void* UserDataKey(); private: // mate::Wrappable: mate::ObjectTemplateBuilder GetObjectTemplateBuilder( v8::Isolate* isolate) override; bool IsDestroyed() const override; - // mate::TrackableObject: - void Destroy() override; + void Destroy(); content::DownloadItem* download_item_; diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index 27e52e112e..7d5f75cac0 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -10,7 +10,6 @@ #include "atom/browser/api/atom_api_cookies.h" #include "atom/browser/api/atom_api_download_item.h" #include "atom/browser/atom_browser_context.h" -#include "atom/browser/atom_download_manager_delegate.h" #include "atom/browser/api/atom_api_web_contents.h" #include "atom/common/native_mate_converters/callback.h" #include "atom/common/native_mate_converters/gurl_converter.h" @@ -295,13 +294,6 @@ void Session::SetDownloadPath(const base::FilePath& path) { prefs::kDownloadDefaultDirectory, path); } -void Session::SetOpenDownloadDialog(bool open_download_dialog) { - AtomDownloadManagerDelegate* delegate = - static_cast( - browser_context()->GetDownloadManagerDelegate()); - delegate->SetOpenDownloadDialog(open_download_dialog); -} - v8::Local Session::Cookies(v8::Isolate* isolate) { if (cookies_.IsEmpty()) { auto handle = atom::api::Cookies::Create(isolate, browser_context()); @@ -318,7 +310,6 @@ mate::ObjectTemplateBuilder Session::GetObjectTemplateBuilder( .SetMethod("clearStorageData", &Session::ClearStorageData) .SetMethod("setProxy", &Session::SetProxy) .SetMethod("setDownloadPath", &Session::SetDownloadPath) - .SetMethod("setOpenDownloadDialog", &Session::SetOpenDownloadDialog) .SetProperty("cookies", &Session::Cookies); } diff --git a/atom/browser/api/atom_api_session.h b/atom/browser/api/atom_api_session.h index 2c53cfdac5..14406e57af 100644 --- a/atom/browser/api/atom_api_session.h +++ b/atom/browser/api/atom_api_session.h @@ -43,8 +43,6 @@ class Session: public mate::TrackableObject, AtomBrowserContext* browser_context() const { return browser_context_.get(); } - void SetOpenDownloadDialog(bool open_download_dialog); - protected: explicit Session(AtomBrowserContext* browser_context); ~Session(); diff --git a/atom/browser/api/lib/app.coffee b/atom/browser/api/lib/app.coffee index 3bf85c5905..48ddd1768e 100644 --- a/atom/browser/api/lib/app.coffee +++ b/atom/browser/api/lib/app.coffee @@ -15,7 +15,7 @@ wrapDownloadItem = (download_item) -> # download_item is an Event Emitter. download_item.__proto__ = EventEmitter.prototype # Be compatible with old APIs. - download_item.url = download_item.getURL() + download_item.url = download_item.getUrl() download_item.filename = download_item.getSuggestedFilename() download_item.mimeType = download_item.getMimeType() download_item.hasUserGesture = download_item.hasUserGesture() diff --git a/atom/browser/atom_download_manager_delegate.cc b/atom/browser/atom_download_manager_delegate.cc index 88daec2f46..b6b6566825 100644 --- a/atom/browser/atom_download_manager_delegate.cc +++ b/atom/browser/atom_download_manager_delegate.cc @@ -6,6 +6,7 @@ #include +#include "atom/browser/api/atom_api_download_item.h" #include "atom/browser/atom_browser_context.h" #include "atom/browser/native_window.h" #include "atom/browser/ui/file_dialog.h" @@ -23,8 +24,7 @@ namespace atom { AtomDownloadManagerDelegate::AtomDownloadManagerDelegate( content::DownloadManager* manager) : download_manager_(manager), - weak_ptr_factory_(this), - open_download_dialog_(true) {} + weak_ptr_factory_(this) {} AtomDownloadManagerDelegate::~AtomDownloadManagerDelegate() { if (download_manager_) { @@ -74,20 +74,14 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated( if (relay) window = relay->window.get(); - file_dialog::Filters filters; base::FilePath path; - if (!open_download_dialog_) { - // Use default_path if download dialog is disabled. - path = default_path; - } else { - if (file_dialog::ShowSaveDialog(window, item->GetURL().spec(), default_path, - filters, &path)) { - // Remember the last selected download directory. - AtomBrowserContext* browser_context = static_cast( - download_manager_->GetBrowserContext()); - browser_context->prefs()->SetFilePath(prefs::kDownloadDefaultDirectory, - path.DirName()); - } + if (file_dialog::ShowSaveDialog(window, item->GetURL().spec(), default_path, + file_dialog::Filters(), &path)) { + // Remember the last selected download directory. + AtomBrowserContext* browser_context = static_cast( + download_manager_->GetBrowserContext()); + browser_context->prefs()->SetFilePath(prefs::kDownloadDefaultDirectory, + path.DirName()); } // Running the DownloadTargetCallback with an empty FilePath signals that the @@ -98,11 +92,6 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated( content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, path); } -void AtomDownloadManagerDelegate::SetOpenDownloadDialog( - bool open_download_dialog) { - open_download_dialog_ = open_download_dialog; -} - void AtomDownloadManagerDelegate::Shutdown() { weak_ptr_factory_.InvalidateWeakPtrs(); download_manager_ = nullptr; @@ -113,6 +102,25 @@ bool AtomDownloadManagerDelegate::DetermineDownloadTarget( const content::DownloadTargetCallback& callback) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + if (!download->GetForcedFilePath().empty()) { + callback.Run(download->GetForcedFilePath(), + content::DownloadItem::TARGET_DISPOSITION_OVERWRITE, + content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, + download->GetForcedFilePath()); + return true; + } + base::SupportsUserData::Data* save_path = download->GetUserData( + atom::api::DownloadItem::UserDataKey()); + if (save_path) { + const base::FilePath& default_download_path = + static_cast(save_path)->path(); + callback.Run(default_download_path, + content::DownloadItem::TARGET_DISPOSITION_OVERWRITE, + content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, + default_download_path); + return true; + } + AtomBrowserContext* browser_context = static_cast( download_manager_->GetBrowserContext()); base::FilePath default_download_path = browser_context->prefs()->GetFilePath( @@ -123,14 +131,6 @@ bool AtomDownloadManagerDelegate::DetermineDownloadTarget( default_download_path = path.Append(FILE_PATH_LITERAL("Downloads")); } - if (!download->GetForcedFilePath().empty()) { - callback.Run(download->GetForcedFilePath(), - content::DownloadItem::TARGET_DISPOSITION_OVERWRITE, - content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, - download->GetForcedFilePath()); - return true; - } - CreateDownloadPathCallback download_path_callback = base::Bind(&AtomDownloadManagerDelegate::OnDownloadPathGenerated, weak_ptr_factory_.GetWeakPtr(), diff --git a/atom/browser/atom_download_manager_delegate.h b/atom/browser/atom_download_manager_delegate.h index d518e16bcb..d602cb9aca 100644 --- a/atom/browser/atom_download_manager_delegate.h +++ b/atom/browser/atom_download_manager_delegate.h @@ -49,7 +49,6 @@ class AtomDownloadManagerDelegate : public content::DownloadManagerDelegate { private: content::DownloadManager* download_manager_; base::WeakPtrFactory weak_ptr_factory_; - bool open_download_dialog_; DISALLOW_COPY_AND_ASSIGN(AtomDownloadManagerDelegate); }; diff --git a/docs/api/download-item.md b/docs/api/download-item.md index 7b496dbc2b..d18433c3fe 100644 --- a/docs/api/download-item.md +++ b/docs/api/download-item.md @@ -5,16 +5,15 @@ is used in `will-download` event of `Session` module, and allows users to control the download item. ```javascript -// Disable showing the download saving dialog. -win.webContents.session.setOpenDownloadDialog(false); - +// In the main process. win.webContents.session.on('will-download', function(event, item, webContents) { - console.log("Download from " + item.getURL()); + // Set the save path, making Electron not to prompt a save dialog. + item.setSavePath('/tmp/save.pdf'); console.log(item.getMimeType()); console.log(item.getSuggestedFilename()); console.log(item.getTotalBytes()); item.on('updated', function() { - console.log('Recived bytes: ' + item.getReceiveBytes()); + console.log('Recived bytes: ' + item.getReceivedBytes()); }); item.on('done', function(e, state) { if (state == "completed") { @@ -48,6 +47,14 @@ download that can't be resumed. The `downloadItem` object has the following methods: +### `downloadItem.setSavePath(path)` + +* `path` String - Set the save file path of the download item. + +The API is only available in session's `will-download` callback function. +If user doesn't set the save path via the API, Electron will use the original +routine to determine the save path(Usually prompts a save dialog). + ### `downloadItem.pause()` Pauses the download. diff --git a/docs/api/session.md b/docs/api/session.md index 2219cf3beb..ae0aacf465 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -191,10 +191,3 @@ proxy-uri = ["://"][":"] Sets download saving directory. By default, the download directory will be the `Downloads` under the respective app folder. - -### `session.setOpenDownloadDialog(openDownloadDialog)` - -* `openDownloadDialog` Boolean - Whether a download saving dialog will be - prompted when the download starts. - -By default, the download saving dialog is enable in Electron. diff --git a/spec/api-session-spec.coffee b/spec/api-session-spec.coffee index fe5765b45f..fb036bc412 100644 --- a/spec/api-session-spec.coffee +++ b/spec/api-session-spec.coffee @@ -75,15 +75,11 @@ describe 'session module', -> w.webContents.send 'getcount' describe 'DownloadItem', -> - # A 5MB mock pdf. - mockPDF = new Buffer(1024*1024*5) + # A 5 MB mock pdf. + mockPDF = new Buffer 1024 * 1024 * 5 contentDisposition = 'inline; filename="mock.pdf"' - # TODO(hokein): Change the download directory to spec/fixtures directory. - # We have to use the # default download directory due to the broken - # session.setDownloadPath API is broken. Once the API is fixed, we can make - # this change. - defaultDownloadDir = path.join app.getPath('userData'), 'Downloads' - downloadFilePath = path.join defaultDownloadDir, "mock.pdf" + ipc = require 'ipc' + downloadFilePath = path.join fixtures, 'mock.pdf' downloadServer = http.createServer (req, res) -> res.writeHead 200, { 'Content-Length': mockPDF.length, @@ -96,29 +92,30 @@ describe 'session module', -> it 'can download successfully', (done) -> downloadServer.listen 0, '127.0.0.1', -> {port} = downloadServer.address() + ipc.sendSync 'set-download-option', false w.loadUrl "#{url}:#{port}" - w.webContents.session.setOpenDownloadDialog false - - w.webContents.session.once 'will-download', (e, item, webContents) -> - item.on 'done', (e, state) -> - assert.equal state, "completed" - assert.equal item.getContentDisposition(), contentDisposition - assert.equal item.getReceiveBytes(), mockPDF.length - assert.equal item.getTotalBytes(), mockPDF.length - assert fs.existsSync downloadFilePath - fs.unlinkSync downloadFilePath - done() - assert.equal item.getURL(), "#{url}:#{port}/" - assert.equal item.getMimeType(), "application/pdf" + ipc.once 'download-done', (state, url, mimeType, receivedBytes, + totalBytes, disposition) -> + assert.equal state, 'completed' + assert.equal url, "http://127.0.0.1:#{port}/" + assert.equal mimeType, 'application/pdf' + assert.equal receivedBytes, mockPDF.length + assert.equal totalBytes, mockPDF.length + assert.equal disposition, contentDisposition + assert fs.existsSync downloadFilePath + fs.unlinkSync downloadFilePath + done() it 'can cancel download', (done) -> downloadServer.listen 0, '127.0.0.1', -> {port} = downloadServer.address() + ipc.sendSync 'set-download-option', true w.loadUrl "#{url}:#{port}/" - w.webContents.session.setOpenDownloadDialog false - w.webContents.session.once 'will-download', (e, item, webContents) -> - item.pause() - item.on 'done', (e, state) -> - assert.equal state, "cancelled" - done() - item.cancel() + ipc.once 'download-done', (state, url, mimeType, receivedBytes, + totalBytes, disposition) -> + assert.equal state, 'cancelled' + assert.equal mimeType, 'application/pdf' + assert.equal receivedBytes, 0 + assert.equal totalBytes, mockPDF.length + assert.equal disposition, contentDisposition + done() diff --git a/spec/static/main.js b/spec/static/main.js index 38ba7cc089..6f84c3f1c7 100644 --- a/spec/static/main.js +++ b/spec/static/main.js @@ -1,6 +1,7 @@ var app = require('app'); var ipc = require('ipc'); var dialog = require('dialog'); +var path = require('path'); var BrowserWindow = require('browser-window'); var window = null; @@ -73,4 +74,26 @@ app.on('ready', function() { }); if (chosen == 0) window.destroy(); }); + + // For session's download test, listen 'will-download' event in browser, and + // reply the result to renderer for verifying + var downloadFilePath = path.join(__dirname, '..', 'fixtures', 'mock.pdf'); + require('ipc').on('set-download-option', function(event, need_cancel) { + window.webContents.session.once('will-download', + function(e, item, webContents) { + item.setSavePath(downloadFilePath); + item.on('done', function(e, state) { + window.webContents.send('download-done', + state, + item.getUrl(), + item.getMimeType(), + item.getReceivedBytes(), + item.getTotalBytes(), + item.getContentDisposition()); + }); + if (need_cancel) + item.cancel(); + }); + event.returnValue = "done"; + }); }); From 39695cdb85151a41f861d222fb3191ad3507a6aa Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 24 Sep 2015 16:17:42 +0800 Subject: [PATCH 054/165] docs: Set npm_config_runtime when using npm Refs https://github.com/mapbox/node-pre-gyp/pull/175. --- docs/tutorial/using-native-node-modules.md | 25 +++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/docs/tutorial/using-native-node-modules.md b/docs/tutorial/using-native-node-modules.md index c338494cde..0e6477fc4c 100644 --- a/docs/tutorial/using-native-node-modules.md +++ b/docs/tutorial/using-native-node-modules.md @@ -34,6 +34,19 @@ npm install --save-dev electron-rebuild node ./node_modules/.bin/electron-rebuild ``` +### The npm Way + +You can also use `npm` to install modules. The steps are exactly the same with +Node modules, except that you need to setup some environment variables: + +```bash +export npm_config_disturl=https://atom.io/download/atom-shell +export npm_config_target=0.33.1 +export npm_config_arch=x64 +export npm_config_runtime=electron +HOME=~/.electron-gyp npm install module-name +``` + ### The node-gyp Way To build Node modules with headers of Electron, you need to tell `node-gyp` @@ -48,15 +61,3 @@ The `HOME=~/.electron-gyp` changes where to find development headers. The `--target=0.29.1` is version of Electron. The `--dist-url=...` specifies where to download the headers. The `--arch=x64` says the module is built for 64bit system. - -### The npm Way - -You can also use `npm` to install modules. The steps are exactly the same with -Node modules, except that you need to setup some environment variables: - -```bash -export npm_config_disturl=https://atom.io/download/atom-shell -export npm_config_target=0.29.1 -export npm_config_arch=x64 -HOME=~/.electron-gyp npm install module-name -``` From 1879392c7baaef8c51e2e90b6cce125b94ade572 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Thu, 24 Sep 2015 16:31:41 +0800 Subject: [PATCH 055/165] Reimplement downloadItem.getFilename API. Previously, the suggested file name(Always 'empty') returned by 'download_item->GetSuggestedFilename' is not the same with the default one saved in local disk. The patch reimplement this API allowing it to return the default file name, which is more expected from user. --- atom/browser/api/atom_api_download_item.cc | 13 ++++++++++--- atom/browser/api/atom_api_download_item.h | 2 +- atom/browser/api/lib/app.coffee | 2 +- docs/api/download-item.md | 15 +++++++-------- spec/api-session-spec.coffee | 6 ++++-- spec/static/main.js | 3 ++- 6 files changed, 25 insertions(+), 16 deletions(-) diff --git a/atom/browser/api/atom_api_download_item.cc b/atom/browser/api/atom_api_download_item.cc index 3d150462bd..6b3dfbf3f7 100644 --- a/atom/browser/api/atom_api_download_item.cc +++ b/atom/browser/api/atom_api_download_item.cc @@ -11,7 +11,9 @@ #include "atom/common/native_mate_converters/gurl_converter.h" #include "atom/common/node_includes.h" #include "base/memory/linked_ptr.h" +#include "base/strings/utf_string_conversions.h" #include "native_mate/dictionary.h" +#include "net/base/filename_util.h" namespace mate { @@ -112,8 +114,13 @@ bool DownloadItem::HasUserGesture() { return download_item_->HasUserGesture(); } -std::string DownloadItem::GetSuggestedFilename() { - return download_item_->GetSuggestedFilename(); +std::string DownloadItem::GetFilename() { + return base::UTF16ToUTF8(net::GenerateFileName(GetUrl(), + GetContentDisposition(), + std::string(), + download_item_->GetSuggestedFilename(), + GetMimeType(), + std::string()).LossyDisplayName()); } std::string DownloadItem::GetContentDisposition() { @@ -147,7 +154,7 @@ mate::ObjectTemplateBuilder DownloadItem::GetObjectTemplateBuilder( .SetMethod("getUrl", &DownloadItem::GetUrl) .SetMethod("getMimeType", &DownloadItem::GetMimeType) .SetMethod("hasUserGesture", &DownloadItem::HasUserGesture) - .SetMethod("getSuggestedFilename", &DownloadItem::GetSuggestedFilename) + .SetMethod("getFilename", &DownloadItem::GetFilename) .SetMethod("getContentDisposition", &DownloadItem::GetContentDisposition) .SetMethod("setSavePath", &DownloadItem::SetSavePath); } diff --git a/atom/browser/api/atom_api_download_item.h b/atom/browser/api/atom_api_download_item.h index 3e90ced8a8..e7b30dd13a 100644 --- a/atom/browser/api/atom_api_download_item.h +++ b/atom/browser/api/atom_api_download_item.h @@ -44,7 +44,7 @@ class DownloadItem : public mate::EventEmitter, int64 GetTotalBytes(); std::string GetMimeType(); bool HasUserGesture(); - std::string GetSuggestedFilename(); + std::string GetFilename(); std::string GetContentDisposition(); const GURL& GetUrl(); void SetSavePath(const base::FilePath& path); diff --git a/atom/browser/api/lib/app.coffee b/atom/browser/api/lib/app.coffee index 48ddd1768e..18c80dc2b1 100644 --- a/atom/browser/api/lib/app.coffee +++ b/atom/browser/api/lib/app.coffee @@ -16,7 +16,7 @@ wrapDownloadItem = (download_item) -> download_item.__proto__ = EventEmitter.prototype # Be compatible with old APIs. download_item.url = download_item.getUrl() - download_item.filename = download_item.getSuggestedFilename() + download_item.filename = download_item.getFilename() download_item.mimeType = download_item.getMimeType() download_item.hasUserGesture = download_item.hasUserGesture() diff --git a/docs/api/download-item.md b/docs/api/download-item.md index d18433c3fe..722dc5d8cf 100644 --- a/docs/api/download-item.md +++ b/docs/api/download-item.md @@ -10,10 +10,10 @@ win.webContents.session.on('will-download', function(event, item, webContents) { // Set the save path, making Electron not to prompt a save dialog. item.setSavePath('/tmp/save.pdf'); console.log(item.getMimeType()); - console.log(item.getSuggestedFilename()); + console.log(item.getFilename()); console.log(item.getTotalBytes()); item.on('updated', function() { - console.log('Recived bytes: ' + item.getReceivedBytes()); + console.log('Received bytes: ' + item.getReceivedBytes()); }); item.on('done', function(e, state) { if (state == "completed") { @@ -24,7 +24,6 @@ win.webContents.session.on('will-download', function(event, item, webContents) { }); ``` - ## Events ### Event: 'updated' @@ -79,13 +78,13 @@ Returns a `String` represents the mime type. Returns a `Boolean` indicates whether the download has user gesture. -### `downloadItem.getSuggestedFilename()` +### `downloadItem.getFilename()` -Returns a `String` represents the suggested file name of the download file. +Returns a `String` represents the file name of the download item. -**Note:** The suggested file name is not always the same as the actual one saved -in local disk. If user changes the file name in a prompted download saving -dialog, the actual name of saved file will be different with the suggested one. +**Note:** The file name is not always the same as the actual one saved in local +disk. If user changes the file name in a prompted download saving dialog, the +actual name of saved file will be different. ### `downloadItem.getTotalBytes()` diff --git a/spec/api-session-spec.coffee b/spec/api-session-spec.coffee index fb036bc412..9e083d27c0 100644 --- a/spec/api-session-spec.coffee +++ b/spec/api-session-spec.coffee @@ -95,8 +95,9 @@ describe 'session module', -> ipc.sendSync 'set-download-option', false w.loadUrl "#{url}:#{port}" ipc.once 'download-done', (state, url, mimeType, receivedBytes, - totalBytes, disposition) -> + totalBytes, disposition, filename) -> assert.equal state, 'completed' + assert.equal filename, 'mock.pdf' assert.equal url, "http://127.0.0.1:#{port}/" assert.equal mimeType, 'application/pdf' assert.equal receivedBytes, mockPDF.length @@ -112,8 +113,9 @@ describe 'session module', -> ipc.sendSync 'set-download-option', true w.loadUrl "#{url}:#{port}/" ipc.once 'download-done', (state, url, mimeType, receivedBytes, - totalBytes, disposition) -> + totalBytes, disposition, filename) -> assert.equal state, 'cancelled' + assert.equal filename, 'mock.pdf' assert.equal mimeType, 'application/pdf' assert.equal receivedBytes, 0 assert.equal totalBytes, mockPDF.length diff --git a/spec/static/main.js b/spec/static/main.js index 6f84c3f1c7..5b10bb6d43 100644 --- a/spec/static/main.js +++ b/spec/static/main.js @@ -89,7 +89,8 @@ app.on('ready', function() { item.getMimeType(), item.getReceivedBytes(), item.getTotalBytes(), - item.getContentDisposition()); + item.getContentDisposition(), + item.getFilename()); }); if (need_cancel) item.cancel(); From fc422e5d552e2c3f30e0d7bc2864de596880b6e1 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 24 Sep 2015 18:08:56 +0800 Subject: [PATCH 056/165] spec: Increase timeout for setTimeout test --- spec/node-spec.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/node-spec.coffee b/spec/node-spec.coffee index c8d569e01a..fc3fcc57f8 100644 --- a/spec/node-spec.coffee +++ b/spec/node-spec.coffee @@ -66,6 +66,7 @@ describe 'node feature', -> describe 'contexts', -> describe 'setTimeout in fs callback', -> it 'does not crash', (done) -> + @timeout 10000 fs.readFile __filename, -> setTimeout done, 0 From da57a3101fc1539fdeeaae9ff628f29ada29f60a Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 24 Sep 2015 18:15:57 +0800 Subject: [PATCH 057/165] Call WasShown when showing window Otherwise WebContents would be invisible when window is hidden at first and then show later. Refs #2879. --- atom/browser/native_window_mac.mm | 4 ++++ atom/browser/native_window_views.cc | 3 +++ 2 files changed, 7 insertions(+) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 9555914c89..6a99f1cf42 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -467,6 +467,8 @@ bool NativeWindowMac::IsFocused() { } void NativeWindowMac::Show() { + web_contents()->WasShown(); + // This method is supposed to put focus on window, however if the app does not // have focus then "makeKeyAndOrderFront" will only show the window. [NSApp activateIgnoringOtherApps:YES]; @@ -475,11 +477,13 @@ void NativeWindowMac::Show() { } void NativeWindowMac::ShowInactive() { + web_contents()->WasShown(); [window_ orderFrontRegardless]; } void NativeWindowMac::Hide() { [window_ orderOut:nil]; + web_contents()->WasHidden(); } bool NativeWindowMac::IsVisible() { diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 45697c9668..70707219f3 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -338,15 +338,18 @@ bool NativeWindowViews::IsFocused() { } void NativeWindowViews::Show() { + web_contents()->WasShown(); window_->native_widget_private()->ShowWithWindowState(GetRestoredState()); } void NativeWindowViews::ShowInactive() { + web_contents()->WasShown(); window_->ShowInactive(); } void NativeWindowViews::Hide() { window_->Hide(); + web_contents()->WasHidden(); } bool NativeWindowViews::IsVisible() { From 06cc1339597fa5b75f14a7695f6517100f23fcc6 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Thu, 24 Sep 2015 19:31:09 +0800 Subject: [PATCH 058/165] Some cleanup. --- atom/browser/api/atom_api_download_item.h | 8 +++++--- atom/browser/atom_download_manager_delegate.h | 1 - 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/atom/browser/api/atom_api_download_item.h b/atom/browser/api/atom_api_download_item.h index e7b30dd13a..14074a4bed 100644 --- a/atom/browser/api/atom_api_download_item.h +++ b/atom/browser/api/atom_api_download_item.h @@ -28,10 +28,13 @@ class DownloadItem : public mate::EventEmitter, base::FilePath path_; }; - explicit DownloadItem(content::DownloadItem* download_item); - ~DownloadItem(); static mate::Handle Create(v8::Isolate* isolate, content::DownloadItem* item); + static void* UserDataKey(); + + protected: + explicit DownloadItem(content::DownloadItem* download_item); + ~DownloadItem(); // Override content::DownloadItem::Observer methods void OnDownloadUpdated(content::DownloadItem* download) override; @@ -49,7 +52,6 @@ class DownloadItem : public mate::EventEmitter, const GURL& GetUrl(); void SetSavePath(const base::FilePath& path); - static void* UserDataKey(); private: // mate::Wrappable: mate::ObjectTemplateBuilder GetObjectTemplateBuilder( diff --git a/atom/browser/atom_download_manager_delegate.h b/atom/browser/atom_download_manager_delegate.h index d602cb9aca..2df3a7d45a 100644 --- a/atom/browser/atom_download_manager_delegate.h +++ b/atom/browser/atom_download_manager_delegate.h @@ -34,7 +34,6 @@ class AtomDownloadManagerDelegate : public content::DownloadManagerDelegate { void OnDownloadPathGenerated(uint32 download_id, const content::DownloadTargetCallback& callback, const base::FilePath& default_path); - void SetOpenDownloadDialog(bool open_download_dialog); // content::DownloadManagerDelegate: void Shutdown() override; From a0638fe801fc0c502f2bd6c42923e098c02b5ee1 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 24 Sep 2015 21:06:24 +0800 Subject: [PATCH 059/165] spec: Suppress the setTimeout test on Travis CI Not sure why it failed there. --- spec/node-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/node-spec.coffee b/spec/node-spec.coffee index fc3fcc57f8..969fc76f41 100644 --- a/spec/node-spec.coffee +++ b/spec/node-spec.coffee @@ -65,8 +65,8 @@ describe 'node feature', -> describe 'contexts', -> describe 'setTimeout in fs callback', -> + return if process.env.TRAVIS is 'true' it 'does not crash', (done) -> - @timeout 10000 fs.readFile __filename, -> setTimeout done, 0 From 01f06431423195891f6f6f63f3135d83ec8eca20 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Fri, 25 Sep 2015 09:34:04 +0800 Subject: [PATCH 060/165] Fix inconsistent docs: downloadItem.getURL() => downloadItem.getUrl() --- docs/api/download-item.md | 2 +- docs/api/session.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api/download-item.md b/docs/api/download-item.md index 722dc5d8cf..5097fde83f 100644 --- a/docs/api/download-item.md +++ b/docs/api/download-item.md @@ -66,7 +66,7 @@ Resumes the download that has been paused. Cancels the download operation. -### `downloadItem.getURL()` +### `downloadItem.getUrl()` Returns a `String` represents the origin url where the item is downloaded from. diff --git a/docs/api/session.md b/docs/api/session.md index ae0aacf465..64991ab753 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -28,7 +28,7 @@ Calling `event.preventDefault()` will cancel the download. ```javascript session.on('will-download', function(event, item, webContents) { event.preventDefault(); - require('request')(item.getURL(), function(data) { + require('request')(item.getUrl(), function(data) { require('fs').writeFileSync('/somewhere', data); }); }); From 109d8352e1f0970c3382a89ff72289065a04af49 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 25 Sep 2015 12:52:16 +0800 Subject: [PATCH 061/165] Update node, fixes #2894 --- vendor/node | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/node b/vendor/node index d64246490d..558bfc0482 160000 --- a/vendor/node +++ b/vendor/node @@ -1 +1 @@ -Subproject commit d64246490d697f387b888391b1aba65032703a0f +Subproject commit 558bfc048294acb57f702f1a802eddd01ebf2794 From 004d3ced5323f55fb094c400365d21edcf4e109c Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 25 Sep 2015 13:04:54 +0800 Subject: [PATCH 062/165] Update node to fix building on Windows --- vendor/node | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/node b/vendor/node index 558bfc0482..ac25693ad1 160000 --- a/vendor/node +++ b/vendor/node @@ -1 +1 @@ -Subproject commit 558bfc048294acb57f702f1a802eddd01ebf2794 +Subproject commit ac25693ad1d4c248e69a89147fd3995c3bf6c946 From 4a64d1d9467e00748f4e157af664a51aed564e38 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Fri, 25 Sep 2015 13:13:11 +0800 Subject: [PATCH 063/165] :memo: fix a typo interrputed => interrupted --- atom/browser/api/atom_api_download_item.cc | 2 +- docs/api/download-item.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/atom/browser/api/atom_api_download_item.cc b/atom/browser/api/atom_api_download_item.cc index 6b3dfbf3f7..ec4dcd84b2 100644 --- a/atom/browser/api/atom_api_download_item.cc +++ b/atom/browser/api/atom_api_download_item.cc @@ -30,7 +30,7 @@ struct Converter { download_state = "cancelled"; break; case content::DownloadItem::INTERRUPTED: - download_state = "interrputed"; + download_state = "interrupted"; break; default: break; diff --git a/docs/api/download-item.md b/docs/api/download-item.md index 5097fde83f..53cd56cca9 100644 --- a/docs/api/download-item.md +++ b/docs/api/download-item.md @@ -39,7 +39,7 @@ Emits when the `downloadItem` gets updated. * `interrupted` - An error broke the connection with the file server. Emits when the download is in a terminal state. This includes a completed -download, a cancelled download(via `downloadItem.cancel()`), and interrputed +download, a cancelled download(via `downloadItem.cancel()`), and interrupted download that can't be resumed. ## Methods From 6f944ad49b85b772166fb14951c9a4c8ce4b963d Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 25 Sep 2015 16:21:08 +0800 Subject: [PATCH 064/165] Clean up code --- atom/browser/native_window_mac.mm | 36 ++++++++++++++----------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 6a99f1cf42..c87e4b2dca 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -351,21 +351,19 @@ NativeWindowMac::NativeWindowMac( bool useStandardWindow = true; options.Get(switches::kStandardWindow, &useStandardWindow); + // New title bar styles are available in Yosemite or newer + std::string titleBarStyle; + if (base::mac::IsOSYosemiteOrLater()) + options.Get(switches::kTitleBarStyle, &titleBarStyle); + NSUInteger styleMask = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask; if (!useStandardWindow || transparent() || !has_frame()) { styleMask |= NSTexturedBackgroundWindowMask; } - - std::string titleBarStyle = "default"; - options.Get(switches::kTitleBarStyle, &titleBarStyle); - - if (base::mac::IsOSYosemiteOrLater()) { - // New title bar styles are available in Yosemite or newer - if ((titleBarStyle == "hidden") || (titleBarStyle == "hidden-inset")) { - styleMask |= NSFullSizeContentViewWindowMask; - styleMask |= NSUnifiedTitleAndToolbarWindowMask; - } + if ((titleBarStyle == "hidden") || (titleBarStyle == "hidden-inset")) { + styleMask |= NSFullSizeContentViewWindowMask; + styleMask |= NSUnifiedTitleAndToolbarWindowMask; } window_.reset([[AtomNSWindow alloc] @@ -394,16 +392,14 @@ NativeWindowMac::NativeWindowMac( [window_ setReleasedWhenClosed:NO]; // Configure title bar look on Yosemite or newer - if (base::mac::IsOSYosemiteOrLater()) { - if ((titleBarStyle == "hidden") || (titleBarStyle == "hidden-inset")) { - [window_ setTitlebarAppearsTransparent:YES]; - [window_ setTitleVisibility:NSWindowTitleHidden]; - if (titleBarStyle == "hidden-inset") { - NSToolbar *toolbar = [[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]; - toolbar.showsBaselineSeparator = NO; - [window_ setToolbar:toolbar]; - [toolbar release]; - } + if ((titleBarStyle == "hidden") || (titleBarStyle == "hidden-inset")) { + [window_ setTitlebarAppearsTransparent:YES]; + [window_ setTitleVisibility:NSWindowTitleHidden]; + if (titleBarStyle == "hidden-inset") { + base::scoped_nsobject toolbar( + [[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]); + [toolbar setShowsBaselineSeparator:NO]; + [window_ setToolbar:toolbar]; } } From 7884a2319c5fb65c262435efc274c0f362c4f87e Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 25 Sep 2015 16:38:36 +0800 Subject: [PATCH 065/165] osx: Make draggable region work for window with hidden titlebar --- atom/browser/native_window.cc | 3 ++- atom/browser/native_window.h | 10 ++++++++++ atom/browser/native_window_mac.mm | 9 ++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index e06633d7b7..c3620bba70 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -68,6 +68,7 @@ NativeWindow::NativeWindow( const mate::Dictionary& options) : content::WebContentsObserver(inspectable_web_contents->GetWebContents()), has_frame_(true), + force_using_draggable_region_(false), transparent_(false), enable_larger_than_screen_(false), is_closed_(false), @@ -473,7 +474,7 @@ bool NativeWindow::OnMessageReceived(const IPC::Message& message) { void NativeWindow::UpdateDraggableRegions( const std::vector& regions) { // Draggable region is not supported for non-frameless window. - if (has_frame_) + if (has_frame_ && !force_using_draggable_region_) return; draggable_region_ = DraggableRegionsToSkRegion(regions); } diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index e9a2b9433d..5c8d8c73b0 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -219,6 +219,13 @@ class NativeWindow : public content::WebContentsObserver, bool enable_larger_than_screen() const { return enable_larger_than_screen_; } gfx::ImageSkia icon() const { return icon_; } + bool force_using_draggable_region() const { + return force_using_draggable_region_; + } + void set_force_using_draggable_region(bool force) { + force_using_draggable_region_ = true; + } + void set_has_dialog_attached(bool has_dialog_attached) { has_dialog_attached_ = has_dialog_attached; } @@ -257,6 +264,9 @@ class NativeWindow : public content::WebContentsObserver, // Whether window has standard frame. bool has_frame_; + // Force the window to be aware of draggable regions. + bool force_using_draggable_region_; + // Whether window is transparent. bool transparent_; diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index c87e4b2dca..f0a685e4d9 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -391,7 +391,7 @@ NativeWindowMac::NativeWindowMac( // We will manage window's lifetime ourselves. [window_ setReleasedWhenClosed:NO]; - // Configure title bar look on Yosemite or newer + // Hide the title bar. if ((titleBarStyle == "hidden") || (titleBarStyle == "hidden-inset")) { [window_ setTitlebarAppearsTransparent:YES]; [window_ setTitleVisibility:NSWindowTitleHidden]; @@ -401,6 +401,8 @@ NativeWindowMac::NativeWindowMac( [toolbar setShowsBaselineSeparator:NO]; [window_ setToolbar:toolbar]; } + // We should be aware of draggable regions when using hidden titlebar. + set_force_using_draggable_region(true); } // On OS X the initial window size doesn't include window frame. @@ -432,6 +434,11 @@ NativeWindowMac::NativeWindowMac( [view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; InstallView(); + + // Install the DraggableRegionView if it is forced to use draggable regions + // for normal window. + if (has_frame() && force_using_draggable_region()) + InstallDraggableRegionView(); } NativeWindowMac::~NativeWindowMac() { From c0528c5049dc42ab191367b0a463274f72f46818 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 25 Sep 2015 17:50:53 +0800 Subject: [PATCH 066/165] Bump v0.33.2 --- atom.gyp | 2 +- atom/browser/resources/mac/Info.plist | 2 +- atom/browser/resources/win/atom.rc | 8 ++++---- atom/common/atom_version.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/atom.gyp b/atom.gyp index 3a46f242a2..41d671d7a2 100644 --- a/atom.gyp +++ b/atom.gyp @@ -4,7 +4,7 @@ 'product_name%': 'Electron', 'company_name%': 'GitHub, Inc', 'company_abbr%': 'github', - 'version%': '0.33.1', + 'version%': '0.33.2', }, 'includes': [ 'filenames.gypi', diff --git a/atom/browser/resources/mac/Info.plist b/atom/browser/resources/mac/Info.plist index 6260173b82..745b12520c 100644 --- a/atom/browser/resources/mac/Info.plist +++ b/atom/browser/resources/mac/Info.plist @@ -17,7 +17,7 @@ CFBundleIconFile atom.icns CFBundleVersion - 0.33.1 + 0.33.2 LSMinimumSystemVersion 10.8.0 NSMainNibFile diff --git a/atom/browser/resources/win/atom.rc b/atom/browser/resources/win/atom.rc index 0583c2df3b..e0b9fa5cfe 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,33,1,0 - PRODUCTVERSION 0,33,1,0 + FILEVERSION 0,33,2,0 + PRODUCTVERSION 0,33,2,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -74,12 +74,12 @@ BEGIN BEGIN VALUE "CompanyName", "GitHub, Inc." VALUE "FileDescription", "Electron" - VALUE "FileVersion", "0.33.1" + VALUE "FileVersion", "0.33.2" VALUE "InternalName", "electron.exe" VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved." VALUE "OriginalFilename", "electron.exe" VALUE "ProductName", "Electron" - VALUE "ProductVersion", "0.33.1" + VALUE "ProductVersion", "0.33.2" VALUE "SquirrelAwareVersion", "1" END END diff --git a/atom/common/atom_version.h b/atom/common/atom_version.h index 5f9d0f3ca0..56dcd67fb0 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 33 -#define ATOM_PATCH_VERSION 1 +#define ATOM_PATCH_VERSION 2 #define ATOM_VERSION_IS_RELEASE 1 From bb102717b4576c8daf5e75ccc564b471c0bd1d70 Mon Sep 17 00:00:00 2001 From: Heilig Benedek Date: Fri, 25 Sep 2015 13:01:52 +0200 Subject: [PATCH 067/165] Adding option to specify the button of WebMouseEvent. --- .../native_mate_converters/blink_converter.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/atom/common/native_mate_converters/blink_converter.cc b/atom/common/native_mate_converters/blink_converter.cc index 67c7e7e95f..beb60737e7 100644 --- a/atom/common/native_mate_converters/blink_converter.cc +++ b/atom/common/native_mate_converters/blink_converter.cc @@ -77,6 +77,21 @@ struct Converter { } }; +template<> +struct Converter { + static bool FromV8(v8::Isolate* isolate, v8::Handle val, + blink::WebMouseEvent::Button* out) { + std::string button = base::StringToLowerASCII(V8ToString(val)); + if (button == "left") + *out = blink::WebMouseEvent::Button::ButtonLeft; + else if (button == "middle") + *out = blink::WebMouseEvent::Button::ButtonMiddle; + else if (button == "right") + *out = blink::WebMouseEvent::Button::ButtonRight; + return true; + } +}; + template<> struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Handle val, @@ -176,6 +191,7 @@ bool Converter::FromV8( return false; if (!dict.Get("x", &out->x) || !dict.Get("y", &out->y)) return false; + dict.Get("button", &out->button); dict.Get("globalX", &out->globalX); dict.Get("globalY", &out->globalY); dict.Get("movementX", &out->movementX); From 775c90b7337bcb74a3d5d21f803f4a7034c6ff24 Mon Sep 17 00:00:00 2001 From: Josh Abernathy Date: Fri, 25 Sep 2015 11:37:30 -0400 Subject: [PATCH 068/165] Use 0.8.0. This picks up the fix for https://github.com/atom/atom/issues/7061. --- script/update-external-binaries.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/update-external-binaries.py b/script/update-external-binaries.py index 49e73435ab..fae268ea8c 100755 --- a/script/update-external-binaries.py +++ b/script/update-external-binaries.py @@ -8,7 +8,7 @@ from lib.config import get_target_arch from lib.util import safe_mkdir, rm_rf, extract_zip, tempdir, download -VERSION = 'v0.7.0' +VERSION = 'v0.8.0' SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) FRAMEWORKS_URL = 'http://github.com/atom/atom-shell-frameworks/releases' \ '/download/' + VERSION From 56520159f73ba6fbc3faa41a6c0977e923c4e088 Mon Sep 17 00:00:00 2001 From: Plusb Preco Date: Sat, 26 Sep 2015 10:36:26 +0900 Subject: [PATCH 069/165] Update as upstream, fix small typo --- docs-translations/ko-KR/api/session.md | 8 ++---- .../ko-KR/tutorial/quick-start.md | 1 + .../tutorial/using-native-node-modules.md | 27 ++++++++++--------- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/docs-translations/ko-KR/api/session.md b/docs-translations/ko-KR/api/session.md index cb912aabb1..4c6ead1647 100644 --- a/docs-translations/ko-KR/api/session.md +++ b/docs-translations/ko-KR/api/session.md @@ -17,11 +17,7 @@ var session = win.webContents.session ### Event: 'will-download' * `event` Event -* `item` Object - * `url` String - * `filename` String - * `mimeType` String - * `hasUserGesture` Boolean +* `item` [DownloadItem](download-item.md) * `webContents` [WebContents](web-contents.md) Electron의 `webContents`에서 `item`을 다운로드할 때 발생하는 이벤트입니다. @@ -31,7 +27,7 @@ Electron의 `webContents`에서 `item`을 다운로드할 때 발생하는 이 ```javascript session.on('will-download', function(event, item, webContents) { event.preventDefault(); - require('request')(item.url, function(data) { + require('request')(item.getUrl(), function(data) { require('fs').writeFileSync('/somewhere', data); }); }); diff --git a/docs-translations/ko-KR/tutorial/quick-start.md b/docs-translations/ko-KR/tutorial/quick-start.md index 8c2e043061..4a6ce6d225 100644 --- a/docs-translations/ko-KR/tutorial/quick-start.md +++ b/docs-translations/ko-KR/tutorial/quick-start.md @@ -111,6 +111,7 @@ app.on('ready', function() { + 헬로 월드! diff --git a/docs-translations/ko-KR/tutorial/using-native-node-modules.md b/docs-translations/ko-KR/tutorial/using-native-node-modules.md index 913c300be8..ed64abb492 100644 --- a/docs-translations/ko-KR/tutorial/using-native-node-modules.md +++ b/docs-translations/ko-KR/tutorial/using-native-node-modules.md @@ -29,7 +29,20 @@ npm install --save-dev electron-rebuild node ./node_modules/.bin/electron-rebuild ``` -### node-gyp을 이용한 방법 +### `npm`을 이용한 방법 + +또한 `npm`을 통해 설치할 수도 있습니다. +환경변수가 필요한 것을 제외하고 일반 Node 모듈을 설치하는 방법과 완전히 똑같습니다: + +```bash +export npm_config_disturl=https://atom.io/download/atom-shell +export npm_config_target=0.33.1 +export npm_config_arch=x64 +export npm_config_runtime=electron +HOME=~/.electron-gyp npm install module-name +``` + +### `node-gyp`를 이용한 방법 Node 모듈을 `node-gyp`를 사용하여 Electron을 타겟으로 빌드할 때는 `node-gyp`에 헤더 다운로드 주소와 버전을 알려주어야 합니다: @@ -40,15 +53,3 @@ $ HOME=~/.electron-gyp node-gyp rebuild --target=0.29.1 --arch=x64 --dist-url=ht `HOME=~/.electron-gyp`은 변경할 헤더의 위치를 찾습니다. `--target=0.29.1`은 Electron의 버전입니다. `--dist-url=...`은 헤더를 다운로드 하는 주소입니다. `--arch=x64`는 64비트 시스템을 타겟으로 빌드 한다는 것을 `node-gyp`에게 알려줍니다. - -### npm을 이용한 방법 - -또한 `npm`을 통해 설치할 수도 있습니다. -환경변수가 필요한 것을 제외하고 일반 Node 모듈을 설치하는 방법과 완전히 똑같습니다: - -```bash -export npm_config_disturl=https://atom.io/download/atom-shell -export npm_config_target=0.29.1 -export npm_config_arch=x64 -HOME=~/.electron-gyp npm install module-name -``` From 690f859a78cb1928b299fc126b8f8720044cdc33 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 26 Sep 2015 22:06:01 +0800 Subject: [PATCH 070/165] Bump v0.33.3 --- atom.gyp | 2 +- atom/browser/resources/mac/Info.plist | 2 +- atom/browser/resources/win/atom.rc | 8 ++++---- atom/common/atom_version.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/atom.gyp b/atom.gyp index 41d671d7a2..42069ea846 100644 --- a/atom.gyp +++ b/atom.gyp @@ -4,7 +4,7 @@ 'product_name%': 'Electron', 'company_name%': 'GitHub, Inc', 'company_abbr%': 'github', - 'version%': '0.33.2', + 'version%': '0.33.3', }, 'includes': [ 'filenames.gypi', diff --git a/atom/browser/resources/mac/Info.plist b/atom/browser/resources/mac/Info.plist index 745b12520c..eb39cb35f9 100644 --- a/atom/browser/resources/mac/Info.plist +++ b/atom/browser/resources/mac/Info.plist @@ -17,7 +17,7 @@ CFBundleIconFile atom.icns CFBundleVersion - 0.33.2 + 0.33.3 LSMinimumSystemVersion 10.8.0 NSMainNibFile diff --git a/atom/browser/resources/win/atom.rc b/atom/browser/resources/win/atom.rc index e0b9fa5cfe..6fba6cf806 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,33,2,0 - PRODUCTVERSION 0,33,2,0 + FILEVERSION 0,33,3,0 + PRODUCTVERSION 0,33,3,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -74,12 +74,12 @@ BEGIN BEGIN VALUE "CompanyName", "GitHub, Inc." VALUE "FileDescription", "Electron" - VALUE "FileVersion", "0.33.2" + VALUE "FileVersion", "0.33.3" VALUE "InternalName", "electron.exe" VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved." VALUE "OriginalFilename", "electron.exe" VALUE "ProductName", "Electron" - VALUE "ProductVersion", "0.33.2" + VALUE "ProductVersion", "0.33.3" VALUE "SquirrelAwareVersion", "1" END END diff --git a/atom/common/atom_version.h b/atom/common/atom_version.h index 56dcd67fb0..4f24034754 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 33 -#define ATOM_PATCH_VERSION 2 +#define ATOM_PATCH_VERSION 3 #define ATOM_VERSION_IS_RELEASE 1 From 9f30e5f52635c797f633fbbc1c4417f1fad5664b Mon Sep 17 00:00:00 2001 From: Gohy Leandre Date: Sat, 26 Sep 2015 17:23:34 +0200 Subject: [PATCH 071/165] Add ability to preload modules (--require, -r) --- atom/browser/default_app/main.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/atom/browser/default_app/main.js b/atom/browser/default_app/main.js index 4d854dc35c..1b92685d13 100644 --- a/atom/browser/default_app/main.js +++ b/atom/browser/default_app/main.js @@ -13,8 +13,8 @@ app.on('window-all-closed', function() { // Parse command line options. var argv = process.argv.slice(1); -var option = { file: null, help: null, version: null, webdriver: null }; -for (var i in argv) { +var option = { file: null, help: null, version: null, webdriver: null, modules: [] }; +for (var i = 0; i < argv.length; i++) { if (argv[i] == '--version' || argv[i] == '-v') { option.version = true; break; @@ -23,6 +23,9 @@ for (var i in argv) { break; } else if (argv[i] == '--test-type=webdriver') { option.webdriver = true; + } else if (argv[i] == '--require' || argv[i] == '-r') { + option.modules.push(argv[++i]); + continue; } else if (argv[i][0] == '-') { continue; } else { @@ -212,6 +215,10 @@ app.once('ready', function() { Menu.setApplicationMenu(menu); }); +if (option.modules.length > 0) { + require('module')._preloadModules(option.modules); +} + // Start the specified app if there is one specified in command line, otherwise // start the default app. if (option.file && !option.webdriver) { @@ -253,6 +260,7 @@ if (option.file && !option.webdriver) { helpMessage += "A path to an Electron application may be specified. The path must be to \n"; helpMessage += "an index.js file or to a folder containing a package.json or index.js file.\n\n"; helpMessage += "Options:\n"; + helpMessage += " -r, --require Module to preload (option can be repeated)"; helpMessage += " -h, --help Print this usage message.\n"; helpMessage += " -v, --version Print the version."; console.log(helpMessage); From 457147365af2bbd3b69a0bf35cac8ce78110b76c Mon Sep 17 00:00:00 2001 From: fscherwi Date: Sun, 27 Sep 2015 14:44:28 +0200 Subject: [PATCH 072/165] standardize package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 101fdeee25..a125d13b68 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name": "electron", "devDependencies": { - "asar": "0.8.x", + "asar": "^0.8.0", "coffee-script": "^1.9.2", "coffeelint": "^1.9.4", "request": "*", - "runas": "3.x" + "runas": "^3.0.0" }, "private": true, "scripts": { From 397fbeae28db234b042baf144aa61f952e43d3b5 Mon Sep 17 00:00:00 2001 From: Plusb Preco Date: Sun, 27 Sep 2015 22:20:35 +0900 Subject: [PATCH 073/165] Update example variable name prefix (atom to electron) * Update variable name prefix as `atom` to `electron` --- docs-translations/ko-KR/api/screen.md | 10 +++++----- docs/api/screen.md | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs-translations/ko-KR/api/screen.md b/docs-translations/ko-KR/api/screen.md index 26975cbb1e..5e0805749f 100644 --- a/docs-translations/ko-KR/api/screen.md +++ b/docs-translations/ko-KR/api/screen.md @@ -6,7 +6,7 @@ `screen`은 [EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter)를 상속 받았습니다. **참고:** 랜더러 / DevTools에선 이미 DOM 속성이 `window.screen`을 가지고 있으므로 `screen = require('screen')` 형식으로 모듈을 사용할 수 없습니다. -밑의 예제와 같이 `atomScreen` 같은 이름으로 모듈 이름을 대체하여 사용해야 합니다. +밑의 예제와 같이 `electronScreen` 같은 이름으로 모듈 이름을 대체하여 사용해야 합니다. 다음 예제는 화면 전체를 채우는 윈도우 창을 생성합니다: @@ -17,8 +17,8 @@ var BrowserWindow = require('browser-window'); var mainWindow; app.on('ready', function() { - var atomScreen = require('screen'); - var size = atomScreen.getPrimaryDisplay().workAreaSize; + var electronScreen = require('screen'); + var size = electronScreen.getPrimaryDisplay().workAreaSize; mainWindow = new BrowserWindow({ width: size.width, height: size.height }); }); ``` @@ -32,8 +32,8 @@ var BrowserWindow = require('browser-window'); var mainWindow; app.on('ready', function() { - var atomScreen = require('screen'); - var displays = atomScreen.getAllDisplays(); + var electronScreen = require('screen'); + var displays = electronScreen.getAllDisplays(); var externalDisplay = null; for (var i in displays) { if (displays[i].bounds.x > 0 || displays[i].bounds.y > 0) { diff --git a/docs/api/screen.md b/docs/api/screen.md index 934e3eaf5a..da15c7326f 100644 --- a/docs/api/screen.md +++ b/docs/api/screen.md @@ -8,7 +8,7 @@ position, etc. You should not use this module until the `ready` event of the **Note:** In the renderer / DevTools, `window.screen` is a reserved DOM property, so writing `var screen = require('screen')` will not work. In our -examples below, we use `atomScreen` as the variable name instead. +examples below, we use `electronScreen` as the variable name instead. An example of creating a window that fills the whole screen: @@ -19,8 +19,8 @@ var BrowserWindow = require('browser-window'); var mainWindow; app.on('ready', function() { - var atomScreen = require('screen'); - var size = atomScreen.getPrimaryDisplay().workAreaSize; + var electronScreen = require('screen'); + var size = electronScreen.getPrimaryDisplay().workAreaSize; mainWindow = new BrowserWindow({ width: size.width, height: size.height }); }); ``` @@ -34,8 +34,8 @@ var BrowserWindow = require('browser-window'); var mainWindow; app.on('ready', function() { - var atomScreen = require('screen'); - var displays = atomScreen.getAllDisplays(); + var electronScreen = require('screen'); + var displays = electronScreen.getAllDisplays(); var externalDisplay = null; for (var i in displays) { if (displays[i].bounds.x > 0 || displays[i].bounds.y > 0) { From fc7f4ae24be37e7414887a7540f16d4167dd3762 Mon Sep 17 00:00:00 2001 From: Robo Date: Sun, 27 Sep 2015 18:49:52 +0530 Subject: [PATCH 074/165] session: api to emulate network conditions --- atom/browser/api/atom_api_session.cc | 41 ++++++++++++++++++++++++++++ atom/browser/api/atom_api_session.h | 3 ++ docs/api/session.md | 15 ++++++++++ 3 files changed, 59 insertions(+) diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index 7d5f75cac0..7bc1a2153e 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -19,6 +19,8 @@ #include "base/prefs/pref_service.h" #include "base/strings/string_util.h" #include "base/thread_task_runner_handle.h" +#include "brightray/browser/net/devtools_network_conditions.h" +#include "brightray/browser/net/devtools_network_controller.h" #include "chrome/common/pref_names.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/storage_partition.h" @@ -294,6 +296,43 @@ void Session::SetDownloadPath(const base::FilePath& path) { prefs::kDownloadDefaultDirectory, path); } +void Session::EnableNetworkEmulation(const mate::Dictionary& options) { + scoped_ptr conditions; + bool offline = false; + double latency, download_throughput, upload_throughput; + if (options.Get("offline", &offline) && offline) { + conditions.reset(new brightray::DevToolsNetworkConditions(offline)); + } else { + options.Get("latency", &latency); + options.Get("downloadThroughput", &download_throughput); + options.Get("uploadThroughput", &upload_throughput); + conditions.reset( + new brightray::DevToolsNetworkConditions(false, + latency, + download_throughput, + upload_throughput)); + } + auto controller = browser_context_->GetDevToolsNetworkController(); + + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, + base::Bind(&brightray::DevToolsNetworkController::SetNetworkState, + base::Unretained(controller), + std::string(), + base::Passed(&conditions))); +} + +void Session::DisableNetworkEmulation() { + scoped_ptr conditions( + new brightray::DevToolsNetworkConditions(false)); + auto controller = browser_context_->GetDevToolsNetworkController(); + + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, + base::Bind(&brightray::DevToolsNetworkController::SetNetworkState, + base::Unretained(controller), + std::string(), + base::Passed(&conditions))); +} + v8::Local Session::Cookies(v8::Isolate* isolate) { if (cookies_.IsEmpty()) { auto handle = atom::api::Cookies::Create(isolate, browser_context()); @@ -310,6 +349,8 @@ mate::ObjectTemplateBuilder Session::GetObjectTemplateBuilder( .SetMethod("clearStorageData", &Session::ClearStorageData) .SetMethod("setProxy", &Session::SetProxy) .SetMethod("setDownloadPath", &Session::SetDownloadPath) + .SetMethod("enableNetworkEmulation", &Session::EnableNetworkEmulation) + .SetMethod("disableNetworkEmulation", &Session::DisableNetworkEmulation) .SetProperty("cookies", &Session::Cookies); } diff --git a/atom/browser/api/atom_api_session.h b/atom/browser/api/atom_api_session.h index 14406e57af..68ee3634e6 100644 --- a/atom/browser/api/atom_api_session.h +++ b/atom/browser/api/atom_api_session.h @@ -20,6 +20,7 @@ class FilePath; namespace mate { class Arguments; +class Dictionary; } namespace atom { @@ -65,6 +66,8 @@ class Session: public mate::TrackableObject, void ClearStorageData(mate::Arguments* args); void SetProxy(const std::string& proxy, const base::Closure& callback); void SetDownloadPath(const base::FilePath& path); + void EnableNetworkEmulation(const mate::Dictionary& options); + void DisableNetworkEmulation(); v8::Local Cookies(v8::Isolate* isolate); // Cached object for cookies API. diff --git a/docs/api/session.md b/docs/api/session.md index 64991ab753..36a92f296e 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -191,3 +191,18 @@ proxy-uri = ["://"][":"] Sets download saving directory. By default, the download directory will be the `Downloads` under the respective app folder. + +### `session.enableNetworkEmulation(options)` + +* `options` Object + * `offline` Boolean - Whether to emulate network outage. + * `latency` Double - RTT in ms + * `downloadThroughput` Double - Download rate in Bps + * `uploadThroughput` Double - Upload rate in Bps + +Emulates network with the given configuration for the `session`. + +### `session.disableNetworkEmulation` + +Disables any network emulation already active for the `session`. Resets to +the original network configuration. From 6dcc752f6742d150ce909ffffae270355234c608 Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Mon, 28 Sep 2015 02:12:47 +0300 Subject: [PATCH 075/165] Set default extension in Windows file dialog On Windows when you open the save dialog and switch the filter, the extension is supposed to change accordingly. It didn't happen with the existing code, since the existing code didn't set the default extension (should be set to the first filter). This resolves #2915. --- atom/browser/ui/file_dialog_win.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/atom/browser/ui/file_dialog_win.cc b/atom/browser/ui/file_dialog_win.cc index b169471c6e..da00dc54e2 100644 --- a/atom/browser/ui/file_dialog_win.cc +++ b/atom/browser/ui/file_dialog_win.cc @@ -79,6 +79,9 @@ class FileDialog { if (!title.empty()) GetPtr()->SetTitle(base::UTF8ToUTF16(title).c_str()); + if (!filterspec.empty()) + GetPtr()->SetDefaultExtension(filterspec.front().pszSpec); + SetDefaultFolder(default_path); } From 70bdfedabf5f9e5bfb1acd89f23d1818e9538016 Mon Sep 17 00:00:00 2001 From: Heilig Benedek Date: Mon, 28 Sep 2015 02:41:06 +0200 Subject: [PATCH 076/165] Added text and unmodifiedtext setting when sending char type keyboard events, and made the type of the character read char16, so I can simulate char events from non-english origins. --- .../native_mate_converters/blink_converter.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/atom/common/native_mate_converters/blink_converter.cc b/atom/common/native_mate_converters/blink_converter.cc index beb60737e7..f1fc1983de 100644 --- a/atom/common/native_mate_converters/blink_converter.cc +++ b/atom/common/native_mate_converters/blink_converter.cc @@ -9,6 +9,7 @@ #include "atom/common/keyboad_util.h" #include "base/strings/string_util.h" +#include "base/strings/utf_string_conversions.h" #include "content/public/browser/native_web_keyboard_event.h" #include "native_mate/dictionary.h" #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" @@ -29,10 +30,10 @@ int VectorToBitArray(const std::vector& vec) { namespace mate { template<> -struct Converter { +struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Handle val, - char* out) { - std::string code = base::StringToLowerASCII(V8ToString(val)); + base::char16* out) { + base::string16 code = base::UTF8ToUTF16(V8ToString(val)); if (code.length() != 1) return false; *out = code[0]; @@ -157,16 +158,18 @@ bool Converter::FromV8( return false; if (!ConvertFromV8(isolate, val, static_cast(out))) return false; - char code; + base::char16 code; if (!dict.Get("keyCode", &code)) return false; bool shifted = false; out->windowsKeyCode = atom::KeyboardCodeFromCharCode(code, &shifted); - if (out->windowsKeyCode == ui::VKEY_UNKNOWN) - return false; if (shifted) out->modifiers |= blink::WebInputEvent::ShiftKey; out->setKeyIdentifierFromWindowsKeyCode(); + if (out->type == blink::WebInputEvent::Char || out->type == blink::WebInputEvent::RawKeyDown) { + out->text[0] = code; + out->unmodifiedText[0] = code; + } return true; } From 21cd4c14316b3a25053d1b45e8754f668a016774 Mon Sep 17 00:00:00 2001 From: Heilig Benedek Date: Mon, 28 Sep 2015 02:52:16 +0200 Subject: [PATCH 077/165] Added documentation about the changes --- docs/api/web-contents.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index c2dccc3a87..b2e924e5d0 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -534,13 +534,13 @@ Sends an input `event` to the page. For keyboard events, the `event` object also have following properties: * `keyCode` String (**required**) - A single character that will be sent as - keyboard event. Can be any ASCII character on the keyboard, like `a`, `1` - and `=`. + keyboard event. Can be any UTF-8 character. For mouse events, the `event` object also have following properties: * `x` Integer (**required**) * `y` Integer (**required**) +* `button` String - The button pressed, can be `left`, `middle`, `right` * `globalX` Integer * `globalY` Integer * `movementX` Integer From 44ee74a9b13db7e0e97248dcd1c4c1291f1fe878 Mon Sep 17 00:00:00 2001 From: Heilig Benedek Date: Mon, 28 Sep 2015 03:05:08 +0200 Subject: [PATCH 078/165] Style fix --- atom/common/native_mate_converters/blink_converter.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/atom/common/native_mate_converters/blink_converter.cc b/atom/common/native_mate_converters/blink_converter.cc index f1fc1983de..a723df1ea9 100644 --- a/atom/common/native_mate_converters/blink_converter.cc +++ b/atom/common/native_mate_converters/blink_converter.cc @@ -166,7 +166,8 @@ bool Converter::FromV8( if (shifted) out->modifiers |= blink::WebInputEvent::ShiftKey; out->setKeyIdentifierFromWindowsKeyCode(); - if (out->type == blink::WebInputEvent::Char || out->type == blink::WebInputEvent::RawKeyDown) { + if (out->type == blink::WebInputEvent::Char + || out->type == blink::WebInputEvent::RawKeyDown) { out->text[0] = code; out->unmodifiedText[0] = code; } From 82bb7905300f6bd906279df81bfe61a82d35e2da Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 28 Sep 2015 12:48:33 +0800 Subject: [PATCH 079/165] Style fix for #2918 --- atom/common/native_mate_converters/blink_converter.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/atom/common/native_mate_converters/blink_converter.cc b/atom/common/native_mate_converters/blink_converter.cc index a723df1ea9..0a599bfdf0 100644 --- a/atom/common/native_mate_converters/blink_converter.cc +++ b/atom/common/native_mate_converters/blink_converter.cc @@ -166,8 +166,8 @@ bool Converter::FromV8( if (shifted) out->modifiers |= blink::WebInputEvent::ShiftKey; out->setKeyIdentifierFromWindowsKeyCode(); - if (out->type == blink::WebInputEvent::Char - || out->type == blink::WebInputEvent::RawKeyDown) { + if (out->type == blink::WebInputEvent::Char || + out->type == blink::WebInputEvent::RawKeyDown) { out->text[0] = code; out->unmodifiedText[0] = code; } From 442c79abe0a36d38961177e738d0ffa35cbb81d7 Mon Sep 17 00:00:00 2001 From: Robo Date: Mon, 28 Sep 2015 12:39:55 +0530 Subject: [PATCH 080/165] update brightray --- vendor/brightray | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/brightray b/vendor/brightray index 8e443520e6..75f7d3fd88 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 8e443520e695674fd26585cfa24a0ec0b6140c27 +Subproject commit 75f7d3fd88ae60026a0717b93e3bf7182f827dc3 From db0732b35be691081ced67c219cb783e9ab2330a Mon Sep 17 00:00:00 2001 From: Robo Date: Mon, 28 Sep 2015 12:52:50 +0530 Subject: [PATCH 081/165] add examples --- docs/api/session.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/api/session.md b/docs/api/session.md index 36a92f296e..392b682641 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -202,6 +202,18 @@ Sets download saving directory. By default, the download directory will be the Emulates network with the given configuration for the `session`. +```javascript +// To emulate a GPRS connection with 50kbps throughput and 500 ms latency. +window.webContents.session.enableNetworkEmulation({ + latency: 500, + downloadThroughput: 6400, + uploadThroughput: 6400 +}); + +// To emulate a network outage. +window.webContents.session.enableNetworkEmulation({offline: true}); +``` + ### `session.disableNetworkEmulation` Disables any network emulation already active for the `session`. Resets to From 1b18a4dfad30a2437f72706ccee1c17a09b3683f Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 28 Sep 2015 15:34:52 +0800 Subject: [PATCH 082/165] Update node, fixes #2916 --- vendor/node | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/node b/vendor/node index ac25693ad1..f4243f5c84 160000 --- a/vendor/node +++ b/vendor/node @@ -1 +1 @@ -Subproject commit ac25693ad1d4c248e69a89147fd3995c3bf6c946 +Subproject commit f4243f5c84a371632d8d72a1a2210a0e994afdcc From 8734395358951f18d01e1e55c6915221f9f99c2b Mon Sep 17 00:00:00 2001 From: Heilig Benedek Date: Mon, 28 Sep 2015 22:33:43 +0200 Subject: [PATCH 083/165] Detalied documentation about frameBuffer's format. --- docs/api/web-contents.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index b2e924e5d0..7cbf8d93ba 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -565,8 +565,11 @@ For the `mouseWheel` event, the `event` object also have following properties: Begin subscribing for presentation events and captured frames, the `callback` will be called with `callback(frameBuffer)` when there is a presentation event. -The `frameBuffer` is a `Buffer` that contains raw pixel data, in the format of -32bit ARGB. +The `frameBuffer` is a `Buffer` that contains raw pixel data. On most machines, +the pixel data is effectively stored in 32bit BGRA format, but the actual +representation depends on the endianness of the processor (most modern +processors are little-endian, on machines with big-endian processors the data +is in 32bit ARGB format). ### `webContents.endFrameSubscription()` From fa95d32475e30120e8d93e2dcf3a4d91f416e06c Mon Sep 17 00:00:00 2001 From: Plusb Preco Date: Tue, 29 Sep 2015 05:35:33 +0900 Subject: [PATCH 084/165] Update as upstream, small changes --- docs-translations/ko-KR/api/screen.md | 2 +- docs-translations/ko-KR/api/session.md | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/docs-translations/ko-KR/api/screen.md b/docs-translations/ko-KR/api/screen.md index 5e0805749f..2d3c02f854 100644 --- a/docs-translations/ko-KR/api/screen.md +++ b/docs-translations/ko-KR/api/screen.md @@ -6,7 +6,7 @@ `screen`은 [EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter)를 상속 받았습니다. **참고:** 랜더러 / DevTools에선 이미 DOM 속성이 `window.screen`을 가지고 있으므로 `screen = require('screen')` 형식으로 모듈을 사용할 수 없습니다. -밑의 예제와 같이 `electronScreen` 같은 이름으로 모듈 이름을 대체하여 사용해야 합니다. +아래의 예제와 같이 `electronScreen` 같은 이름으로 모듈 이름을 대체하여 사용해야 합니다. 다음 예제는 화면 전체를 채우는 윈도우 창을 생성합니다: diff --git a/docs-translations/ko-KR/api/session.md b/docs-translations/ko-KR/api/session.md index 4c6ead1647..96d38dda5d 100644 --- a/docs-translations/ko-KR/api/session.md +++ b/docs-translations/ko-KR/api/session.md @@ -181,3 +181,29 @@ proxy-uri = ["://"][":"] * `path` String - 다운로드 위치 다운로드 저장 위치를 지정합니다. 기본 다운로드 위치는 각 어플리케이션 데이터 디렉터리의 `Downloads` 폴더입니다. + +### `session.enableNetworkEmulation(options)` + +* `options` Object + * `offline` Boolean - 네트워크의 오프라인 상태 여부 + * `latency` Double - 밀리세컨드 단위의 RTT + * `downloadThroughput` Double - Bps 단위의 다운로드 주기 + * `uploadThroughput` Double - Bps 단위의 업로드 주기 + +제공된 설정으로 `session`의 네트워크를 에뮬레이트합니다. + +```javascript +// 50kbps의 처리량과 함께 500ms의 레이턴시로 GPRS 연결을 에뮬레이트합니다. +window.webContents.session.enableNetworkEmulation({ + latency: 500, + downloadThroughput: 6400, + uploadThroughput: 6400 +}); + +// 네트워크가 끊긴 상태를 에뮬레이트합니다. +window.webContents.session.enableNetworkEmulation({offline: true}); +``` + +### `session.disableNetworkEmulation` + +활성화된 `session`의 에뮬레이션을 비활성화합니다. 기본 네트워크 설정으로 돌아갑니다. From ee0f0f6cfcd41f3f70399922bec08d1f109317ed Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Tue, 29 Sep 2015 02:20:09 +0300 Subject: [PATCH 085/165] Fix window state events on Windows This commit fixes the issue we had with window state events not firing when triggered through Aero Snap. Instead of listening to command from the system menu (SC_MAXIMIZE etc.), we use the WM_SIZE event. This resolves #1381. --- atom/browser/native_window_views.cc | 99 ++++++++++++++++++++--------- atom/browser/native_window_views.h | 8 ++- 2 files changed, 73 insertions(+), 34 deletions(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 70707219f3..34c2f62263 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -169,9 +169,6 @@ NativeWindowViews::NativeWindowViews( menu_bar_autohide_(false), menu_bar_visible_(false), menu_bar_alt_pressed_(false), -#if defined(OS_WIN) - is_minimized_(false), -#endif keyboard_event_handler_(new views::UnhandledKeyboardEventHandler), use_content_size_(false), resizable_(true) { @@ -228,6 +225,9 @@ NativeWindowViews::NativeWindowViews( window_->Init(params); + bool fullscreen = false; + options.Get(switches::kFullscreen, &fullscreen); + #if defined(USE_X11) // Start monitoring window states. window_state_watcher_.reset(new WindowStateWatcher(this)); @@ -253,8 +253,7 @@ NativeWindowViews::NativeWindowViews( } // Before the window is mapped, there is no SHOW_FULLSCREEN_STATE. - bool fullscreen = false; - if (options.Get(switches::kFullscreen, & fullscreen) && fullscreen) { + if (fullscreen) { state_atom_list.push_back(GetAtom("_NET_WM_STATE_FULLSCREEN")); } @@ -278,6 +277,12 @@ NativeWindowViews::NativeWindowViews( bounds = ContentBoundsToWindowBounds(bounds); #if defined(OS_WIN) + // Save initial window state. + if (fullscreen) + last_window_state_ = ui::SHOW_STATE_FULLSCREEN; + else + last_window_state_ = ui::SHOW_STATE_NORMAL; + if (!has_frame()) { // Set Window style so that we get a minimize and maximize animation when // frameless. @@ -391,11 +396,16 @@ bool NativeWindowViews::IsMinimized() { void NativeWindowViews::SetFullScreen(bool fullscreen) { #if defined(OS_WIN) // There is no native fullscreen state on Windows. - window_->SetFullscreen(fullscreen); - if (fullscreen) + if (fullscreen) { + last_window_state_ = ui::SHOW_STATE_FULLSCREEN; NotifyWindowEnterFullScreen(); - else + } else { + last_window_state_ = ui::SHOW_STATE_NORMAL; NotifyWindowLeaveFullScreen(); + } + // We set the new value after notifying, so we can handle the size event + // correctly. + window_->SetFullscreen(fullscreen); #else if (IsVisible()) window_->SetFullscreen(fullscreen); @@ -807,24 +817,8 @@ void NativeWindowViews::OnWidgetMove() { #if defined(OS_WIN) bool NativeWindowViews::ExecuteWindowsCommand(int command_id) { - // Windows uses the 4 lower order bits of |command_id| for type-specific - // information so we must exclude this when comparing. - static const int sc_mask = 0xFFF0; - if ((command_id & sc_mask) == SC_MINIMIZE) { - NotifyWindowMinimize(); - is_minimized_ = true; - } else if ((command_id & sc_mask) == SC_RESTORE) { - if (is_minimized_) - NotifyWindowRestore(); - else - NotifyWindowUnmaximize(); - is_minimized_ = false; - } else if ((command_id & sc_mask) == SC_MAXIMIZE) { - NotifyWindowMaximize(); - } else { - std::string command = AppCommandToString(command_id); - NotifyWindowExecuteWindowsCommand(command); - } + std::string command = AppCommandToString(command_id); + NotifyWindowExecuteWindowsCommand(command); return false; } #endif @@ -844,11 +838,54 @@ void NativeWindowViews::GetDevToolsWindowWMClass( #if defined(OS_WIN) bool NativeWindowViews::PreHandleMSG( UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) { - // Handle thumbar button click message. - if (message == WM_COMMAND && HIWORD(w_param) == THBN_CLICKED) - return taskbar_host_.HandleThumbarButtonEvent(LOWORD(w_param)); - else - return false; + switch (message) { + case WM_COMMAND: + // Handle thumbar button click message. + if (HIWORD(w_param) == THBN_CLICKED) + return taskbar_host_.HandleThumbarButtonEvent(LOWORD(w_param)); + return false; + case WM_SIZE: + // Handle window state change. + HandleSizeEvent(w_param, l_param); + return false; + default: + return false; + } +} + +void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) { + // Here we handle the WM_SIZE event in order to figure out what is the current + // window state and notify the user accordingly. + switch (w_param) { + case SIZE_MAXIMIZED: + last_window_state_ = ui::SHOW_STATE_MAXIMIZED; + NotifyWindowMaximize(); + break; + case SIZE_MINIMIZED: + last_window_state_ = ui::SHOW_STATE_MINIMIZED; + NotifyWindowMinimize(); + break; + case SIZE_RESTORED: + if (last_window_state_ == ui::SHOW_STATE_NORMAL) + return; + + switch (last_window_state_) { + case ui::SHOW_STATE_MAXIMIZED: + last_window_state_ = ui::SHOW_STATE_NORMAL; + NotifyWindowUnmaximize(); + break; + case ui::SHOW_STATE_MINIMIZED: + if (IsFullscreen()) { + last_window_state_ = ui::SHOW_STATE_FULLSCREEN; + NotifyWindowEnterFullScreen(); + } else { + last_window_state_ = ui::SHOW_STATE_NORMAL; + NotifyWindowRestore(); + } + break; + } + break; + } } #endif diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index 355f5bd38e..70c722c7d9 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -142,6 +142,8 @@ class NativeWindowViews : public NativeWindow, // MessageHandlerDelegate: bool PreHandleMSG( UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) override; + + void HandleSizeEvent(WPARAM w_param, LPARAM l_param); #endif // NativeWindow: @@ -178,9 +180,9 @@ class NativeWindowViews : public NativeWindow, #elif defined(OS_WIN) // Weak ref. AtomDesktopWindowTreeHostWin* atom_desktop_window_tree_host_win_; - // Records window was whether restored from minimized state or maximized - // state. - bool is_minimized_; + + ui::WindowShowState last_window_state_; + // In charge of running taskbar related APIs. TaskbarHost taskbar_host_; #endif From a0dcfc57b29ec241f7da2053fc8bf3b99383c0da Mon Sep 17 00:00:00 2001 From: My-khael Pierce Date: Mon, 28 Sep 2015 23:09:13 -0400 Subject: [PATCH 086/165] Update quick-start.md --- docs/tutorial/quick-start.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/tutorial/quick-start.md b/docs/tutorial/quick-start.md index 4ce65a1dc1..94368df09c 100644 --- a/docs/tutorial/quick-start.md +++ b/docs/tutorial/quick-start.md @@ -143,8 +143,8 @@ working as expected. ### electron-prebuilt -If you've installed `electron-prebuilt` globally with `npm`, then you need only -run the following in your app's source directory: +If you've installed `electron-prebuilt` globally with `npm`, then you will only need +to run the following in your app's source directory: ```bash electron . @@ -158,7 +158,7 @@ If you've installed it locally, then run: ### Manually Downloaded Electron Binary -If you downloaded Electron manually, you can also just use the included +If you downloaded Electron manually, you can also use the included binary to execute your app directly. #### Windows From 464134a31ab439535fe406e90428ccca6f911de9 Mon Sep 17 00:00:00 2001 From: Robo Date: Tue, 29 Sep 2015 17:47:26 +0530 Subject: [PATCH 087/165] protocol: allowing default clients to handle external unhandled protocols --- atom/browser/atom_browser_client.cc | 9 ++++ atom/browser/atom_browser_client.h | 6 +++ ...owser_resource_dispatcher_host_delegate.cc | 54 +++++++++++++++++++ ...rowser_resource_dispatcher_host_delegate.h | 29 ++++++++++ filenames.gypi | 2 + 5 files changed, 100 insertions(+) create mode 100644 atom/browser/atom_browser_resource_dispatcher_host_delegate.cc create mode 100644 atom/browser/atom_browser_resource_dispatcher_host_delegate.h diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index e45caceab0..dface840d7 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -11,6 +11,7 @@ #include "atom/browser/atom_access_token_store.h" #include "atom/browser/atom_browser_context.h" #include "atom/browser/atom_browser_main_parts.h" +#include "atom/browser/atom_browser_resource_dispatcher_host_delegate.h" #include "atom/browser/atom_quota_permission_context.h" #include "atom/browser/atom_speech_recognition_manager_delegate.h" #include "atom/browser/browser.h" @@ -30,6 +31,7 @@ #include "content/public/browser/client_certificate_delegate.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" +#include "content/public/browser/resource_dispatcher_host.h" #include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" #include "content/public/common/web_preferences.h" @@ -226,6 +228,13 @@ void AtomBrowserClient::SelectClientCertificate( delegate.Pass()); } +void AtomBrowserClient::ResourceDispatcherHostCreated() { + resource_dispatcher_host_delegate_.reset( + new AtomResourceDispatcherHostDelegate); + content::ResourceDispatcherHost::Get()->SetDelegate( + resource_dispatcher_host_delegate_.get()); +} + brightray::BrowserMainParts* AtomBrowserClient::OverrideCreateBrowserMainParts( const content::MainFunctionParams&) { v8::V8::Initialize(); // Init V8 before creating main parts. diff --git a/atom/browser/atom_browser_client.h b/atom/browser/atom_browser_client.h index a0217efede..ee4700456c 100644 --- a/atom/browser/atom_browser_client.h +++ b/atom/browser/atom_browser_client.h @@ -23,6 +23,8 @@ class SSLCertRequestInfo; namespace atom { +class AtomResourceDispatcherHostDelegate; + class AtomBrowserClient : public brightray::BrowserClient, public content::RenderProcessHostObserver { public: @@ -56,6 +58,7 @@ class AtomBrowserClient : public brightray::BrowserClient, content::WebContents* web_contents, net::SSLCertRequestInfo* cert_request_info, scoped_ptr delegate) override; + void ResourceDispatcherHostCreated() override; // brightray::BrowserClient: brightray::BrowserMainParts* OverrideCreateBrowserMainParts( @@ -68,6 +71,9 @@ class AtomBrowserClient : public brightray::BrowserClient, // pending_render_process => current_render_process. std::map pending_processes_; + scoped_ptr + resource_dispatcher_host_delegate_; + DISALLOW_COPY_AND_ASSIGN(AtomBrowserClient); }; diff --git a/atom/browser/atom_browser_resource_dispatcher_host_delegate.cc b/atom/browser/atom_browser_resource_dispatcher_host_delegate.cc new file mode 100644 index 0000000000..9e02f7cc81 --- /dev/null +++ b/atom/browser/atom_browser_resource_dispatcher_host_delegate.cc @@ -0,0 +1,54 @@ +// Copyright (c) 2015 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#include "atom/browser/atom_browser_resource_dispatcher_host_delegate.h" + +#include "atom/common/platform_util.h" +#include "content/public/browser/browser_thread.h" +#include "content/public/browser/web_contents.h" +#include "content/public/browser/render_view_host.h" +#include "net/base/escape.h" + +using content::BrowserThread; + +namespace atom { + +namespace { + +void HandleExternalProtocolInUI(const GURL& url, + int render_process_id, + int render_view_id) { + auto web_contents = content::WebContents::FromRenderViewHost( + content::RenderViewHost::FromID(render_process_id, render_view_id)); + if (!web_contents) + return; + + GURL escaped_url(net::EscapeExternalHandlerValue(url.spec())); + platform_util::OpenExternal(escaped_url); +} + +} // namespace + +AtomResourceDispatcherHostDelegate::AtomResourceDispatcherHostDelegate() { +} + +AtomResourceDispatcherHostDelegate::~AtomResourceDispatcherHostDelegate() { +} + +bool AtomResourceDispatcherHostDelegate::HandleExternalProtocol( + const GURL& url, + int render_process_id, + int render_view_id, + bool is_main_frame, + ui::PageTransition transition, + bool has_user_gesture) { + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, + base::Bind(&HandleExternalProtocolInUI, + url, + render_process_id, + render_view_id)); + return true; +} + +} // namespace atom diff --git a/atom/browser/atom_browser_resource_dispatcher_host_delegate.h b/atom/browser/atom_browser_resource_dispatcher_host_delegate.h new file mode 100644 index 0000000000..21155024c8 --- /dev/null +++ b/atom/browser/atom_browser_resource_dispatcher_host_delegate.h @@ -0,0 +1,29 @@ +// Copyright (c) 2015 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#ifndef ATOM_BROWSER_ATOM_BROWSER_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ +#define ATOM_BROWSER_ATOM_BROWSER_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ + +#include "content/public/browser/resource_dispatcher_host_delegate.h" + +namespace atom { + +class AtomResourceDispatcherHostDelegate + : public content::ResourceDispatcherHostDelegate { + public: + AtomResourceDispatcherHostDelegate(); + ~AtomResourceDispatcherHostDelegate(); + + // content::ResourceDispatcherHostDelegate: + bool HandleExternalProtocol(const GURL& url, + int render_process_id, + int render_view_id, + bool is_main_frame, + ui::PageTransition transition, + bool has_user_gesture) override; +}; + +} // namespace atom + +#endif // ATOM_BROWSER_ATOM_BROWSER_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ diff --git a/filenames.gypi b/filenames.gypi index cb6a2273ea..a571ed1caf 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -125,6 +125,8 @@ 'atom/browser/atom_browser_main_parts.h', 'atom/browser/atom_browser_main_parts_linux.cc', 'atom/browser/atom_browser_main_parts_mac.mm', + 'atom/browser/atom_browser_resource_dispatcher_host_delegate.cc', + 'atom/browser/atom_browser_resource_dispatcher_host_delegate.h', 'atom/browser/atom_javascript_dialog_manager.cc', 'atom/browser/atom_javascript_dialog_manager.h', 'atom/browser/atom_quota_permission_context.cc', From 93f58925aa2b6e0bef2143f2ca2b8122c31f17bc Mon Sep 17 00:00:00 2001 From: Plusb Preco Date: Wed, 30 Sep 2015 10:54:18 +0900 Subject: [PATCH 088/165] Improve grammar --- docs-translations/ko-KR/tutorial/quick-start.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs-translations/ko-KR/tutorial/quick-start.md b/docs-translations/ko-KR/tutorial/quick-start.md index 4a6ce6d225..3edf13cc47 100644 --- a/docs-translations/ko-KR/tutorial/quick-start.md +++ b/docs-translations/ko-KR/tutorial/quick-start.md @@ -127,31 +127,31 @@ app.on('ready', function() { 앱을 작성한 후 [어플리케이션 배포](application-distribution.md) 가이드를 따라 앱을 패키징 하고 패키징한 앱을 실행할 수 있습니다. 또한 Electron 실행파일을 다운로드 받아 바로 실행해 볼 수도 있습니다. -### electron-prebuilt +### electron-prebuilt 사용 `npm`을 통해 `electron-prebuilt` 패키지를 전역에 설치하면 간단한 명령으로 앱을 실행할 수 있습니다. -앱 디렉터리 내에서 이렇게 실행합니다: +앱 디렉터리 내에서 다음 명령으로 실행할 수 있습니다: ```bash electron . ``` -또는 앱 디렉터리 밖에서 앱 디렉터리를 입력해도 됩니다: +또는 앱 디렉터리 밖에서 앱을 실행할 수도 있습니다: ```bash electron app ``` -npm 모듈을 로컬에 설치했다면 이렇게 실행할 수 있습니다: +npm 모듈을 로컬에 설치했다면 다음 명령으로 실행할 수 있습니다: ```bash ./node_modules/.bin/electron . ``` -### 임의로 다운로드 받은 Electron +### 다운로드 받은 Electron 바이너리 사용 -만약 Electron 바이너리를 임의로 다운로드 받았다면 다음과 같이 앱 디렉터리에 놓고 실행하면 됩니다. +따로 Electron 바이너리를 다운로드 받았다면 다음 예시와 같이 실행하면 됩니다. #### Windows From 21f7316a18dd62a6753b99953ca97fdc9106faea Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 30 Sep 2015 10:56:42 +0800 Subject: [PATCH 089/165] Code cleanup --- atom/browser/atom_browser_client.cc | 2 +- ...owser_resource_dispatcher_host_delegate.cc | 54 ------------------- .../atom_resource_dispatcher_host_delegate.cc | 32 +++++++++++ ... atom_resource_dispatcher_host_delegate.h} | 7 ++- filenames.gypi | 4 +- 5 files changed, 38 insertions(+), 61 deletions(-) delete mode 100644 atom/browser/atom_browser_resource_dispatcher_host_delegate.cc create mode 100644 atom/browser/atom_resource_dispatcher_host_delegate.cc rename atom/browser/{atom_browser_resource_dispatcher_host_delegate.h => atom_resource_dispatcher_host_delegate.h} (74%) diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index dface840d7..4969ce47a6 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -11,8 +11,8 @@ #include "atom/browser/atom_access_token_store.h" #include "atom/browser/atom_browser_context.h" #include "atom/browser/atom_browser_main_parts.h" -#include "atom/browser/atom_browser_resource_dispatcher_host_delegate.h" #include "atom/browser/atom_quota_permission_context.h" +#include "atom/browser/atom_resource_dispatcher_host_delegate.h" #include "atom/browser/atom_speech_recognition_manager_delegate.h" #include "atom/browser/browser.h" #include "atom/browser/native_window.h" diff --git a/atom/browser/atom_browser_resource_dispatcher_host_delegate.cc b/atom/browser/atom_browser_resource_dispatcher_host_delegate.cc deleted file mode 100644 index 9e02f7cc81..0000000000 --- a/atom/browser/atom_browser_resource_dispatcher_host_delegate.cc +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2015 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#include "atom/browser/atom_browser_resource_dispatcher_host_delegate.h" - -#include "atom/common/platform_util.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/browser/web_contents.h" -#include "content/public/browser/render_view_host.h" -#include "net/base/escape.h" - -using content::BrowserThread; - -namespace atom { - -namespace { - -void HandleExternalProtocolInUI(const GURL& url, - int render_process_id, - int render_view_id) { - auto web_contents = content::WebContents::FromRenderViewHost( - content::RenderViewHost::FromID(render_process_id, render_view_id)); - if (!web_contents) - return; - - GURL escaped_url(net::EscapeExternalHandlerValue(url.spec())); - platform_util::OpenExternal(escaped_url); -} - -} // namespace - -AtomResourceDispatcherHostDelegate::AtomResourceDispatcherHostDelegate() { -} - -AtomResourceDispatcherHostDelegate::~AtomResourceDispatcherHostDelegate() { -} - -bool AtomResourceDispatcherHostDelegate::HandleExternalProtocol( - const GURL& url, - int render_process_id, - int render_view_id, - bool is_main_frame, - ui::PageTransition transition, - bool has_user_gesture) { - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - base::Bind(&HandleExternalProtocolInUI, - url, - render_process_id, - render_view_id)); - return true; -} - -} // namespace atom diff --git a/atom/browser/atom_resource_dispatcher_host_delegate.cc b/atom/browser/atom_resource_dispatcher_host_delegate.cc new file mode 100644 index 0000000000..46904d2ff9 --- /dev/null +++ b/atom/browser/atom_resource_dispatcher_host_delegate.cc @@ -0,0 +1,32 @@ +// Copyright (c) 2015 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#include "atom/browser/atom_resource_dispatcher_host_delegate.h" + +#include "atom/common/platform_util.h" +#include "content/public/browser/browser_thread.h" +#include "net/base/escape.h" +#include "url/gurl.h" + +using content::BrowserThread; + +namespace atom { + +AtomResourceDispatcherHostDelegate::AtomResourceDispatcherHostDelegate() { +} + +bool AtomResourceDispatcherHostDelegate::HandleExternalProtocol( + const GURL& url, + int render_process_id, + int render_view_id, + bool is_main_frame, + ui::PageTransition transition, + bool has_user_gesture) { + GURL escaped_url(net::EscapeExternalHandlerValue(url.spec())); + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, + base::Bind(base::IgnoreResult(platform_util::OpenExternal), escaped_url)); + return true; +} + +} // namespace atom diff --git a/atom/browser/atom_browser_resource_dispatcher_host_delegate.h b/atom/browser/atom_resource_dispatcher_host_delegate.h similarity index 74% rename from atom/browser/atom_browser_resource_dispatcher_host_delegate.h rename to atom/browser/atom_resource_dispatcher_host_delegate.h index 21155024c8..876554f0f9 100644 --- a/atom/browser/atom_browser_resource_dispatcher_host_delegate.h +++ b/atom/browser/atom_resource_dispatcher_host_delegate.h @@ -2,8 +2,8 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -#ifndef ATOM_BROWSER_ATOM_BROWSER_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ -#define ATOM_BROWSER_ATOM_BROWSER_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ +#ifndef ATOM_BROWSER_ATOM_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ +#define ATOM_BROWSER_ATOM_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ #include "content/public/browser/resource_dispatcher_host_delegate.h" @@ -13,7 +13,6 @@ class AtomResourceDispatcherHostDelegate : public content::ResourceDispatcherHostDelegate { public: AtomResourceDispatcherHostDelegate(); - ~AtomResourceDispatcherHostDelegate(); // content::ResourceDispatcherHostDelegate: bool HandleExternalProtocol(const GURL& url, @@ -26,4 +25,4 @@ class AtomResourceDispatcherHostDelegate } // namespace atom -#endif // ATOM_BROWSER_ATOM_BROWSER_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ +#endif // ATOM_BROWSER_ATOM_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ diff --git a/filenames.gypi b/filenames.gypi index a571ed1caf..0e7010d7a4 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -125,12 +125,12 @@ 'atom/browser/atom_browser_main_parts.h', 'atom/browser/atom_browser_main_parts_linux.cc', 'atom/browser/atom_browser_main_parts_mac.mm', - 'atom/browser/atom_browser_resource_dispatcher_host_delegate.cc', - 'atom/browser/atom_browser_resource_dispatcher_host_delegate.h', 'atom/browser/atom_javascript_dialog_manager.cc', 'atom/browser/atom_javascript_dialog_manager.h', 'atom/browser/atom_quota_permission_context.cc', 'atom/browser/atom_quota_permission_context.h', + 'atom/browser/atom_resource_dispatcher_host_delegate.cc', + 'atom/browser/atom_resource_dispatcher_host_delegate.h', 'atom/browser/atom_speech_recognition_manager_delegate.cc', 'atom/browser/atom_speech_recognition_manager_delegate.h', 'atom/browser/atom_ssl_config_service.cc', From 4fdf6ceb5170c8146a1eb37559bf7a766d803ec3 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 30 Sep 2015 16:58:37 +0800 Subject: [PATCH 090/165] Cache remote WebContents object of webview --- atom/renderer/lib/web-view/web-view.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/atom/renderer/lib/web-view/web-view.coffee b/atom/renderer/lib/web-view/web-view.coffee index 65e4501975..3a563101f0 100644 --- a/atom/renderer/lib/web-view/web-view.coffee +++ b/atom/renderer/lib/web-view/web-view.coffee @@ -46,6 +46,7 @@ class WebViewImpl # that we don't end up allocating a second guest. if @guestInstanceId guestViewInternal.destroyGuest @guestInstanceId + @webContents = null @guestInstanceId = undefined @beforeFirstNavigation = true @attributes[webViewConstants.ATTRIBUTE_PARTITION].validPartitionId = true @@ -188,6 +189,7 @@ class WebViewImpl attachWindow: (guestInstanceId) -> @guestInstanceId = guestInstanceId + @webContents = remote.getGuestWebContents @guestInstanceId return true unless @internalInstanceId guestViewInternal.attachGuest @internalInstanceId, @guestInstanceId, @buildParams() @@ -299,7 +301,7 @@ registerWebViewElement = -> createHandler = (m) -> (args...) -> internal = v8Util.getHiddenValue this, 'internal' - remote.getGuestWebContents(internal.guestInstanceId)[m] args... + internal.webContents[m] args... proto[m] = createHandler m for m in methods window.WebView = webFrame.registerEmbedderCustomElement 'webview', From 8c3116851dcdc2eee5be766a1f889d48a88ddab2 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 30 Sep 2015 17:29:38 +0800 Subject: [PATCH 091/165] Exit the process when unable to find a valid app Fixes #2583. --- atom/browser/lib/init.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/atom/browser/lib/init.coffee b/atom/browser/lib/init.coffee index 1299364d2f..454baf0b8a 100644 --- a/atom/browser/lib/init.coffee +++ b/atom/browser/lib/init.coffee @@ -64,7 +64,9 @@ for packagePath in searchPaths catch e continue -throw new Error("Unable to find a valid app") unless packageJson? +unless packageJson? + process.nextTick -> process.exit 1 + throw new Error("Unable to find a valid app") # Set application's version. app.setVersion packageJson.version if packageJson.version? From d5f81357b60092edee2694975cb646651f695220 Mon Sep 17 00:00:00 2001 From: Alexander Rusakov Date: Wed, 30 Sep 2015 17:13:20 +0300 Subject: [PATCH 092/165] remove required width and height BrowserWindowOptions --- docs/api/browser-window.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index a1870bc66a..c71cb610fc 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -24,14 +24,13 @@ You can also create a window without chrome by using [EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter). It creates a new `BrowserWindow` with native properties as set by the `options`. -Properties `width` and `height` are required. ### `new BrowserWindow(options)` `options` Object, properties: -* `width` Integer (**required**) - Window's width. -* `height` Integer (**required**) - Window's height. +* `width` Integer - Window's width. +* `height` Integer - Window's height. * `x` Integer - Window's left offset from screen. * `y` Integer - Window's top offset from screen. * `use-content-size` Boolean - The `width` and `height` would be used as web From 0fb68e8130841282d7e605d165c9d1ced84ff103 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 30 Sep 2015 23:41:23 +0800 Subject: [PATCH 093/165] Make Menu.popup accept no parameter --- atom/browser/api/lib/menu.coffee | 6 +++++- docs/api/menu.md | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/atom/browser/api/lib/menu.coffee b/atom/browser/api/lib/menu.coffee index 3595ba1fe7..f66c1568c0 100644 --- a/atom/browser/api/lib/menu.coffee +++ b/atom/browser/api/lib/menu.coffee @@ -79,7 +79,11 @@ Menu::_init = -> v8Util.setHiddenValue group[0], 'checked', true unless checked Menu::popup = (window, x, y) -> - throw new TypeError('Invalid window') unless window?.constructor is BrowserWindow + unless window?.constructor is BrowserWindow + # Shift. + y = x + x = window + window = BrowserWindow.getFocusedWindow() if x? and y? @_popupAt(window, x, y) else diff --git a/docs/api/menu.md b/docs/api/menu.md index f48b07e7e4..cabd04ca85 100644 --- a/docs/api/menu.md +++ b/docs/api/menu.md @@ -237,9 +237,9 @@ Generally, the `template` is just an array of `options` for constructing a You can also attach other fields to the element of the `template` and they will become properties of the constructed menu items. -### `Menu.popup(browserWindow[, x, y])` +### `Menu.popup([browserWindow, x, y])` -* `browserWindow` BrowserWindow +* `browserWindow` BrowserWindow (optional) * `x` Number (optional) * `y` Number (**required** if `x` is used) From 83c514001ef3b7fb0cd82f7ddcef8ad704e717c7 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 1 Oct 2015 11:14:19 +0800 Subject: [PATCH 094/165] Move devtools API to WebContents --- atom/browser/api/atom_api_web_contents.cc | 44 +++++++++++++++++--- atom/browser/api/atom_api_web_contents.h | 11 ++++- atom/browser/api/atom_api_window.cc | 32 +------------- atom/browser/api/atom_api_window.h | 5 --- atom/browser/api/lib/browser-window.coffee | 9 ++++ atom/browser/common_web_contents_delegate.cc | 25 +++++++++++ atom/browser/common_web_contents_delegate.h | 13 +++++- atom/browser/native_window.cc | 14 ------- atom/browser/native_window.h | 9 +--- atom/browser/native_window_observer.h | 5 --- atom/browser/native_window_views.cc | 12 ------ atom/browser/native_window_views.h | 7 ---- 12 files changed, 97 insertions(+), 89 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index bdeb4ed4f8..90c5a5146c 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -26,6 +26,7 @@ #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "brightray/browser/inspectable_web_contents.h" +#include "brightray/browser/inspectable_web_contents_view.h" #include "chrome/browser/printing/print_view_manager_basic.h" #include "chrome/browser/printing/print_preview_message_handler.h" #include "content/common/view_messages.h" @@ -228,6 +229,8 @@ WebContents::WebContents(v8::Isolate* isolate, AttachAsUserData(web_contents); InitWithWebContents(web_contents); + managed_web_contents()->GetView()->SetDelegate(this); + // Save the preferences in C++. base::DictionaryValue web_preferences; mate::ConvertFromV8(isolate, options.GetHandle(), &web_preferences); @@ -491,6 +494,28 @@ void WebContents::DidUpdateFaviconURL( Emit("page-favicon-updated", unique_urls); } +void WebContents::DevToolsFocused() { + Emit("devtools-focused"); +} + +void WebContents::DevToolsOpened() { + v8::Locker locker(isolate()); + v8::HandleScope handle_scope(isolate()); + auto handle = WebContents::CreateFrom( + isolate(), managed_web_contents()->GetDevToolsWebContents()); + devtools_web_contents_.Reset(isolate(), handle.ToV8()); + + Emit("devtools-opened"); +} + +void WebContents::DevToolsClosed() { + v8::Locker locker(isolate()); + v8::HandleScope handle_scope(isolate()); + devtools_web_contents_.Reset(); + + Emit("devtools-closed"); +} + bool WebContents::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(WebContents, message) @@ -698,10 +723,6 @@ void WebContents::InspectServiceWorker() { } } -v8::Local WebContents::Session(v8::Isolate* isolate) { - return v8::Local::New(isolate, session_); -} - void WebContents::HasServiceWorker( const base::Callback& callback) { auto context = GetServiceWorkerContext(web_contents()); @@ -893,6 +914,17 @@ v8::Local WebContents::GetWebPreferences(v8::Isolate* isolate) { return mate::ConvertToV8(isolate, *web_preferences->web_preferences()); } +v8::Local WebContents::Session(v8::Isolate* isolate) { + return v8::Local::New(isolate, session_); +} + +v8::Local WebContents::DevToolsWebContents(v8::Isolate* isolate) { + if (devtools_web_contents_.IsEmpty()) + return v8::Null(isolate); + else + return v8::Local::New(isolate, devtools_web_contents_); +} + mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder( v8::Isolate* isolate) { if (template_.IsEmpty()) @@ -957,7 +989,9 @@ mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder( .SetMethod("_printToPDF", &WebContents::PrintToPDF) .SetMethod("addWorkSpace", &WebContents::AddWorkSpace) .SetMethod("removeWorkSpace", &WebContents::RemoveWorkSpace) - .SetProperty("session", &WebContents::Session) + .SetProperty("session", &WebContents::Session, true) + .SetProperty("devToolsWebContents", + &WebContents::DevToolsWebContents, true) .Build()); return mate::ObjectTemplateBuilder( diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 91750ac613..fa32d812e6 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -83,7 +83,6 @@ class WebContents : public mate::TrackableObject, void DisableDeviceEmulation(); void InspectElement(int x, int y); void InspectServiceWorker(); - v8::Local Session(v8::Isolate* isolate); void HasServiceWorker(const base::Callback&); void UnregisterServiceWorker(const base::Callback&); void SetAudioMuted(bool muted); @@ -135,6 +134,10 @@ class WebContents : public mate::TrackableObject, // Returns the web preferences of current WebContents. v8::Local GetWebPreferences(v8::Isolate* isolate); + // Properties. + v8::Local Session(v8::Isolate* isolate); + v8::Local DevToolsWebContents(v8::Isolate* isolate); + protected: explicit WebContents(content::WebContents* web_contents); WebContents(v8::Isolate* isolate, const mate::Dictionary& options); @@ -218,6 +221,11 @@ class WebContents : public mate::TrackableObject, void PluginCrashed(const base::FilePath& plugin_path, base::ProcessId plugin_pid) override; + // brightray::InspectableWebContentsViewDelegate: + void DevToolsFocused() override; + void DevToolsOpened() override; + void DevToolsClosed() override; + private: enum Type { BROWSER_WINDOW, // Used by BrowserWindow. @@ -237,6 +245,7 @@ class WebContents : public mate::TrackableObject, IPC::Message* message); v8::Global session_; + v8::Global devtools_web_contents_; scoped_ptr guest_delegate_; diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index 4d866d1850..7536c70876 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -184,28 +184,6 @@ void Window::OnRendererResponsive() { Emit("responsive"); } -void Window::OnDevToolsFocus() { - Emit("devtools-focused"); -} - -void Window::OnDevToolsOpened() { - v8::Locker locker(isolate()); - v8::HandleScope handle_scope(isolate()); - auto handle = WebContents::CreateFrom( - isolate(), api_web_contents_->GetDevToolsWebContents()); - devtools_web_contents_.Reset(isolate(), handle.ToV8()); - - Emit("devtools-opened"); -} - -void Window::OnDevToolsClosed() { - v8::Locker locker(isolate()); - v8::HandleScope handle_scope(isolate()); - devtools_web_contents_.Reset(); - - Emit("devtools-closed"); -} - void Window::OnExecuteWindowsCommand(const std::string& command_name) { Emit("app-command", command_name); } @@ -540,13 +518,6 @@ v8::Local Window::WebContents(v8::Isolate* isolate) { return v8::Local::New(isolate, web_contents_); } -v8::Local Window::DevToolsWebContents(v8::Isolate* isolate) { - if (devtools_web_contents_.IsEmpty()) - return v8::Null(isolate); - else - return v8::Local::New(isolate, devtools_web_contents_); -} - // static void Window::BuildPrototype(v8::Isolate* isolate, v8::Local prototype) { @@ -618,8 +589,7 @@ void Window::BuildPrototype(v8::Isolate* isolate, &Window::ShowDefinitionForSelection) #endif .SetProperty("id", &Window::ID, true) - .SetProperty("webContents", &Window::WebContents, true) - .SetProperty("devToolsWebContents", &Window::DevToolsWebContents, true); + .SetProperty("webContents", &Window::WebContents, true); } } // namespace api diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index d60bf0d87e..8cf26fe58e 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -69,9 +69,6 @@ class Window : public mate::TrackableObject, void OnWindowLeaveHtmlFullScreen() override; void OnRendererUnresponsive() override; void OnRendererResponsive() override; - void OnDevToolsFocus() override; - void OnDevToolsOpened() override; - void OnDevToolsClosed() override; void OnExecuteWindowsCommand(const std::string& command_name) override; // mate::Wrappable: @@ -150,10 +147,8 @@ class Window : public mate::TrackableObject, int32_t ID() const; v8::Local WebContents(v8::Isolate* isolate); - v8::Local DevToolsWebContents(v8::Isolate* isolate); v8::Global web_contents_; - v8::Global devtools_web_contents_; v8::Global menu_; api::WebContents* api_web_contents_; diff --git a/atom/browser/api/lib/browser-window.coffee b/atom/browser/api/lib/browser-window.coffee index 2a92cfc55f..6ffba50d34 100644 --- a/atom/browser/api/lib/browser-window.coffee +++ b/atom/browser/api/lib/browser-window.coffee @@ -48,6 +48,15 @@ BrowserWindow::_init = -> # Notify the creation of the window. app.emit 'browser-window-created', {}, this + # Be compatible with old APIs. + @webContents.on 'devtools-focused', => @emit 'devtools-focused' + @webContents.on 'devtools-opened', => @emit 'devtools-opened' + @webContents.on 'devtools-closed', => @emit 'devtools-closed' + Object.defineProperty this, 'devToolsWebContents', + enumerable: true, + configurable: false, + get: -> @webContents.devToolsWebContents + BrowserWindow.getFocusedWindow = -> windows = BrowserWindow.getAllWindows() return window for window in windows when window.isFocused() diff --git a/atom/browser/common_web_contents_delegate.cc b/atom/browser/common_web_contents_delegate.cc index 3cef7c6d68..518d4f650a 100644 --- a/atom/browser/common_web_contents_delegate.cc +++ b/atom/browser/common_web_contents_delegate.cc @@ -21,6 +21,14 @@ #include "content/public/browser/render_view_host.h" #include "storage/browser/fileapi/isolated_context.h" +#if defined(TOOLKIT_VIEWS) +#include "atom/browser/native_window_views.h" +#endif + +#if defined(USE_X11) +#include "atom/browser/browser.h" +#endif + using content::BrowserThread; namespace atom { @@ -355,6 +363,23 @@ void CommonWebContentsDelegate::OnDevToolsAppendToFile( "DevToolsAPI.appendedToURL", &url_value, nullptr, nullptr); } +#if defined(TOOLKIT_VIEWS) +gfx::ImageSkia CommonWebContentsDelegate::GetDevToolsWindowIcon() { + if (!owner_window()) + return gfx::ImageSkia(); + return static_cast(static_cast( + owner_window()))->GetWindowAppIcon(); +} +#endif + +#if defined(USE_X11) +void CommonWebContentsDelegate::GetDevToolsWindowWMClass( + std::string* name, std::string* class_name) { + *class_name = Browser::Get()->GetName(); + *name = base::StringToLowerASCII(*class_name); +} +#endif + void CommonWebContentsDelegate::SetHtmlApiFullscreen(bool enter_fullscreen) { // Window is already in fullscreen mode, save the state. if (enter_fullscreen && owner_window_->IsFullscreen()) { diff --git a/atom/browser/common_web_contents_delegate.h b/atom/browser/common_web_contents_delegate.h index 495b5501a0..3a5be180dc 100644 --- a/atom/browser/common_web_contents_delegate.h +++ b/atom/browser/common_web_contents_delegate.h @@ -12,6 +12,7 @@ #include "brightray/browser/default_web_contents_delegate.h" #include "brightray/browser/inspectable_web_contents_impl.h" #include "brightray/browser/inspectable_web_contents_delegate.h" +#include "brightray/browser/inspectable_web_contents_view_delegate.h" namespace atom { @@ -21,7 +22,8 @@ class WebDialogHelper; class CommonWebContentsDelegate : public brightray::DefaultWebContentsDelegate, - public brightray::InspectableWebContentsDelegate { + public brightray::InspectableWebContentsDelegate, + public brightray::InspectableWebContentsViewDelegate { public: CommonWebContentsDelegate(); virtual ~CommonWebContentsDelegate(); @@ -86,6 +88,15 @@ class CommonWebContentsDelegate void DevToolsRemoveFileSystem( const base::FilePath& file_system_path) override; + // brightray::InspectableWebContentsViewDelegate: +#if defined(TOOLKIT_VIEWS) + gfx::ImageSkia GetDevToolsWindowIcon() override; +#endif +#if defined(USE_X11) + void GetDevToolsWindowWMClass( + std::string* name, std::string* class_name) override; +#endif + private: // Callback for when DevToolsSaveToFile has completed. void OnDevToolsSaveToFile(const std::string& url); diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index c3620bba70..b3ac71d210 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -76,8 +76,6 @@ NativeWindow::NativeWindow( aspect_ratio_(0.0), inspectable_web_contents_(inspectable_web_contents), weak_factory_(this) { - inspectable_web_contents->GetView()->SetDelegate(this); - options.Get(switches::kFrame, &has_frame_); options.Get(switches::kTransparent, &transparent_); options.Get(switches::kEnableLargerThanScreen, &enable_larger_than_screen_); @@ -418,18 +416,6 @@ void NativeWindow::NotifyWindowExecuteWindowsCommand( OnExecuteWindowsCommand(command)); } -void NativeWindow::DevToolsFocused() { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnDevToolsFocus()); -} - -void NativeWindow::DevToolsOpened() { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnDevToolsOpened()); -} - -void NativeWindow::DevToolsClosed() { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnDevToolsClosed()); -} - void NativeWindow::RenderViewCreated( content::RenderViewHost* render_view_host) { if (!transparent_) diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index 5c8d8c73b0..6350ad247c 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -15,7 +15,6 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" -#include "brightray/browser/inspectable_web_contents_view_delegate.h" #include "content/public/browser/readback_types.h" #include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_user_data.h" @@ -50,8 +49,7 @@ namespace atom { struct DraggableRegion; -class NativeWindow : public content::WebContentsObserver, - public brightray::InspectableWebContentsViewDelegate { +class NativeWindow : public content::WebContentsObserver { public: using CapturePageCallback = base::Callback; @@ -234,11 +232,6 @@ class NativeWindow : public content::WebContentsObserver, NativeWindow(brightray::InspectableWebContents* inspectable_web_contents, const mate::Dictionary& options); - // brightray::InspectableWebContentsViewDelegate: - void DevToolsFocused() override; - void DevToolsOpened() override; - void DevToolsClosed() override; - // content::WebContentsObserver: void RenderViewCreated(content::RenderViewHost* render_view_host) override; void BeforeUnloadDialogCancelled() override; diff --git a/atom/browser/native_window_observer.h b/atom/browser/native_window_observer.h index 5b0a0c56b3..33ab1ecb6b 100644 --- a/atom/browser/native_window_observer.h +++ b/atom/browser/native_window_observer.h @@ -55,11 +55,6 @@ class NativeWindowObserver { virtual void OnWindowEnterHtmlFullScreen() {} virtual void OnWindowLeaveHtmlFullScreen() {} - // Redirect devtools events. - virtual void OnDevToolsFocus() {} - virtual void OnDevToolsOpened() {} - virtual void OnDevToolsClosed() {} - // Called when renderer is hung. virtual void OnRendererUnresponsive() {} diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 34c2f62263..0fa2a99c27 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -823,18 +823,6 @@ bool NativeWindowViews::ExecuteWindowsCommand(int command_id) { } #endif -gfx::ImageSkia NativeWindowViews::GetDevToolsWindowIcon() { - return GetWindowAppIcon(); -} - -#if defined(USE_X11) -void NativeWindowViews::GetDevToolsWindowWMClass( - std::string* name, std::string* class_name) { - *class_name = Browser::Get()->GetName(); - *name = base::StringToLowerASCII(*class_name); -} -#endif - #if defined(OS_WIN) bool NativeWindowViews::PreHandleMSG( UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) { diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index 70c722c7d9..71e122d381 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -131,13 +131,6 @@ class NativeWindowViews : public NativeWindow, bool ExecuteWindowsCommand(int command_id) override; #endif - // brightray::InspectableWebContentsViewDelegate: - gfx::ImageSkia GetDevToolsWindowIcon() override; -#if defined(USE_X11) - void GetDevToolsWindowWMClass( - std::string* name, std::string* class_name) override; -#endif - #if defined(OS_WIN) // MessageHandlerDelegate: bool PreHandleMSG( From f2c7943d42eb83ca81c73c619ac9e727744b8967 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 1 Oct 2015 13:45:59 +0800 Subject: [PATCH 095/165] Add WebContents.getOwnerBrowserWindow --- atom/browser/api/atom_api_web_contents.cc | 9 +++++++++ atom/browser/api/atom_api_web_contents.h | 3 +++ atom/browser/api/atom_api_window.cc | 11 +++++++++++ atom/browser/api/atom_api_window.h | 4 ++++ atom/browser/native_window.h | 4 +++- 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 90c5a5146c..bbe244da7e 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -7,6 +7,7 @@ #include #include "atom/browser/api/atom_api_session.h" +#include "atom/browser/api/atom_api_window.h" #include "atom/browser/atom_browser_client.h" #include "atom/browser/atom_browser_context.h" #include "atom/browser/atom_browser_main_parts.h" @@ -914,6 +915,13 @@ v8::Local WebContents::GetWebPreferences(v8::Isolate* isolate) { return mate::ConvertToV8(isolate, *web_preferences->web_preferences()); } +v8::Local WebContents::GetOwnerBrowserWindow() { + if (owner_window()) + return Window::From(isolate(), owner_window()); + else + return v8::Null(isolate()); +} + v8::Local WebContents::Session(v8::Isolate* isolate) { return v8::Local::New(isolate, session_); } @@ -981,6 +989,7 @@ mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder( .SetMethod("setAllowTransparency", &WebContents::SetAllowTransparency) .SetMethod("isGuest", &WebContents::IsGuest) .SetMethod("getWebPreferences", &WebContents::GetWebPreferences) + .SetMethod("getOwnerBrowserWindow", &WebContents::GetOwnerBrowserWindow) .SetMethod("hasServiceWorker", &WebContents::HasServiceWorker) .SetMethod("unregisterServiceWorker", &WebContents::UnregisterServiceWorker) diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index fa32d812e6..bbf331848c 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -134,6 +134,9 @@ class WebContents : public mate::TrackableObject, // Returns the web preferences of current WebContents. v8::Local GetWebPreferences(v8::Isolate* isolate); + // Returns the owner window. + v8::Local GetOwnerBrowserWindow(); + // Properties. v8::Local Session(v8::Isolate* isolate); v8::Local DevToolsWebContents(v8::Isolate* isolate); diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index 7536c70876..c4beaace67 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -92,6 +92,7 @@ Window::Window(v8::Isolate* isolate, const mate::Dictionary& options) { web_contents->SetOwnerWindow(window_.get()); window_->InitFromOptions(options); window_->AddObserver(this); + AttachAsUserData(window_.get()); } Window::~Window() { @@ -592,6 +593,16 @@ void Window::BuildPrototype(v8::Isolate* isolate, .SetProperty("webContents", &Window::WebContents, true); } +// static +v8::Local Window::From(v8::Isolate* isolate, + NativeWindow* native_window) { + auto existing = TrackableObject::FromWrappedClass(isolate, native_window); + if (existing) + return existing->GetWrapper(isolate); + else + return v8::Null(isolate); +} + } // namespace api } // namespace atom diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index 8cf26fe58e..d2886b5fac 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -43,6 +43,10 @@ class Window : public mate::TrackableObject, static void BuildPrototype(v8::Isolate* isolate, v8::Local prototype); + // Returns the BrowserWindow object from |native_window|. + static v8::Local From(v8::Isolate* isolate, + NativeWindow* native_window); + NativeWindow* window() const { return window_.get(); } protected: diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index 6350ad247c..751644e459 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -15,6 +15,7 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" +#include "base/supports_user_data.h" #include "content/public/browser/readback_types.h" #include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_user_data.h" @@ -49,7 +50,8 @@ namespace atom { struct DraggableRegion; -class NativeWindow : public content::WebContentsObserver { +class NativeWindow : public base::SupportsUserData, + public content::WebContentsObserver { public: using CapturePageCallback = base::Callback; From 1045bbc861186a566f0d9ed2b4768a7fda23be3f Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 1 Oct 2015 14:08:33 +0800 Subject: [PATCH 096/165] Do not enumerate windows in remote.getCurrentWindow --- atom/browser/lib/rpc-server.coffee | 11 ++--------- atom/renderer/api/lib/remote.coffee | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/atom/browser/lib/rpc-server.coffee b/atom/browser/lib/rpc-server.coffee index 0a28d350e8..149b208b40 100644 --- a/atom/browser/lib/rpc-server.coffee +++ b/atom/browser/lib/rpc-server.coffee @@ -106,16 +106,9 @@ ipc.on 'ATOM_BROWSER_GLOBAL', (event, name) -> catch e event.returnValue = errorToMeta e -ipc.on 'ATOM_BROWSER_CURRENT_WINDOW', (event, guestInstanceId) -> +ipc.on 'ATOM_BROWSER_CURRENT_WINDOW', (event) -> try - BrowserWindow = require 'browser-window' - if guestInstanceId? - guestViewManager = require './guest-view-manager' - window = BrowserWindow.fromWebContents guestViewManager.getEmbedder(guestInstanceId) - else - window = BrowserWindow.fromWebContents event.sender - window = BrowserWindow.fromDevToolsWebContents event.sender unless window? - event.returnValue = valueToMeta event.sender, window + event.returnValue = valueToMeta event.sender, event.sender.getOwnerBrowserWindow() catch e event.returnValue = errorToMeta e diff --git a/atom/renderer/api/lib/remote.coffee b/atom/renderer/api/lib/remote.coffee index 00d22ab8cf..1f17cf3400 100644 --- a/atom/renderer/api/lib/remote.coffee +++ b/atom/renderer/api/lib/remote.coffee @@ -130,7 +130,7 @@ exports.require = (module) -> windowCache = null exports.getCurrentWindow = -> return windowCache if windowCache? - meta = ipc.sendSync 'ATOM_BROWSER_CURRENT_WINDOW', process.guestInstanceId + meta = ipc.sendSync 'ATOM_BROWSER_CURRENT_WINDOW' windowCache = metaToValue meta # Get current WebContents object. From ca40ea8e2fc179668b8d9c8b429a94cb0f740781 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 1 Oct 2015 14:41:01 +0800 Subject: [PATCH 097/165] Inherit owner window in devtools --- atom/browser/api/atom_api_web_contents.cc | 5 +++++ atom/browser/common_web_contents_delegate.cc | 6 +++++- atom/browser/common_web_contents_delegate.h | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index bbe244da7e..f6433ca635 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -506,6 +506,11 @@ void WebContents::DevToolsOpened() { isolate(), managed_web_contents()->GetDevToolsWebContents()); devtools_web_contents_.Reset(isolate(), handle.ToV8()); + // Inherit owner window in devtools. + if (owner_window()) + handle->SetOwnerWindow(managed_web_contents()->GetDevToolsWebContents(), + owner_window()); + Emit("devtools-opened"); } diff --git a/atom/browser/common_web_contents_delegate.cc b/atom/browser/common_web_contents_delegate.cc index 518d4f650a..8b7a159dd7 100644 --- a/atom/browser/common_web_contents_delegate.cc +++ b/atom/browser/common_web_contents_delegate.cc @@ -136,7 +136,11 @@ void CommonWebContentsDelegate::InitWithWebContents( } void CommonWebContentsDelegate::SetOwnerWindow(NativeWindow* owner_window) { - content::WebContents* web_contents = GetWebContents(); + SetOwnerWindow(GetWebContents(), owner_window); +} + +void CommonWebContentsDelegate::SetOwnerWindow( + content::WebContents* web_contents, NativeWindow* owner_window) { owner_window_ = owner_window->GetWeakPtr(); NativeWindowRelay* relay = new NativeWindowRelay(owner_window_); web_contents->SetUserData(relay->key, relay); diff --git a/atom/browser/common_web_contents_delegate.h b/atom/browser/common_web_contents_delegate.h index 3a5be180dc..ee18f36660 100644 --- a/atom/browser/common_web_contents_delegate.h +++ b/atom/browser/common_web_contents_delegate.h @@ -34,6 +34,8 @@ class CommonWebContentsDelegate // Set the window as owner window. void SetOwnerWindow(NativeWindow* owner_window); + void SetOwnerWindow(content::WebContents* web_contents, + NativeWindow* owner_window); // Destroy the managed InspectableWebContents object. void DestroyWebContents(); From ef4014e14b9344204eb0f9636cbcf0af0c284cc2 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 1 Oct 2015 14:46:33 +0800 Subject: [PATCH 098/165] Don't show open dialog as sheet in devtools --- atom/renderer/lib/inspector.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/renderer/lib/inspector.coffee b/atom/renderer/lib/inspector.coffee index 126f68f960..5f08a2acf8 100644 --- a/atom/renderer/lib/inspector.coffee +++ b/atom/renderer/lib/inspector.coffee @@ -44,7 +44,7 @@ createMenu = (x, y, items, document) -> showFileChooserDialog = (callback) -> remote = require 'remote' dialog = remote.require 'dialog' - files = dialog.showOpenDialog remote.getCurrentWindow(), null + files = dialog.showOpenDialog {} callback pathToHtml5FileObject files[0] if files? pathToHtml5FileObject = (path) -> From af971a46bd125ac778faa27e2a6a6eb52d1f77a1 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 1 Oct 2015 16:30:31 +0800 Subject: [PATCH 099/165] docs: Move devtools methods to WebContents --- docs/api/browser-window.md | 57 -------------------------------------- docs/api/web-contents.md | 57 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 57 deletions(-) diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index c71cb610fc..1a2870f205 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -231,18 +231,6 @@ Emitted when the window enters full screen state triggered by html api. Emitted when the window leaves full screen state triggered by html api. -### Event: 'devtools-opened' - -Emitted when DevTools is opened. - -### Event: 'devtools-closed' - -Emitted when DevTools is closed. - -### Event: 'devtools-focused' - -Emitted when DevTools is focused / opened. - ### Event: 'app-command': Emitted when an [App Command](https://msdn.microsoft.com/en-us/library/windows/desktop/ms646275(v=vs.85).aspx) @@ -317,16 +305,6 @@ operations will be done via it. See the [`webContents` documentation](web-contents.md) for its methods and events. -**Note:** Users should never store this object because it may become `null` -when the renderer process (web page) has crashed. - -### `win.devToolsWebContents` - -Get the `WebContents` of DevTools for this window. - -**Note:** Users should never store this object because it may become `null` -when the DevTools has been closed. - ### `win.id` The unique ID of this window. @@ -595,41 +573,6 @@ bar will become grey when set to `true`. Whether the window's document has been edited. -### `win.openDevTools([options])` - -* `options` Object (optional). Properties: - * `detach` Boolean - opens DevTools in a new window - -Opens the developer tools. - -### `win.closeDevTools()` - -Closes the developer tools. - -### `win.isDevToolsOpened()` - -Returns whether the developer tools are opened. - -### `win.toggleDevTools()` - -Toggles the developer tools. - -### `win.isDevToolsFocused()` - -Returns whether the developer tools is focused. - -### `win.inspectElement(x, y)` - -* `x` Integer -* `y` Integer - -Starts inspecting element at position (`x`, `y`). - -### `win.inspectServiceWorker()` - -Opens the developer tools for the service worker context present in the web -contents. - ### `win.focusOnWebView()` ### `win.blurWebView()` diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 7cbf8d93ba..08670bad9d 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -154,6 +154,18 @@ Emitted when a plugin process has crashed. Emitted when `webContents` is destroyed. +### Event: 'devtools-opened' + +Emitted when DevTools is opened. + +### Event: 'devtools-closed' + +Emitted when DevTools is closed. + +### Event: 'devtools-focused' + +Emitted when DevTools is focused / opened. + ## Instance Methods The `webContents` object has the following instance methods: @@ -441,6 +453,40 @@ Adds the specified path to DevTools workspace. Removes the specified path from DevTools workspace. +### `webContents.openDevTools([options])` + +* `options` Object (optional). Properties: + * `detach` Boolean - opens DevTools in a new window + +Opens the developer tools. + +### `webContents.closeDevTools()` + +Closes the developer tools. + +### `webContents.isDevToolsOpened()` + +Returns whether the developer tools are opened. + +### `webContents.toggleDevTools()` + +Toggles the developer tools. + +### `webContents.isDevToolsFocused()` + +Returns whether the developer tools is focused. + +### `webContents.inspectElement(x, y)` + +* `x` Integer +* `y` Integer + +Starts inspecting element at position (`x`, `y`). + +### `webContents.inspectServiceWorker()` + +Opens the developer tools for the service worker context. + ### `webContents.send(channel[, args...])` * `channel` String @@ -574,3 +620,14 @@ is in 32bit ARGB format). ### `webContents.endFrameSubscription()` 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. From 6082b83a6522cd68ca5934f4bd50e69461cd1838 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 1 Oct 2015 17:03:45 +0800 Subject: [PATCH 100/165] Update brightray for #2851 --- vendor/brightray | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/brightray b/vendor/brightray index 75f7d3fd88..6cbb4ad4d1 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 75f7d3fd88ae60026a0717b93e3bf7182f827dc3 +Subproject commit 6cbb4ad4d173d25b66eecf675c2b25ee64196429 From 63c065299a61a4133f801d08dfd2c0f3381d92c4 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 1 Oct 2015 17:31:44 +0800 Subject: [PATCH 101/165] Update brightray for atom/brightray#147 --- vendor/brightray | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/brightray b/vendor/brightray index 6cbb4ad4d1..a4b793cf32 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 6cbb4ad4d173d25b66eecf675c2b25ee64196429 +Subproject commit a4b793cf32ff550f7fff87148464d4d02afa880b From 8d61531f4e344a9244305e5d0832d8cf536bbfb2 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 1 Oct 2015 17:46:11 +0800 Subject: [PATCH 102/165] Revert #2879 --- atom/browser/native_window.cc | 7 +------ atom/browser/native_window_mac.mm | 4 ---- atom/browser/native_window_views.cc | 3 --- 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index b3ac71d210..80a7d1347f 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -158,13 +158,8 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) { // Then show it. bool show = true; options.Get(switches::kShow, &show); - if (show) { + if (show) Show(); - } else { - // When RenderView is created it sets to visible, this is to prevent - // breaking the visibility API. - web_contents()->WasHidden(); - } } void NativeWindow::SetSize(const gfx::Size& size) { diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index f0a685e4d9..3e8dab2133 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -470,8 +470,6 @@ bool NativeWindowMac::IsFocused() { } void NativeWindowMac::Show() { - web_contents()->WasShown(); - // This method is supposed to put focus on window, however if the app does not // have focus then "makeKeyAndOrderFront" will only show the window. [NSApp activateIgnoringOtherApps:YES]; @@ -480,13 +478,11 @@ void NativeWindowMac::Show() { } void NativeWindowMac::ShowInactive() { - web_contents()->WasShown(); [window_ orderFrontRegardless]; } void NativeWindowMac::Hide() { [window_ orderOut:nil]; - web_contents()->WasHidden(); } bool NativeWindowMac::IsVisible() { diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 0fa2a99c27..e9db97e195 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -343,17 +343,14 @@ bool NativeWindowViews::IsFocused() { } void NativeWindowViews::Show() { - web_contents()->WasShown(); window_->native_widget_private()->ShowWithWindowState(GetRestoredState()); } void NativeWindowViews::ShowInactive() { - web_contents()->WasShown(); window_->ShowInactive(); } void NativeWindowViews::Hide() { - window_->Hide(); web_contents()->WasHidden(); } From 5d9e4fc8fd98360e22ce4725174c07592e5e3ad0 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 1 Oct 2015 18:39:35 +0800 Subject: [PATCH 103/165] Override document.hidden --- atom/renderer/lib/override.coffee | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/atom/renderer/lib/override.coffee b/atom/renderer/lib/override.coffee index 5cffdd486d..93cf8b8357 100644 --- a/atom/renderer/lib/override.coffee +++ b/atom/renderer/lib/override.coffee @@ -122,3 +122,7 @@ window.history.go = (offset) -> sendHistoryOperation 'goToOffset', offset Object.defineProperty window.history, 'length', get: -> getHistoryOperation 'length' + +# Make document.hidden return the correct value. +Object.defineProperty document, 'hidden', + get: -> !remote.getCurrentWindow().isVisible() From c1fba9b4a5c90a7afe001a02629be703c4d6a1c1 Mon Sep 17 00:00:00 2001 From: Plusb Preco Date: Fri, 2 Oct 2015 12:46:42 +0900 Subject: [PATCH 104/165] Update as upstream --- docs-translations/ko-KR/api/menu.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs-translations/ko-KR/api/menu.md b/docs-translations/ko-KR/api/menu.md index a8ac499f57..56b7f4a198 100644 --- a/docs-translations/ko-KR/api/menu.md +++ b/docs-translations/ko-KR/api/menu.md @@ -229,11 +229,11 @@ Menu.setApplicationMenu(menu); 또한 `template`에는 다른 속성도 추가할 수 있으며 메뉴가 만들어질 때 해당 메뉴 아이템의 프로퍼티로 변환됩니다. -### `Menu.popup(browserWindow[, x, y])` +### `Menu.popup([browserWindow, x, y])` -* `browserWindow` BrowserWindow +* `browserWindow` BrowserWindow (optional) * `x` Number (optional) -* `y` Number (만약 `x`를 지정했을 경우 `y`도 필수로 지정해야 합니다) +* `y` Number (만약 `x`를 지정했을 경우 반드시 `y`도 지정해야 합니다) 메뉴를 `browserWindow` 내부 팝업으로 표시합니다. 옵션으로 메뉴를 표시할 `(x,y)` 좌표를 지정할 수 있습니다. From 9eb7c3ac2d6653834803f91ad3f643f30df9eab5 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 2 Oct 2015 13:41:50 +0800 Subject: [PATCH 105/165] Bump v0.33.4 --- atom.gyp | 2 +- atom/browser/resources/mac/Info.plist | 2 +- atom/browser/resources/win/atom.rc | 8 ++++---- atom/common/atom_version.h | 2 +- vendor/brightray | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/atom.gyp b/atom.gyp index 42069ea846..b3c9e117a5 100644 --- a/atom.gyp +++ b/atom.gyp @@ -4,7 +4,7 @@ 'product_name%': 'Electron', 'company_name%': 'GitHub, Inc', 'company_abbr%': 'github', - 'version%': '0.33.3', + 'version%': '0.33.4', }, 'includes': [ 'filenames.gypi', diff --git a/atom/browser/resources/mac/Info.plist b/atom/browser/resources/mac/Info.plist index eb39cb35f9..b1b905a433 100644 --- a/atom/browser/resources/mac/Info.plist +++ b/atom/browser/resources/mac/Info.plist @@ -17,7 +17,7 @@ CFBundleIconFile atom.icns CFBundleVersion - 0.33.3 + 0.33.4 LSMinimumSystemVersion 10.8.0 NSMainNibFile diff --git a/atom/browser/resources/win/atom.rc b/atom/browser/resources/win/atom.rc index 6fba6cf806..6d900b0ea0 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,33,3,0 - PRODUCTVERSION 0,33,3,0 + FILEVERSION 0,33,4,0 + PRODUCTVERSION 0,33,4,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -74,12 +74,12 @@ BEGIN BEGIN VALUE "CompanyName", "GitHub, Inc." VALUE "FileDescription", "Electron" - VALUE "FileVersion", "0.33.3" + VALUE "FileVersion", "0.33.4" VALUE "InternalName", "electron.exe" VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved." VALUE "OriginalFilename", "electron.exe" VALUE "ProductName", "Electron" - VALUE "ProductVersion", "0.33.3" + VALUE "ProductVersion", "0.33.4" VALUE "SquirrelAwareVersion", "1" END END diff --git a/atom/common/atom_version.h b/atom/common/atom_version.h index 4f24034754..998e430881 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 33 -#define ATOM_PATCH_VERSION 3 +#define ATOM_PATCH_VERSION 4 #define ATOM_VERSION_IS_RELEASE 1 diff --git a/vendor/brightray b/vendor/brightray index a4b793cf32..6cbb4ad4d1 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit a4b793cf32ff550f7fff87148464d4d02afa880b +Subproject commit 6cbb4ad4d173d25b66eecf675c2b25ee64196429 From 0ecf077590ef64e88a31fff81fe50590a8c42c82 Mon Sep 17 00:00:00 2001 From: Jhen Date: Fri, 2 Oct 2015 21:53:55 +0800 Subject: [PATCH 106/165] Fix typo for docs/api/menu-item.md --- docs/api/menu-item.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/menu-item.md b/docs/api/menu-item.md index 89524d9f23..37079233fc 100644 --- a/docs/api/menu-item.md +++ b/docs/api/menu-item.md @@ -1,6 +1,6 @@ # MenuItem -The `menu-item` module allows you to add items to an application or content +The `menu-item` module allows you to add items to an application or context [`menu`](menu.md). See [`menu`](menu.md) for examples. From 64640afc20bba0e6474a3bb2b61c0d72a379185c Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 2 Oct 2015 17:41:57 -0700 Subject: [PATCH 107/165] supported operating system list Proposed fix for issue #2964 --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 0bf29fbc3e..ccfc9cf200 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,12 @@ npm install electron-prebuilt --save-dev - [China](https://npm.taobao.org/mirrors/electron) +## Supported Operating Systems + +- Ubuntu: 14.04 and higher +- Mac: OS X 10.8.0 and higher +- Windows: Win7 or higher + ## Documentation Guides and the API reference are located in the @@ -53,6 +59,7 @@ contains documents describing how to build and contribute to Electron. - [Simplified Chinese](https://github.com/atom/electron/tree/master/docs-translations/zh-CN) - [Traditional Chinese](https://github.com/atom/electron/tree/master/docs-translations/zh-TW) + ## Community You can ask questions and interact with the community in the following From 651009a1dc4cfe901a24ca829413719e906fb00e Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 3 Oct 2015 13:42:34 +0800 Subject: [PATCH 108/165] docs: Add "Supported Platforms" --- README.md | 15 ++++----------- docs/README.md | 1 + docs/tutorial/supported-platforms.md | 23 +++++++++++++++++++++++ 3 files changed, 28 insertions(+), 11 deletions(-) create mode 100644 docs/tutorial/supported-platforms.md diff --git a/README.md b/README.md index ccfc9cf200..fa122c9b6c 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Follow [@ElectronJS](https://twitter.com/electronjs) on Twitter for important announcements. This project adheres to the [Contributor Covenant 1.2](http://contributor-covenant.org/version/1/2/0). -By participating, you are expected to uphold this code. Please report +By participating, you are expected to uphold this code. Please report unacceptable behavior to atom@github.com. ## Downloads @@ -38,12 +38,6 @@ npm install electron-prebuilt --save-dev - [China](https://npm.taobao.org/mirrors/electron) -## Supported Operating Systems - -- Ubuntu: 14.04 and higher -- Mac: OS X 10.8.0 and higher -- Windows: Win7 or higher - ## Documentation Guides and the API reference are located in the @@ -59,15 +53,14 @@ contains documents describing how to build and contribute to Electron. - [Simplified Chinese](https://github.com/atom/electron/tree/master/docs-translations/zh-CN) - [Traditional Chinese](https://github.com/atom/electron/tree/master/docs-translations/zh-TW) - ## Community -You can ask questions and interact with the community in the following +You can ask questions and interact with the community in the following locations: -- [`electron`](http://discuss.atom.io/category/electron) category on the Atom +- [`electron`](http://discuss.atom.io/category/electron) category on the Atom forums - `#atom-shell` channel on Freenode - [`Atom`](http://atom-slack.herokuapp.com/) channel on Slack -Check out [awesome-electron](https://github.com/sindresorhus/awesome-electron) +Check out [awesome-electron](https://github.com/sindresorhus/awesome-electron) for a community maintained list of useful example apps, tools and resources. diff --git a/docs/README.md b/docs/README.md index b2f95fe4b5..eb6e9d6e36 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,5 +1,6 @@ ## Guides +* [Supported Platforms](tutorial/supported-platforms.md) * [Application Distribution](tutorial/application-distribution.md) * [Application Packaging](tutorial/application-packaging.md) * [Using Native Node Modules](tutorial/using-native-node-modules.md) diff --git a/docs/tutorial/supported-platforms.md b/docs/tutorial/supported-platforms.md new file mode 100644 index 0000000000..8b795769a8 --- /dev/null +++ b/docs/tutorial/supported-platforms.md @@ -0,0 +1,23 @@ +# Supported Platforms + +Following platforms are supported by Electron: + +### OS X + +Only 64bit binaries are provided for OS X, and the minimum OS X version supported is OS X 10.8. + +### Windows + +Windows 7 and later are supported, Electron should be able to run on Windows Vista, but there is no testing done on it. + +Both `x86` and `x64` binaries are provided for Windows, and `ARM` version of Windows is not supported for now. + +### Linux + +The prebuilt `ia32`(`i686`) and `x64`(`amd64`) binaries of Electron are built on Ubuntu 12.04, the `arm` binary is built against ARM v7 with hard-float ABI and NEON for Debian Wheezy. + +Whether the prebuilt binary can run on a distribution depends on whether the distribution includes the libraries that Electron is linked to on the building platform, so only Ubuntu 12.04 is guaranteed to work, but following platforms are also verified to be able to run the prebuilt binaries of Electron: + +* Ubuntu 12.04 and later +* Fedora 21 +* Debian 8 From 0f9f8e62fc801b724278b45a61a5c7f6828ca204 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 3 Oct 2015 13:53:52 +0800 Subject: [PATCH 109/165] docs: No leading slash in --url-base Fixes #2968. --- docs/tutorial/using-selenium-and-webdriver.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorial/using-selenium-and-webdriver.md b/docs/tutorial/using-selenium-and-webdriver.md index ebc6d2fa78..b87f8f11da 100644 --- a/docs/tutorial/using-selenium-and-webdriver.md +++ b/docs/tutorial/using-selenium-and-webdriver.md @@ -74,7 +74,7 @@ driver. First you need to download the `chromedriver` binary, and run it: ```bash -$ chromedriver --url-base=/wd/hub --port=9515 +$ chromedriver --url-base=wd/hub --port=9515 Starting ChromeDriver (v2.10.291558) on port 9515 Only local connections are allowed. ``` From 3503b62ff290f7897ca1f0cf304dbc6b630152c0 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 3 Oct 2015 15:33:55 +0800 Subject: [PATCH 110/165] Disable logging unless --enable-logging is specified --- atom/app/atom_main_delegate.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/atom/app/atom_main_delegate.cc b/atom/app/atom_main_delegate.cc index 3c7d6b2e70..fe3c0e09ae 100644 --- a/atom/app/atom_main_delegate.cc +++ b/atom/app/atom_main_delegate.cc @@ -27,10 +27,10 @@ AtomMainDelegate::~AtomMainDelegate() { } bool AtomMainDelegate::BasicStartupComplete(int* exit_code) { - // Disable logging out to debug.log on Windows logging::LoggingSettings settings; #if defined(OS_WIN) #if defined(DEBUG) + // Print logging to debug.log on Windows settings.logging_dest = logging::LOG_TO_ALL; settings.log_file = L"debug.log"; settings.lock_log = logging::LOCK_LOG_FILE; @@ -41,6 +41,12 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) { #else // defined(OS_WIN) settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; #endif // !defined(OS_WIN) + + // Only enable logging when --enable-logging is specified. + auto command_line = base::CommandLine::ForCurrentProcess(); + if (!command_line->HasSwitch(switches::kEnableLogging)) + settings.logging_dest = logging::LOG_NONE; + logging::InitLogging(settings); // Logging with pid and timestamp. From 55acdcb1ad3e999f9f0ac5cd115203216ed25989 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 3 Oct 2015 15:43:26 +0800 Subject: [PATCH 111/165] docs: --enable-logging --- docs/api/chrome-command-line-switches.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/api/chrome-command-line-switches.md b/docs/api/chrome-command-line-switches.md index cd633fc046..c2a39126f6 100644 --- a/docs/api/chrome-command-line-switches.md +++ b/docs/api/chrome-command-line-switches.md @@ -89,15 +89,21 @@ Enables net log events to be saved and writes them to `path`. ## --ssl-version-fallback-min=`version` -Set the minimum SSL/TLS version ("tls1", "tls1.1" or "tls1.2") that TLS +Sets the minimum SSL/TLS version ("tls1", "tls1.1" or "tls1.2") that TLS fallback will accept. +## --enable-logging + +Prints Chromium's logging into console. + +This switch can not be used in `app.commandLine.appendSwitch` since it is parsed earlier than user's app is loaded. + ## --v=`log_level` Gives the default maximal active V-logging level; 0 is the default. Normally positive values are used for V-logging levels. -Passing `--v=-1` will disable logging. +This switch only works when `--enable-logging` is also passed. ## --vmodule=`pattern` @@ -109,10 +115,4 @@ Any pattern containing a forward or backward slash will be tested against the whole pathname and not just the module. E.g. `*/foo/bar/*=2` would change the logging level for all code in the source files under a `foo/bar` directory. -To disable all chromium related logs and only enable your application logs you -can do: - -```javascript -app.commandLine.appendSwitch('v', -1); -app.commandLine.appendSwitch('vmodule', 'console=0'); -``` +This switch only works when `--enable-logging` is also passed. From b78bb8442406cd6df63966b851ab59928dd92b3a Mon Sep 17 00:00:00 2001 From: Plusb Preco Date: Sat, 3 Oct 2015 17:54:05 +0900 Subject: [PATCH 112/165] Update as upstream --- docs-translations/ko-KR/README.md | 1 + .../ko-KR/api/chrome-command-line-switches.md | 18 ++++++------- docs-translations/ko-KR/api/menu-item.md | 2 +- .../ko-KR/tutorial/supported-platforms.md | 26 +++++++++++++++++++ .../tutorial/using-selenium-and-webdriver.md | 2 +- 5 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 docs-translations/ko-KR/tutorial/supported-platforms.md diff --git a/docs-translations/ko-KR/README.md b/docs-translations/ko-KR/README.md index 1e0ba63e7b..9b88aa6e17 100644 --- a/docs-translations/ko-KR/README.md +++ b/docs-translations/ko-KR/README.md @@ -1,5 +1,6 @@ ## 개발 가이드 +* [지원하는 플랫폼](tutorial/supported-platforms.md) * [어플리케이션 배포](tutorial/application-distribution.md) * [어플리케이션 패키징](tutorial/application-packaging.md) * [네이티브 Node 모듈 사용하기](tutorial/using-native-node-modules.md) diff --git a/docs-translations/ko-KR/api/chrome-command-line-switches.md b/docs-translations/ko-KR/api/chrome-command-line-switches.md index 2d9158fcc2..777ce4612d 100644 --- a/docs-translations/ko-KR/api/chrome-command-line-switches.md +++ b/docs-translations/ko-KR/api/chrome-command-line-switches.md @@ -84,13 +84,19 @@ Net log 이벤트를 활성화하고 `path`에 로그를 기록합니다. ## --ssl-version-fallback-min=`version` -Fallback SSL/TLS 최소 버전을 지정합니다. ("tls1", "tls1.1", "tls1.2") +TLS fallback에서 사용할 SSL/TLS 최소 버전을 지정합니다. ("tls1", "tls1.1", "tls1.2") + +## --enable-logging + +Chromium의 로그를 콘솔에 출력합니다. + +이 스위치는 어플리케이션이 로드되기 전에 파싱 되므로 `app.commandLine.appendSwitch`에서 사용할 수 없습니다. ## --v=`log_level` 기본 V-logging 최대 활성화 레벨을 지정합니다. 기본값은 0입니다. 기본적으로 양수를 레벨로 사용합니다. -`--v=-1`를 사용하면 로깅이 비활성화 됩니다. +이 스위치는 `--enable-logging` 스위치를 같이 지정해야 작동합니다. ## --vmodule=`pattern` @@ -100,10 +106,4 @@ Fallback SSL/TLS 최소 버전을 지정합니다. ("tls1", "tls1.1", "tls1.2") 또한 슬래시(`/`) 또는 백슬래시(`\`)를 포함하는 패턴은 지정한 경로에 대해 패턴을 테스트 합니다. 예를 들어 `*/foo/bar/*=2` 표현식은 `foo/bar` 디렉터리 안의 모든 소스 코드의 로깅 레벨을 2로 지정합니다. -모든 크로미움과 관련된 로그를 비활성화하고 어플리케이션의 로그만 활성화 하려면 다음과 같이 코드를 작성하면 됩니다: - - -```javascript -app.commandLine.appendSwitch('v', -1); -app.commandLine.appendSwitch('vmodule', 'console=0'); -``` +이 스위치는 `--enable-logging` 스위치를 같이 지정해야 작동합니다. diff --git a/docs-translations/ko-KR/api/menu-item.md b/docs-translations/ko-KR/api/menu-item.md index 8f10210099..e4c5c67767 100644 --- a/docs-translations/ko-KR/api/menu-item.md +++ b/docs-translations/ko-KR/api/menu-item.md @@ -1,6 +1,6 @@ # MenuItem -`menu-item` 모듈은 어플리케이션 또는 컨텐츠 [`menu`](menu.md)에 아이템을 추가할 수 있도록 관련 클래스를 제공합니다. +`menu-item` 모듈은 어플리케이션 또는 컨텍스트 [`menu`](menu.md)에 아이템을 추가할 수 있도록 관련 클래스를 제공합니다. [`menu`](menu.md)에서 예제를 확인할 수 있습니다. diff --git a/docs-translations/ko-KR/tutorial/supported-platforms.md b/docs-translations/ko-KR/tutorial/supported-platforms.md new file mode 100644 index 0000000000..7a35da0c12 --- /dev/null +++ b/docs-translations/ko-KR/tutorial/supported-platforms.md @@ -0,0 +1,26 @@ +# 지원하는 플랫폼 + +Electron에선 다음과 같은 플랫폼을 지원합니다: + +### OS X + +OS X는 64비트 바이너리만 제공됩니다. 그리고 최소 OS X 지원 버전은 10.8입니다. + +### Windows + +Windows 7 이후 버전만 지원됩니다. Windows Vista에서도 작동할 수 있지만 아직 모든 작동 테스트가 완료되지 않았습니다. + +윈도우용 바이너리는 `x86`과 `x64` 모두 제공됩니다. 그리고 `ARM` 버전 윈도우는 아직 지원하지 않습니다. (역주: 추후 지원할 가능성이 있습니다) + +### Linux + +Ubuntu 12.04 버전에서 빌드된 `ia32`(`i686`), `x64`(`amd64`) 바이너리가 제공됩니다. +그리고 `arm` 버전 바이너리는 ARM v7 hard-float ABI와 Debian Wheezy용 NEON에 맞춰 제공됩니다. + +미리 빌드된 바이너리가 배포판에서 작동할 수 있는지 여부는 Electron이 빌드된 플랫폼에서 링크된 라이브러리에 따라 달라집니다. +그래서 현재 Linux 바이너리는 Ubuntu 12.04 버전만 정상적인 작동이 보장됩니다. +하지만 다음 플랫폼들은 미리 빌드된 Electron 바이너리가 정상적으로 작동하는 것을 확인했습니다: + +* Ubuntu 12.04 이후 버전 +* Fedora 21 +* Debian 8 diff --git a/docs-translations/ko-KR/tutorial/using-selenium-and-webdriver.md b/docs-translations/ko-KR/tutorial/using-selenium-and-webdriver.md index 33dc6311ce..a9fd84a68b 100644 --- a/docs-translations/ko-KR/tutorial/using-selenium-and-webdriver.md +++ b/docs-translations/ko-KR/tutorial/using-selenium-and-webdriver.md @@ -71,7 +71,7 @@ driver.quit(); 먼저, `chromedriver` 바이너리를 다운로드 받고 실행합니다: ```bash -$ chromedriver --url-base=/wd/hub --port=9515 +$ chromedriver --url-base=wd/hub --port=9515 Starting ChromeDriver (v2.10.291558) on port 9515 Only local connections are allowed. ``` From 021ee20400ea4636090fb41213f3dcfd1770edf6 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 3 Oct 2015 17:52:46 +0800 Subject: [PATCH 113/165] No need to add "app" to search paths --- atom/renderer/lib/init.coffee | 3 --- 1 file changed, 3 deletions(-) diff --git a/atom/renderer/lib/init.coffee b/atom/renderer/lib/init.coffee index 274c50ec5f..ff9b12ecbf 100644 --- a/atom/renderer/lib/init.coffee +++ b/atom/renderer/lib/init.coffee @@ -11,9 +11,6 @@ process.argv.splice 1, 1 # of Atom's built-in libraries. globalPaths = Module.globalPaths globalPaths.push path.resolve(__dirname, '..', 'api', 'lib') -# And also app. -globalPaths.push path.join(process.resourcesPath, 'app') -globalPaths.push path.join(process.resourcesPath, 'app.asar') # Import common settings. require path.resolve(__dirname, '..', '..', 'common', 'lib', 'init') From 9fe326ebeb43ffb2c955945ca8b4a2135efb08c2 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 3 Oct 2015 19:55:59 +0800 Subject: [PATCH 114/165] Clear node's global search paths --- atom/browser/lib/init.coffee | 6 +++--- atom/common/lib/init.coffee | 13 ++----------- atom/renderer/lib/init.coffee | 6 +++--- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/atom/browser/lib/init.coffee b/atom/browser/lib/init.coffee index 454baf0b8a..44ae29522e 100644 --- a/atom/browser/lib/init.coffee +++ b/atom/browser/lib/init.coffee @@ -7,14 +7,14 @@ Module = require 'module' # we need to restore it here. process.argv.splice 1, 1 +# Import common settings. +require path.resolve(__dirname, '..', '..', 'common', 'lib', 'init') + # Add browser/api/lib to module search paths, which contains javascript part of # Electron's built-in libraries. globalPaths = Module.globalPaths globalPaths.push path.resolve(__dirname, '..', 'api', 'lib') -# Import common settings. -require path.resolve(__dirname, '..', '..', 'common', 'lib', 'init') - if process.platform is 'win32' # Redirect node's console to use our own implementations, since node can not # handle console output when running as GUI program. diff --git a/atom/common/lib/init.coffee b/atom/common/lib/init.coffee index acb635edea..2bfea3d72a 100644 --- a/atom/common/lib/init.coffee +++ b/atom/common/lib/init.coffee @@ -9,18 +9,9 @@ process.atomBinding = (name) -> catch e process.binding "atom_common_#{name}" if /No such module/.test e.message -# Global module search paths. +# Clear node's global search paths. globalPaths = Module.globalPaths - -# Don't lookup modules in user-defined search paths, see http://git.io/vf8sF. -homeDir = - if process.platform is 'win32' - process.env.USERPROFILE - else - process.env.HOME -if homeDir # Node only add user-defined search paths when $HOME is defined. - userModulePath = path.resolve homeDir, '.node_modules' - globalPaths.splice globalPaths.indexOf(userModulePath), 2 +globalPaths.length = 0 # Add common/api/lib to module search paths. globalPaths.push path.resolve(__dirname, '..', 'api', 'lib') diff --git a/atom/renderer/lib/init.coffee b/atom/renderer/lib/init.coffee index ff9b12ecbf..e5173fcd1e 100644 --- a/atom/renderer/lib/init.coffee +++ b/atom/renderer/lib/init.coffee @@ -7,14 +7,14 @@ Module = require 'module' # atom-renderer.js, we need to restore it here. process.argv.splice 1, 1 +# Import common settings. +require path.resolve(__dirname, '..', '..', 'common', 'lib', 'init') + # Add renderer/api/lib to require's search paths, which contains javascript part # of Atom's built-in libraries. globalPaths = Module.globalPaths globalPaths.push path.resolve(__dirname, '..', 'api', 'lib') -# Import common settings. -require path.resolve(__dirname, '..', '..', 'common', 'lib', 'init') - # The global variable will be used by ipc for event dispatching v8Util = process.atomBinding 'v8_util' v8Util.setHiddenValue global, 'ipc', new events.EventEmitter From 01d2765e4b566df853cd583006ebc7993d48cd38 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 3 Oct 2015 20:38:39 +0800 Subject: [PATCH 115/165] Prevent Node from adding paths outside this app to search paths --- atom/browser/lib/init.coffee | 3 +++ atom/common/lib/init.coffee | 6 +---- atom/common/lib/reset-search-paths.coffee | 29 +++++++++++++++++++++++ atom/renderer/lib/init.coffee | 3 +++ filenames.gypi | 1 + 5 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 atom/common/lib/reset-search-paths.coffee diff --git a/atom/browser/lib/init.coffee b/atom/browser/lib/init.coffee index 44ae29522e..b394c0fecc 100644 --- a/atom/browser/lib/init.coffee +++ b/atom/browser/lib/init.coffee @@ -7,6 +7,9 @@ Module = require 'module' # we need to restore it here. process.argv.splice 1, 1 +# Clear search paths. +require path.resolve(__dirname, '..', '..', 'common', 'lib', 'reset-search-paths') + # Import common settings. require path.resolve(__dirname, '..', '..', 'common', 'lib', 'init') diff --git a/atom/common/lib/init.coffee b/atom/common/lib/init.coffee index 2bfea3d72a..1c80e6171a 100644 --- a/atom/common/lib/init.coffee +++ b/atom/common/lib/init.coffee @@ -9,12 +9,8 @@ process.atomBinding = (name) -> catch e process.binding "atom_common_#{name}" if /No such module/.test e.message -# Clear node's global search paths. -globalPaths = Module.globalPaths -globalPaths.length = 0 - # Add common/api/lib to module search paths. -globalPaths.push path.resolve(__dirname, '..', 'api', 'lib') +Module.globalPaths.push path.resolve(__dirname, '..', 'api', 'lib') # setImmediate and process.nextTick makes use of uv_check and uv_prepare to # run the callbacks, however since we only run uv loop on requests, the diff --git a/atom/common/lib/reset-search-paths.coffee b/atom/common/lib/reset-search-paths.coffee new file mode 100644 index 0000000000..7061103306 --- /dev/null +++ b/atom/common/lib/reset-search-paths.coffee @@ -0,0 +1,29 @@ +path = require 'path' +Module = require 'module' + +# Clear Node's global search paths. +Module.globalPaths.length = 0 + +# Clear current and parent(init.coffee)'s search paths. +module.paths = [] +module.parent.paths = [] + +# Prevent Node from adding paths outside this app to search paths. +Module._nodeModulePaths = (from) -> + from = path.resolve from + + # If "from" is outside the app then we do nothing. + skipOutsidePaths = from.startsWith process.resourcesPath + + # Following logoic is copied from module.js. + splitRe = if process.platform is 'win32' then /[\/\\]/ else /\// + paths = [] + + parts = from.split splitRe + for part, tip in parts by -1 + continue if part is 'node_modules' + dir = parts.slice(0, tip + 1).join path.sep + break if skipOutsidePaths and not dir.startsWith process.resourcesPath + paths.push path.join(dir, 'node_modules') + + paths diff --git a/atom/renderer/lib/init.coffee b/atom/renderer/lib/init.coffee index e5173fcd1e..b7224b39ae 100644 --- a/atom/renderer/lib/init.coffee +++ b/atom/renderer/lib/init.coffee @@ -7,6 +7,9 @@ Module = require 'module' # atom-renderer.js, we need to restore it here. process.argv.splice 1, 1 +# Clear search paths. +require path.resolve(__dirname, '..', '..', 'common', 'lib', 'reset-search-paths') + # Import common settings. require path.resolve(__dirname, '..', '..', 'common', 'lib', 'init') diff --git a/filenames.gypi b/filenames.gypi index 0e7010d7a4..000633fb96 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -37,6 +37,7 @@ 'atom/common/api/lib/native-image.coffee', 'atom/common/api/lib/shell.coffee', 'atom/common/lib/init.coffee', + 'atom/common/lib/reset-search-paths.coffee', 'atom/renderer/lib/chrome-api.coffee', 'atom/renderer/lib/init.coffee', 'atom/renderer/lib/inspector.coffee', From bb938b02d8f3b32079c4d555e50df6b9647df43b Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Sat, 3 Oct 2015 09:02:50 -0700 Subject: [PATCH 116/165] Remove Vista as possibly working Vista crashes on startup because Win7 touch APIs aren't present - this is fine, but we want to tell people out of the gate that it won't work --- docs/tutorial/supported-platforms.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/tutorial/supported-platforms.md b/docs/tutorial/supported-platforms.md index 8b795769a8..f74ccf2ec2 100644 --- a/docs/tutorial/supported-platforms.md +++ b/docs/tutorial/supported-platforms.md @@ -8,9 +8,9 @@ Only 64bit binaries are provided for OS X, and the minimum OS X version supporte ### Windows -Windows 7 and later are supported, Electron should be able to run on Windows Vista, but there is no testing done on it. +Windows 7 and later are supported, older operating systems are not supported (and do not work). -Both `x86` and `x64` binaries are provided for Windows, and `ARM` version of Windows is not supported for now. +Both `x86` and `amd64` (x64) binaries are provided for Windows, and `ARM` version of Windows is not supported for now. ### Linux From b4ec7c5aaf09d7125124658f269954cacc1765c0 Mon Sep 17 00:00:00 2001 From: chriswmercer Date: Sat, 3 Oct 2015 18:03:49 +0100 Subject: [PATCH 117/165] Minor grammar correction --- docs/tutorial/supported-platforms.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorial/supported-platforms.md b/docs/tutorial/supported-platforms.md index 8b795769a8..ec0f3ef6a1 100644 --- a/docs/tutorial/supported-platforms.md +++ b/docs/tutorial/supported-platforms.md @@ -10,7 +10,7 @@ Only 64bit binaries are provided for OS X, and the minimum OS X version supporte Windows 7 and later are supported, Electron should be able to run on Windows Vista, but there is no testing done on it. -Both `x86` and `x64` binaries are provided for Windows, and `ARM` version of Windows is not supported for now. +Both `x86` and `x64` binaries are provided for Windows. Please note, the `ARM` version of Windows is not supported for now. ### Linux From aea1f8aebb8faf71c2c54c815b72ad9a8c21a88e Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Sat, 3 Oct 2015 22:09:57 +0300 Subject: [PATCH 118/165] Fix calculating min/max size in frameless views The minimum and maximum size that frameless windows had used, was incorrect. It included the border, so when it was called it actually added that to the size, so window increased in size. The fix makes sure that the view will use the frameless size. This fixes #2945 and partially fixes #1806 (it also refers to some other issues with hidpi which might still exist). --- atom/browser/native_window_views.cc | 29 +++++++++++++++++++++++-- atom/browser/native_window_views.h | 2 ++ atom/browser/ui/views/frameless_view.cc | 8 +++++-- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index e9db97e195..40d702e35a 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -818,9 +818,7 @@ bool NativeWindowViews::ExecuteWindowsCommand(int command_id) { NotifyWindowExecuteWindowsCommand(command); return false; } -#endif -#if defined(OS_WIN) bool NativeWindowViews::PreHandleMSG( UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) { switch (message) { @@ -874,6 +872,33 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) { } #endif +gfx::Size NativeWindowViews::WindowSizeToFramelessSize( + const gfx::Size& size) { + if (size.width() == 0 && size.height() == 0) + return size; + + gfx::Rect window_bounds = gfx::Rect(size); + if (use_content_size_) { + if (menu_bar_ && menu_bar_visible_) { + window_bounds.set_height(window_bounds.height() + kMenuBarHeight); + } + } else if (has_frame()) { +#if defined(OS_WIN) + gfx::Size frame_size = gfx::win::ScreenToDIPRect( + window_->non_client_view()->GetWindowBoundsForClientBounds( + gfx::Rect())).size(); +#else + gfx::Size frame_size = + window_->non_client_view()->GetWindowBoundsForClientBounds( + gfx::Rect()).size(); +#endif + window_bounds.set_height(window_bounds.height() - frame_size.height()); + window_bounds.set_width(window_bounds.width() - frame_size.width()); + } + + return window_bounds.size(); +} + void NativeWindowViews::HandleKeyboardEvent( content::WebContents*, const content::NativeWebKeyboardEvent& event) { diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index 71e122d381..790e532f84 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -94,6 +94,8 @@ class NativeWindowViews : public NativeWindow, gfx::AcceleratedWidget GetAcceleratedWidget(); + gfx::Size WindowSizeToFramelessSize(const gfx::Size& size); + views::Widget* widget() const { return window_.get(); } #if defined(OS_WIN) diff --git a/atom/browser/ui/views/frameless_view.cc b/atom/browser/ui/views/frameless_view.cc index 03a31e0828..e8d351ec82 100644 --- a/atom/browser/ui/views/frameless_view.cc +++ b/atom/browser/ui/views/frameless_view.cc @@ -104,11 +104,15 @@ gfx::Size FramelessView::GetPreferredSize() const { } gfx::Size FramelessView::GetMinimumSize() const { - return window_->GetMinimumSize(); + gfx::Size size = window_->WindowSizeToFramelessSize( + window_->GetMinimumSize()); + return size; } gfx::Size FramelessView::GetMaximumSize() const { - return window_->GetMaximumSize(); + gfx::Size size = window_->WindowSizeToFramelessSize( + window_->GetMaximumSize()); + return size; } const char* FramelessView::GetClassName() const { From 5d7cfa1b3ac5b3f578ceca6ceb94dcbddedd4dcf Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 4 Oct 2015 15:53:09 +0800 Subject: [PATCH 119/165] Update brightray for atom/brightray#149 --- vendor/brightray | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/brightray b/vendor/brightray index 6cbb4ad4d1..361d99dd05 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 6cbb4ad4d173d25b66eecf675c2b25ee64196429 +Subproject commit 361d99dd05a8368faee20bc39a6ffaedbc67c383 From 791f988aba568921c940713231da1811b6a1cdd3 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 4 Oct 2015 16:32:08 +0800 Subject: [PATCH 120/165] linux: Fix pressing Alt not showing menubar --- atom/browser/native_window_views.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index e9db97e195..4282b0eda9 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -905,9 +905,6 @@ void NativeWindowViews::HandleKeyboardEvent( // When a single Alt is pressed: menu_bar_alt_pressed_ = true; } else if (event.type == blink::WebInputEvent::KeyUp && IsAltKey(event) && -#if defined(USE_X11) - event.modifiers == 0 && -#endif menu_bar_alt_pressed_) { // When a single Alt is released right after a Alt is pressed: menu_bar_alt_pressed_ = false; From add9c380230ae61316156025ef8c9fec85d23f84 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 4 Oct 2015 16:33:03 +0800 Subject: [PATCH 121/165] linux: Enable force showing menubar This is for debugging purpose. --- atom/browser/ui/x/x_window_utils.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/atom/browser/ui/x/x_window_utils.cc b/atom/browser/ui/x/x_window_utils.cc index e57122839c..f5c3f54ec1 100644 --- a/atom/browser/ui/x/x_window_utils.cc +++ b/atom/browser/ui/x/x_window_utils.cc @@ -6,6 +6,7 @@ #include +#include "base/environment.h" #include "base/strings/string_util.h" #include "dbus/bus.h" #include "dbus/object_proxy.h" @@ -50,6 +51,10 @@ void SetWindowType(::Window xwindow, const std::string& type) { } bool ShouldUseGlobalMenuBar() { + scoped_ptr env(base::Environment::Create()); + if (env->HasVar("ELECTRON_FORCE_WINDOW_MENU_BAR")) + return false; + dbus::Bus::Options options; scoped_refptr bus(new dbus::Bus(options)); From 74b76102a84740a618ff3288f27dfad1197d32a2 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 4 Oct 2015 16:53:20 +0800 Subject: [PATCH 122/165] linux: No longer needs to manually read DPI settings It is now done in brightray by reading the value from GTK+. --- atom/browser/atom_browser_main_parts.cc | 4 - atom/browser/atom_browser_main_parts.h | 4 - atom/browser/atom_browser_main_parts_linux.cc | 73 ------------------- filenames.gypi | 1 - vendor/brightray | 2 +- 5 files changed, 1 insertion(+), 83 deletions(-) delete mode 100644 atom/browser/atom_browser_main_parts_linux.cc diff --git a/atom/browser/atom_browser_main_parts.cc b/atom/browser/atom_browser_main_parts.cc index a1a1192b27..1b46247c49 100644 --- a/atom/browser/atom_browser_main_parts.cc +++ b/atom/browser/atom_browser_main_parts.cc @@ -55,10 +55,6 @@ void AtomBrowserMainParts::RegisterDestructionCallback( void AtomBrowserMainParts::PostEarlyInitialization() { brightray::BrowserMainParts::PostEarlyInitialization(); -#if defined(USE_X11) - SetDPIFromGSettings(); -#endif - { // Temporary set the bridge_task_runner_ as current thread's task runner, // so we can fool gin::PerIsolateData to use it as its task runner, instead diff --git a/atom/browser/atom_browser_main_parts.h b/atom/browser/atom_browser_main_parts.h index bcebc86f16..9fefa486a1 100644 --- a/atom/browser/atom_browser_main_parts.h +++ b/atom/browser/atom_browser_main_parts.h @@ -48,10 +48,6 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts { #endif private: -#if defined(USE_X11) - void SetDPIFromGSettings(); -#endif - // A fake BrowserProcess object that used to feed the source code from chrome. scoped_ptr fake_browser_process_; diff --git a/atom/browser/atom_browser_main_parts_linux.cc b/atom/browser/atom_browser_main_parts_linux.cc deleted file mode 100644 index 278e49ac1f..0000000000 --- a/atom/browser/atom_browser_main_parts_linux.cc +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2014 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#include "atom/browser/atom_browser_main_parts.h" - -#include - -#include "base/command_line.h" -#include "base/strings/string_number_conversions.h" -#include "ui/gfx/switches.h" - -namespace atom { - -namespace { - -const char* kInterfaceSchema = "org.gnome.desktop.interface"; -const char* kScaleFactor = "scaling-factor"; - -bool SchemaExists(const char* schema_name) { - const gchar* const* schemas = g_settings_list_schemas(); - while (*schemas) { - if (strcmp(schema_name, static_cast(*schemas)) == 0) - return true; - schemas++; - } - return false; -} - -bool KeyExists(GSettings* client, const char* key) { - gchar** keys = g_settings_list_keys(client); - if (!keys) - return false; - - gchar** iter = keys; - while (*iter) { - if (strcmp(*iter, key) == 0) - break; - iter++; - } - - bool exists = *iter != NULL; - g_strfreev(keys); - return exists; -} - -void GetDPIFromGSettings(guint* scale_factor) { - GSettings* client = nullptr; - if (!SchemaExists(kInterfaceSchema) || - !(client = g_settings_new(kInterfaceSchema))) { - VLOG(1) << "Cannot create gsettings client."; - return; - } - - if (KeyExists(client, kScaleFactor)) - *scale_factor = g_settings_get_uint(client, kScaleFactor); - - g_object_unref(client); -} - -} // namespace - -void AtomBrowserMainParts::SetDPIFromGSettings() { - guint scale_factor = 1; - GetDPIFromGSettings(&scale_factor); - if (scale_factor == 0) - scale_factor = 1; - - base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( - switches::kForceDeviceScaleFactor, base::UintToString(scale_factor)); -} - -} // namespace atom diff --git a/filenames.gypi b/filenames.gypi index 000633fb96..eb94973e01 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -124,7 +124,6 @@ 'atom/browser/atom_download_manager_delegate.h', 'atom/browser/atom_browser_main_parts.cc', 'atom/browser/atom_browser_main_parts.h', - 'atom/browser/atom_browser_main_parts_linux.cc', 'atom/browser/atom_browser_main_parts_mac.mm', 'atom/browser/atom_javascript_dialog_manager.cc', 'atom/browser/atom_javascript_dialog_manager.h', diff --git a/vendor/brightray b/vendor/brightray index 361d99dd05..bbb9287337 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 361d99dd05a8368faee20bc39a6ffaedbc67c383 +Subproject commit bbb9287337f8b7958b001be35b993c21cd573109 From bdd2f919137546a560ce808fd386994823628c57 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 4 Oct 2015 19:20:52 +0800 Subject: [PATCH 123/165] Make Browser::Quit more robust --- atom/browser/browser.cc | 15 +++++++++++++-- atom/browser/browser.h | 3 +++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index 9d2a9fc1ef..d8bb94103c 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -16,7 +16,8 @@ namespace atom { Browser::Browser() : is_quiting_(false), - is_ready_(false) { + is_ready_(false), + is_shutdown_(false) { WindowList::AddObserver(this); } @@ -30,6 +31,9 @@ Browser* Browser::Get() { } void Browser::Quit() { + if (is_quiting_) + return; + is_quiting_ = HandleBeforeQuit(); if (!is_quiting_) return; @@ -42,9 +46,13 @@ void Browser::Quit() { } void Browser::Shutdown() { - FOR_EACH_OBSERVER(BrowserObserver, observers_, OnQuit()); + if (is_shutdown_) + return; + is_shutdown_ = true; is_quiting_ = true; + + FOR_EACH_OBSERVER(BrowserObserver, observers_, OnQuit()); base::MessageLoop::current()->PostTask( FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); } @@ -121,6 +129,9 @@ void Browser::ClientCertificateSelector( } void Browser::NotifyAndShutdown() { + if (is_shutdown_) + return; + bool prevent_default = false; FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWillQuit(&prevent_default)); diff --git a/atom/browser/browser.h b/atom/browser/browser.h index d135556b87..3c5abd2f04 100644 --- a/atom/browser/browser.h +++ b/atom/browser/browser.h @@ -159,6 +159,9 @@ class Browser : public WindowListObserver { // Whether "ready" event has been emitted. bool is_ready_; + // The browse is being shutdown. + bool is_shutdown_; + std::string version_override_; std::string name_override_; From 0e131f760b63ad199c5fffa13b2d422cf3bb5e26 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 4 Oct 2015 19:21:36 +0800 Subject: [PATCH 124/165] Quit gracefully when Ctrl-C is pressed --- atom/browser/atom_browser_main_parts.cc | 12 + atom/browser/atom_browser_main_parts.h | 8 + atom/browser/atom_browser_main_parts_posix.cc | 225 ++++++++++++++++++ filenames.gypi | 1 + 4 files changed, 246 insertions(+) create mode 100644 atom/browser/atom_browser_main_parts_posix.cc diff --git a/atom/browser/atom_browser_main_parts.cc b/atom/browser/atom_browser_main_parts.cc index 1b46247c49..e70d42fc76 100644 --- a/atom/browser/atom_browser_main_parts.cc +++ b/atom/browser/atom_browser_main_parts.cc @@ -52,6 +52,12 @@ void AtomBrowserMainParts::RegisterDestructionCallback( destruction_callbacks_.push_back(callback); } +void AtomBrowserMainParts::PreEarlyInitialization() { +#if defined(OS_POSIX) + HandleSIGCHLD(); +#endif +} + void AtomBrowserMainParts::PostEarlyInitialization() { brightray::BrowserMainParts::PostEarlyInitialization(); @@ -112,6 +118,12 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() { #endif } +void AtomBrowserMainParts::PostMainMessageLoopStart() { +#if defined(OS_POSIX) + HandleShutdownSignals(); +#endif +} + void AtomBrowserMainParts::PostMainMessageLoopRun() { brightray::BrowserMainParts::PostMainMessageLoopRun(); diff --git a/atom/browser/atom_browser_main_parts.h b/atom/browser/atom_browser_main_parts.h index 9fefa486a1..65b142157d 100644 --- a/atom/browser/atom_browser_main_parts.h +++ b/atom/browser/atom_browser_main_parts.h @@ -39,8 +39,10 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts { protected: // content::BrowserMainParts: + void PreEarlyInitialization() override; void PostEarlyInitialization() override; void PreMainMessageLoopRun() override; + void PostMainMessageLoopStart() override; void PostMainMessageLoopRun() override; #if defined(OS_MACOSX) void PreMainMessageLoopStart() override; @@ -48,6 +50,12 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts { #endif private: +#if defined(OS_POSIX) + // Set signal handlers. + void HandleSIGCHLD(); + void HandleShutdownSignals(); +#endif + // A fake BrowserProcess object that used to feed the source code from chrome. scoped_ptr fake_browser_process_; diff --git a/atom/browser/atom_browser_main_parts_posix.cc b/atom/browser/atom_browser_main_parts_posix.cc new file mode 100644 index 0000000000..ea0f87b171 --- /dev/null +++ b/atom/browser/atom_browser_main_parts_posix.cc @@ -0,0 +1,225 @@ +// Copyright (c) 2015 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +// Most code came from: chrome/browser/chrome_browser_main_posix.cc. + +#include "atom/browser/atom_browser_main_parts.h" + +#include +#include +#include +#include +#include +#include + +#include "atom/browser/browser.h" +#include "base/posix/eintr_wrapper.h" +#include "content/public/browser/browser_thread.h" + +using content::BrowserThread; + +namespace atom { + +namespace { + +// See comment in |PreEarlyInitialization()|, where sigaction is called. +void SIGCHLDHandler(int signal) { +} + +// The OSX fork() implementation can crash in the child process before +// fork() returns. In that case, the shutdown pipe will still be +// shared with the parent process. To prevent child crashes from +// causing parent shutdowns, |g_pipe_pid| is the pid for the process +// which registered |g_shutdown_pipe_write_fd|. +// See . +pid_t g_pipe_pid = -1; +int g_shutdown_pipe_write_fd = -1; +int g_shutdown_pipe_read_fd = -1; + +// Common code between SIG{HUP, INT, TERM}Handler. +void GracefulShutdownHandler(int signal) { + // Reinstall the default handler. We had one shot at graceful shutdown. + struct sigaction action; + memset(&action, 0, sizeof(action)); + action.sa_handler = SIG_DFL; + RAW_CHECK(sigaction(signal, &action, NULL) == 0); + + RAW_CHECK(g_pipe_pid == getpid()); + RAW_CHECK(g_shutdown_pipe_write_fd != -1); + RAW_CHECK(g_shutdown_pipe_read_fd != -1); + size_t bytes_written = 0; + do { + int rv = HANDLE_EINTR( + write(g_shutdown_pipe_write_fd, + reinterpret_cast(&signal) + bytes_written, + sizeof(signal) - bytes_written)); + RAW_CHECK(rv >= 0); + bytes_written += rv; + } while (bytes_written < sizeof(signal)); +} + +// See comment in |PostMainMessageLoopStart()|, where sigaction is called. +void SIGHUPHandler(int signal) { + RAW_CHECK(signal == SIGHUP); + GracefulShutdownHandler(signal); +} + +// See comment in |PostMainMessageLoopStart()|, where sigaction is called. +void SIGINTHandler(int signal) { + RAW_CHECK(signal == SIGINT); + GracefulShutdownHandler(signal); +} + +// See comment in |PostMainMessageLoopStart()|, where sigaction is called. +void SIGTERMHandler(int signal) { + RAW_CHECK(signal == SIGTERM); + GracefulShutdownHandler(signal); +} + +class ShutdownDetector : public base::PlatformThread::Delegate { + public: + explicit ShutdownDetector(int shutdown_fd); + + void ThreadMain() override; + + private: + const int shutdown_fd_; + + DISALLOW_COPY_AND_ASSIGN(ShutdownDetector); +}; + +ShutdownDetector::ShutdownDetector(int shutdown_fd) + : shutdown_fd_(shutdown_fd) { + CHECK_NE(shutdown_fd_, -1); +} + +// These functions are used to help us diagnose crash dumps that happen +// during the shutdown process. +NOINLINE void ShutdownFDReadError() { + // Ensure function isn't optimized away. + asm(""); + sleep(UINT_MAX); +} + +NOINLINE void ShutdownFDClosedError() { + // Ensure function isn't optimized away. + asm(""); + sleep(UINT_MAX); +} + +NOINLINE void ExitPosted() { + // Ensure function isn't optimized away. + asm(""); + sleep(UINT_MAX); +} + +void ShutdownDetector::ThreadMain() { + base::PlatformThread::SetName("CrShutdownDetector"); + + int signal; + size_t bytes_read = 0; + ssize_t ret; + do { + ret = HANDLE_EINTR( + read(shutdown_fd_, + reinterpret_cast(&signal) + bytes_read, + sizeof(signal) - bytes_read)); + if (ret < 0) { + NOTREACHED() << "Unexpected error: " << strerror(errno); + ShutdownFDReadError(); + break; + } else if (ret == 0) { + NOTREACHED() << "Unexpected closure of shutdown pipe."; + ShutdownFDClosedError(); + break; + } + bytes_read += ret; + } while (bytes_read < sizeof(signal)); + VLOG(1) << "Handling shutdown for signal " << signal << "."; + base::Closure task = + base::Bind(&Browser::Quit, base::Unretained(Browser::Get())); + + if (!BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, task)) { + // Without a UI thread to post the exit task to, there aren't many + // options. Raise the signal again. The default handler will pick it up + // and cause an ungraceful exit. + RAW_LOG(WARNING, "No UI thread, exiting ungracefully."); + kill(getpid(), signal); + + // The signal may be handled on another thread. Give that a chance to + // happen. + sleep(3); + + // We really should be dead by now. For whatever reason, we're not. Exit + // immediately, with the exit status set to the signal number with bit 8 + // set. On the systems that we care about, this exit status is what is + // normally used to indicate an exit by this signal's default handler. + // This mechanism isn't a de jure standard, but even in the worst case, it + // should at least result in an immediate exit. + RAW_LOG(WARNING, "Still here, exiting really ungracefully."); + _exit(signal | (1 << 7)); + } + ExitPosted(); +} + +} // namespace + +void AtomBrowserMainParts::HandleSIGCHLD() { + // We need to accept SIGCHLD, even though our handler is a no-op because + // otherwise we cannot wait on children. (According to POSIX 2001.) + struct sigaction action; + memset(&action, 0, sizeof(action)); + action.sa_handler = SIGCHLDHandler; + CHECK(sigaction(SIGCHLD, &action, NULL) == 0); +} + +void AtomBrowserMainParts::HandleShutdownSignals() { + int pipefd[2]; + int ret = pipe(pipefd); + if (ret < 0) { + PLOG(DFATAL) << "Failed to create pipe"; + } else { + g_pipe_pid = getpid(); + g_shutdown_pipe_read_fd = pipefd[0]; + g_shutdown_pipe_write_fd = pipefd[1]; +#if !defined(ADDRESS_SANITIZER) && !defined(KEEP_SHADOW_STACKS) + const size_t kShutdownDetectorThreadStackSize = PTHREAD_STACK_MIN * 2; +#else + // ASan instrumentation and -finstrument-functions (used for keeping the + // shadow stacks) bloat the stack frames, so we need to increase the stack + // size to avoid hitting the guard page. + const size_t kShutdownDetectorThreadStackSize = PTHREAD_STACK_MIN * 4; +#endif + // TODO(viettrungluu,willchan): crbug.com/29675 - This currently leaks, so + // if you change this, you'll probably need to change the suppression. + if (!base::PlatformThread::CreateNonJoinable( + kShutdownDetectorThreadStackSize, + new ShutdownDetector(g_shutdown_pipe_read_fd))) { + LOG(DFATAL) << "Failed to create shutdown detector task."; + } + } + // Setup signal handlers for shutdown AFTER shutdown pipe is setup because + // it may be called right away after handler is set. + + // If adding to this list of signal handlers, note the new signal probably + // needs to be reset in child processes. See + // base/process_util_posix.cc:LaunchProcess. + + // We need to handle SIGTERM, because that is how many POSIX-based distros ask + // processes to quit gracefully at shutdown time. + struct sigaction action; + memset(&action, 0, sizeof(action)); + action.sa_handler = SIGTERMHandler; + CHECK(sigaction(SIGTERM, &action, NULL) == 0); + // Also handle SIGINT - when the user terminates the browser via Ctrl+C. If + // the browser process is being debugged, GDB will catch the SIGINT first. + action.sa_handler = SIGINTHandler; + CHECK(sigaction(SIGINT, &action, NULL) == 0); + // And SIGHUP, for when the terminal disappears. On shutdown, many Linux + // distros send SIGHUP, SIGTERM, and then SIGKILL. + action.sa_handler = SIGHUPHandler; + CHECK(sigaction(SIGHUP, &action, NULL) == 0); +} + +} // namespace atom diff --git a/filenames.gypi b/filenames.gypi index eb94973e01..04b82992bc 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -125,6 +125,7 @@ 'atom/browser/atom_browser_main_parts.cc', 'atom/browser/atom_browser_main_parts.h', 'atom/browser/atom_browser_main_parts_mac.mm', + 'atom/browser/atom_browser_main_parts_posix.cc', 'atom/browser/atom_javascript_dialog_manager.cc', 'atom/browser/atom_javascript_dialog_manager.h', 'atom/browser/atom_quota_permission_context.cc', From a2a4970f5f6601c6e8b713e6fe342ea63d78b022 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 4 Oct 2015 19:36:41 +0800 Subject: [PATCH 125/165] Fix cpplint warnings --- atom/browser/atom_browser_main_parts_posix.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/atom/browser/atom_browser_main_parts_posix.cc b/atom/browser/atom_browser_main_parts_posix.cc index ea0f87b171..2a0dddc474 100644 --- a/atom/browser/atom_browser_main_parts_posix.cc +++ b/atom/browser/atom_browser_main_parts_posix.cc @@ -171,7 +171,7 @@ void AtomBrowserMainParts::HandleSIGCHLD() { struct sigaction action; memset(&action, 0, sizeof(action)); action.sa_handler = SIGCHLDHandler; - CHECK(sigaction(SIGCHLD, &action, NULL) == 0); + CHECK_EQ(sigaction(SIGCHLD, &action, NULL), 0); } void AtomBrowserMainParts::HandleShutdownSignals() { @@ -211,15 +211,15 @@ void AtomBrowserMainParts::HandleShutdownSignals() { struct sigaction action; memset(&action, 0, sizeof(action)); action.sa_handler = SIGTERMHandler; - CHECK(sigaction(SIGTERM, &action, NULL) == 0); + CHECK_EQ(sigaction(SIGTERM, &action, NULL), 0); // Also handle SIGINT - when the user terminates the browser via Ctrl+C. If // the browser process is being debugged, GDB will catch the SIGINT first. action.sa_handler = SIGINTHandler; - CHECK(sigaction(SIGINT, &action, NULL) == 0); + CHECK_EQ(sigaction(SIGINT, &action, NULL), 0); // And SIGHUP, for when the terminal disappears. On shutdown, many Linux // distros send SIGHUP, SIGTERM, and then SIGKILL. action.sa_handler = SIGHUPHandler; - CHECK(sigaction(SIGHUP, &action, NULL) == 0); + CHECK_EQ(sigaction(SIGHUP, &action, NULL), 0); } } // namespace atom From d4bfeff6ad1686feb4a815096bb7890230a73a01 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 4 Oct 2015 20:08:19 +0800 Subject: [PATCH 126/165] Fix crashing on Linux --- atom/browser/atom_browser_main_parts.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/atom/browser/atom_browser_main_parts.cc b/atom/browser/atom_browser_main_parts.cc index e70d42fc76..4c11176997 100644 --- a/atom/browser/atom_browser_main_parts.cc +++ b/atom/browser/atom_browser_main_parts.cc @@ -53,6 +53,7 @@ void AtomBrowserMainParts::RegisterDestructionCallback( } void AtomBrowserMainParts::PreEarlyInitialization() { + brightray::BrowserMainParts::PreEarlyInitialization(); #if defined(OS_POSIX) HandleSIGCHLD(); #endif @@ -119,6 +120,7 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() { } void AtomBrowserMainParts::PostMainMessageLoopStart() { + brightray::BrowserMainParts::PostMainMessageLoopStart(); #if defined(OS_POSIX) HandleShutdownSignals(); #endif From 3d4318e15e757cf26377637ee1240d5b87cde39c Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 4 Oct 2015 21:19:44 +0800 Subject: [PATCH 127/165] docs: Remove `cache` and `userCache` dir Closes #1404. --- docs/api/app.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/docs/api/app.md b/docs/api/app.md index e4a8d561e2..0b5780aab7 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -197,12 +197,6 @@ You can request the following paths by the name: * `~/Library/Application Support` on OS X * `userData` The directory for storing your app's configuration files, which by default it is the `appData` directory appended with your app's name. -* `cache` Per-user application cache directory, which by default points to: - * `%APPDATA%` on Windows (which doesn't have a universal cache location) - * `$XDG_CACHE_HOME` or `~/.cache` on Linux - * `~/Library/Caches` on OS X -* `userCache` The directory for placing your app's caches, by default it is the - `cache` directory appended with your app's name. * `temp` Temporary directory. * `userDesktop` The current user's Desktop directory. * `exe` The current executable file. From ca6f6880139670e560157ebaa812cdf73afdeb0a Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 4 Oct 2015 22:19:05 +0800 Subject: [PATCH 128/165] Update brightray for #877 --- vendor/brightray | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/brightray b/vendor/brightray index bbb9287337..c44f99278b 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit bbb9287337f8b7958b001be35b993c21cd573109 +Subproject commit c44f99278bc4f6823f81b6f3a8d75881d697fd01 From 4d02fc58fa183c13273888cc30a874abaee52238 Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Mon, 5 Oct 2015 03:29:02 +0300 Subject: [PATCH 129/165] Fix restore/unmaximize wrong window size This resolves #2498. --- atom/browser/native_window_views.cc | 46 +++++++++++++++++++---------- atom/browser/native_window_views.h | 6 ++++ 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index e9db97e195..7117142cf0 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -283,6 +283,8 @@ NativeWindowViews::NativeWindowViews( else last_window_state_ = ui::SHOW_STATE_NORMAL; + last_normal_size_ = gfx::Size(widget_size_); + if (!has_frame()) { // Set Window style so that we get a minimize and maximize animation when // frameless. @@ -851,23 +853,35 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) { NotifyWindowMinimize(); break; case SIZE_RESTORED: - if (last_window_state_ == ui::SHOW_STATE_NORMAL) - return; - - switch (last_window_state_) { - case ui::SHOW_STATE_MAXIMIZED: - last_window_state_ = ui::SHOW_STATE_NORMAL; - NotifyWindowUnmaximize(); - break; - case ui::SHOW_STATE_MINIMIZED: - if (IsFullscreen()) { - last_window_state_ = ui::SHOW_STATE_FULLSCREEN; - NotifyWindowEnterFullScreen(); - } else { + if (last_window_state_ == ui::SHOW_STATE_NORMAL) { + // Window was resized so we save it's new size. + last_normal_size_ = GetSize(); + } else { + switch (last_window_state_) { + case ui::SHOW_STATE_MAXIMIZED: last_window_state_ = ui::SHOW_STATE_NORMAL; - NotifyWindowRestore(); - } - break; + + // When the window is restored we resize it to the previous known + // normal size. + NativeWindow::SetSize(last_normal_size_); + + NotifyWindowUnmaximize(); + break; + case ui::SHOW_STATE_MINIMIZED: + if (IsFullscreen()) { + last_window_state_ = ui::SHOW_STATE_FULLSCREEN; + NotifyWindowEnterFullScreen(); + } else { + last_window_state_ = ui::SHOW_STATE_NORMAL; + + // When the window is restored we resize it to the previous known + // normal size. + NativeWindow::SetSize(last_normal_size_); + + NotifyWindowRestore(); + } + break; + } } break; } diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index 71e122d381..f93a9e2f7f 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -176,6 +176,12 @@ class NativeWindowViews : public NativeWindow, ui::WindowShowState last_window_state_; + // There's an issue with restore on Windows, that sometimes causes the Window + // to receive the wrong size (#2498). To circumvent that, we keep tabs on the + // size of the window while in the normal state (not maximized, minimized or + // fullscreen), so we restore it correctly. + gfx::Size last_normal_size_; + // In charge of running taskbar related APIs. TaskbarHost taskbar_host_; #endif From c34c123b338df7a8a72cc14f0b032eae223800ac Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Mon, 5 Oct 2015 04:01:25 +0300 Subject: [PATCH 130/165] Make it work only on Windows Limiting the solution to Windows only. --- atom/browser/ui/views/frameless_view.cc | 8 ++------ atom/browser/ui/views/win_frame_view.cc | 6 ++++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/atom/browser/ui/views/frameless_view.cc b/atom/browser/ui/views/frameless_view.cc index e8d351ec82..03a31e0828 100644 --- a/atom/browser/ui/views/frameless_view.cc +++ b/atom/browser/ui/views/frameless_view.cc @@ -104,15 +104,11 @@ gfx::Size FramelessView::GetPreferredSize() const { } gfx::Size FramelessView::GetMinimumSize() const { - gfx::Size size = window_->WindowSizeToFramelessSize( - window_->GetMinimumSize()); - return size; + return window_->GetMinimumSize(); } gfx::Size FramelessView::GetMaximumSize() const { - gfx::Size size = window_->WindowSizeToFramelessSize( - window_->GetMaximumSize()); - return size; + return window_->GetMaximumSize(); } const char* FramelessView::GetClassName() const { diff --git a/atom/browser/ui/views/win_frame_view.cc b/atom/browser/ui/views/win_frame_view.cc index db74661932..d0338af19d 100644 --- a/atom/browser/ui/views/win_frame_view.cc +++ b/atom/browser/ui/views/win_frame_view.cc @@ -40,12 +40,14 @@ int WinFrameView::NonClientHitTest(const gfx::Point& point) { } gfx::Size WinFrameView::GetMinimumSize() const { - gfx::Size size = FramelessView::GetMinimumSize(); + gfx::Size size = window_->WindowSizeToFramelessSize( + window_->GetMinimumSize()); return gfx::win::DIPToScreenSize(size); } gfx::Size WinFrameView::GetMaximumSize() const { - gfx::Size size = FramelessView::GetMaximumSize(); + gfx::Size size = window_->WindowSizeToFramelessSize( + window_->GetMaximumSize()); return gfx::win::DIPToScreenSize(size); } From 69140af0835d2d7aea8bbce632ae7fe9faa70bad Mon Sep 17 00:00:00 2001 From: hansrwindhoff Date: Sun, 4 Oct 2015 20:14:52 -0600 Subject: [PATCH 131/165] example code didn't run --- docs/api/screen.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/api/screen.md b/docs/api/screen.md index da15c7326f..9afbf02170 100644 --- a/docs/api/screen.md +++ b/docs/api/screen.md @@ -37,8 +37,8 @@ app.on('ready', function() { var electronScreen = require('screen'); var displays = electronScreen.getAllDisplays(); var externalDisplay = null; - for (var i in displays) { - if (displays[i].bounds.x > 0 || displays[i].bounds.y > 0) { + for (var i =0; i< displays.length; i++) { + if (displays[i].bounds.x !==0 || displays[i].bounds.y !== 0) { externalDisplay = displays[i]; break; } @@ -48,6 +48,8 @@ app.on('ready', function() { mainWindow = new BrowserWindow({ x: externalDisplay.bounds.x + 50, y: externalDisplay.bounds.y + 50, + width: 900, + height:600 }); } }); From 46c69cc3e5f76aee329a1b79847ac0f65818e5ee Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 5 Oct 2015 11:41:06 +0800 Subject: [PATCH 132/165] docs: Removed unneeded changes from PR --- docs/api/screen.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/api/screen.md b/docs/api/screen.md index 9afbf02170..3b6c276daf 100644 --- a/docs/api/screen.md +++ b/docs/api/screen.md @@ -37,8 +37,8 @@ app.on('ready', function() { var electronScreen = require('screen'); var displays = electronScreen.getAllDisplays(); var externalDisplay = null; - for (var i =0; i< displays.length; i++) { - if (displays[i].bounds.x !==0 || displays[i].bounds.y !== 0) { + for (var i in displays) { + if (displays[i].bounds.x != 0 || displays[i].bounds.y != 0) { externalDisplay = displays[i]; break; } @@ -48,8 +48,6 @@ app.on('ready', function() { mainWindow = new BrowserWindow({ x: externalDisplay.bounds.x + 50, y: externalDisplay.bounds.y + 50, - width: 900, - height:600 }); } }); From ad8e727ba251b559e48625680a50cc014f26b0e5 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 5 Oct 2015 11:41:36 +0800 Subject: [PATCH 133/165] docs: "loaded" event of "process" --- docs/api/process.md | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/docs/api/process.md b/docs/api/process.md index abd3c4fe57..4e0fa4d602 100644 --- a/docs/api/process.md +++ b/docs/api/process.md @@ -9,7 +9,25 @@ upstream node: * `process.versions['chrome']` String - Version of Chromium. * `process.resourcesPath` String - Path to JavaScript source code. -# Methods +## Events + +### Event: 'loaded' + +Emitted when Electron has loaded its internal initialization script and is +beginning to load the web page or the main script. + +It can be used by the preload script to add removed Node global symbols back to +the global scope when node integration is turned off: + +```js +// preload.js +process.once('loaded', function() { + global.setImmediate = setImmediate; + global.clearImmediate = clearImmediate; +}); +``` + +## Methods The `process` object has the following method: @@ -17,7 +35,7 @@ The `process` object has the following method: Causes the main thread of the current process hang. -## process.setFdLimit(maxDescriptors) _OS X_ _Linux_ +### process.setFdLimit(maxDescriptors) _OS X_ _Linux_ * `maxDescriptors` Integer From ec0a8a13219a18989623878ed063449742a42bd6 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 5 Oct 2015 11:42:43 +0800 Subject: [PATCH 134/165] Bump v0.33.5 --- atom.gyp | 2 +- atom/browser/resources/mac/Info.plist | 2 +- atom/browser/resources/win/atom.rc | 8 ++++---- atom/common/atom_version.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/atom.gyp b/atom.gyp index b3c9e117a5..637e1c4795 100644 --- a/atom.gyp +++ b/atom.gyp @@ -4,7 +4,7 @@ 'product_name%': 'Electron', 'company_name%': 'GitHub, Inc', 'company_abbr%': 'github', - 'version%': '0.33.4', + 'version%': '0.33.5', }, 'includes': [ 'filenames.gypi', diff --git a/atom/browser/resources/mac/Info.plist b/atom/browser/resources/mac/Info.plist index b1b905a433..12934e6ef8 100644 --- a/atom/browser/resources/mac/Info.plist +++ b/atom/browser/resources/mac/Info.plist @@ -17,7 +17,7 @@ CFBundleIconFile atom.icns CFBundleVersion - 0.33.4 + 0.33.5 LSMinimumSystemVersion 10.8.0 NSMainNibFile diff --git a/atom/browser/resources/win/atom.rc b/atom/browser/resources/win/atom.rc index 6d900b0ea0..7a36dcdf35 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,33,4,0 - PRODUCTVERSION 0,33,4,0 + FILEVERSION 0,33,5,0 + PRODUCTVERSION 0,33,5,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -74,12 +74,12 @@ BEGIN BEGIN VALUE "CompanyName", "GitHub, Inc." VALUE "FileDescription", "Electron" - VALUE "FileVersion", "0.33.4" + VALUE "FileVersion", "0.33.5" VALUE "InternalName", "electron.exe" VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved." VALUE "OriginalFilename", "electron.exe" VALUE "ProductName", "Electron" - VALUE "ProductVersion", "0.33.4" + VALUE "ProductVersion", "0.33.5" VALUE "SquirrelAwareVersion", "1" END END diff --git a/atom/common/atom_version.h b/atom/common/atom_version.h index 998e430881..42610f196e 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 33 -#define ATOM_PATCH_VERSION 4 +#define ATOM_PATCH_VERSION 5 #define ATOM_VERSION_IS_RELEASE 1 From 7de3aa3cc1eef66a84df8d474954d4e2d81a1adb Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 5 Oct 2015 19:57:14 +0800 Subject: [PATCH 135/165] Fix typo, closes #2990 --- atom/browser/native_window_views.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 4282b0eda9..689626fc5f 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -351,7 +351,7 @@ void NativeWindowViews::ShowInactive() { } void NativeWindowViews::Hide() { - web_contents()->WasHidden(); + window_->Hide(); } bool NativeWindowViews::IsVisible() { From 2d676770b12975daf1bbf67d0c758be04e03844f Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 5 Oct 2015 19:57:30 +0800 Subject: [PATCH 136/165] Bump v0.33.6 --- atom.gyp | 2 +- atom/browser/resources/mac/Info.plist | 2 +- atom/browser/resources/win/atom.rc | 8 ++++---- atom/common/atom_version.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/atom.gyp b/atom.gyp index 637e1c4795..f06a0c8251 100644 --- a/atom.gyp +++ b/atom.gyp @@ -4,7 +4,7 @@ 'product_name%': 'Electron', 'company_name%': 'GitHub, Inc', 'company_abbr%': 'github', - 'version%': '0.33.5', + 'version%': '0.33.6', }, 'includes': [ 'filenames.gypi', diff --git a/atom/browser/resources/mac/Info.plist b/atom/browser/resources/mac/Info.plist index 12934e6ef8..50e019c1c7 100644 --- a/atom/browser/resources/mac/Info.plist +++ b/atom/browser/resources/mac/Info.plist @@ -17,7 +17,7 @@ CFBundleIconFile atom.icns CFBundleVersion - 0.33.5 + 0.33.6 LSMinimumSystemVersion 10.8.0 NSMainNibFile diff --git a/atom/browser/resources/win/atom.rc b/atom/browser/resources/win/atom.rc index 7a36dcdf35..b1aba451dc 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,33,5,0 - PRODUCTVERSION 0,33,5,0 + FILEVERSION 0,33,6,0 + PRODUCTVERSION 0,33,6,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -74,12 +74,12 @@ BEGIN BEGIN VALUE "CompanyName", "GitHub, Inc." VALUE "FileDescription", "Electron" - VALUE "FileVersion", "0.33.5" + VALUE "FileVersion", "0.33.6" VALUE "InternalName", "electron.exe" VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved." VALUE "OriginalFilename", "electron.exe" VALUE "ProductName", "Electron" - VALUE "ProductVersion", "0.33.5" + VALUE "ProductVersion", "0.33.6" VALUE "SquirrelAwareVersion", "1" END END diff --git a/atom/common/atom_version.h b/atom/common/atom_version.h index 42610f196e..8078551b90 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 33 -#define ATOM_PATCH_VERSION 5 +#define ATOM_PATCH_VERSION 6 #define ATOM_VERSION_IS_RELEASE 1 From 8577f2b52f42335747101123b4fe9e5fa77f1bd8 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 5 Oct 2015 16:19:01 +0800 Subject: [PATCH 137/165] osx: Add NativeWindow::SetSizeConstraints --- atom/browser/native_window.cc | 69 +++++++++++++++ atom/browser/native_window.h | 26 ++++-- atom/browser/native_window_mac.h | 12 +-- atom/browser/native_window_mac.mm | 77 +++++++---------- atom/browser/native_window_views.cc | 16 ++++ atom/browser/native_window_views.h | 6 ++ .../browser/app_window/size_constraints.cc | 83 +++++++++++++++++++ .../browser/app_window/size_constraints.h | 57 +++++++++++++ filenames.gypi | 2 + 9 files changed, 287 insertions(+), 61 deletions(-) create mode 100644 chromium_src/extensions/browser/app_window/size_constraints.cc create mode 100644 chromium_src/extensions/browser/app_window/size_constraints.h diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 80a7d1347f..cad6942d2e 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -162,6 +162,14 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) { Show(); } +gfx::Size NativeWindow::ContentSizeToWindowSize(const gfx::Size& size) { + return size; +} + +gfx::Size NativeWindow::WindowSizeToContentSize(const gfx::Size& size) { + return size; +} + void NativeWindow::SetSize(const gfx::Size& size) { SetBounds(gfx::Rect(GetPosition(), size)); } @@ -178,6 +186,67 @@ gfx::Point NativeWindow::GetPosition() { return GetBounds().origin(); } +void NativeWindow::SetContentSize(const gfx::Size& size) { + SetSize(ContentSizeToWindowSize(size)); +} + +gfx::Size NativeWindow::GetContentSize() { + return WindowSizeToContentSize(GetSize()); +} + +void NativeWindow::SetSizeConstraints( + const extensions::SizeConstraints& window_constraints) { + extensions::SizeConstraints content_constraints; + if (window_constraints.HasMaximumSize()) + content_constraints.set_maximum_size( + WindowSizeToContentSize(window_constraints.GetMaximumSize())); + if (window_constraints.HasMinimumSize()) + content_constraints.set_minimum_size( + WindowSizeToContentSize(window_constraints.GetMinimumSize())); + SetContentSizeConstraints(content_constraints); +} + +extensions::SizeConstraints NativeWindow::GetSizeConstraints() { + extensions::SizeConstraints content_constraints = GetContentSizeConstraints(); + extensions::SizeConstraints window_constraints; + if (content_constraints.HasMaximumSize()) + window_constraints.set_maximum_size( + ContentSizeToWindowSize(content_constraints.GetMaximumSize())); + if (content_constraints.HasMinimumSize()) + window_constraints.set_minimum_size( + ContentSizeToWindowSize(content_constraints.GetMinimumSize())); + return window_constraints; +} + +void NativeWindow::SetContentSizeConstraints( + const extensions::SizeConstraints& size_constraints) { + size_constraints_ = size_constraints; +} + +extensions::SizeConstraints NativeWindow::GetContentSizeConstraints() { + return size_constraints_; +} + +void NativeWindow::SetMinimumSize(const gfx::Size& size) { + extensions::SizeConstraints size_constraints; + size_constraints.set_minimum_size(size); + SetSizeConstraints(size_constraints); +} + +gfx::Size NativeWindow::GetMinimumSize() { + return GetSizeConstraints().GetMinimumSize(); +} + +void NativeWindow::SetMaximumSize(const gfx::Size& size) { + extensions::SizeConstraints size_constraints; + size_constraints.set_maximum_size(size); + SetSizeConstraints(size_constraints); +} + +gfx::Size NativeWindow::GetMaximumSize() { + return GetSizeConstraints().GetMaximumSize(); +} + void NativeWindow::SetRepresentedFilename(const std::string& filename) { } diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index 751644e459..5387833064 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -19,6 +19,7 @@ #include "content/public/browser/readback_types.h" #include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_user_data.h" +#include "extensions/browser/app_window/size_constraints.h" #include "ui/gfx/image/image.h" #include "ui/gfx/image/image_skia.h" @@ -110,12 +111,18 @@ class NativeWindow : public base::SupportsUserData, virtual gfx::Size GetSize(); virtual void SetPosition(const gfx::Point& position); virtual gfx::Point GetPosition(); - virtual void SetContentSize(const gfx::Size& size) = 0; - virtual gfx::Size GetContentSize() = 0; - virtual void SetMinimumSize(const gfx::Size& size) = 0; - virtual gfx::Size GetMinimumSize() = 0; - virtual void SetMaximumSize(const gfx::Size& size) = 0; - virtual gfx::Size GetMaximumSize() = 0; + virtual void SetContentSize(const gfx::Size& size); + virtual gfx::Size GetContentSize(); + virtual void SetSizeConstraints( + const extensions::SizeConstraints& size_constraints); + virtual extensions::SizeConstraints GetSizeConstraints(); + virtual void SetContentSizeConstraints( + const extensions::SizeConstraints& size_constraints); + virtual extensions::SizeConstraints GetContentSizeConstraints(); + virtual void SetMinimumSize(const gfx::Size& size); + virtual gfx::Size GetMinimumSize(); + virtual void SetMaximumSize(const gfx::Size& size); + virtual gfx::Size GetMaximumSize(); virtual void SetResizable(bool resizable) = 0; virtual bool IsResizable() = 0; virtual void SetAlwaysOnTop(bool top) = 0; @@ -234,6 +241,10 @@ class NativeWindow : public base::SupportsUserData, NativeWindow(brightray::InspectableWebContents* inspectable_web_contents, const mate::Dictionary& options); + // Converts between content size to window size. + virtual gfx::Size ContentSizeToWindowSize(const gfx::Size& size); + virtual gfx::Size WindowSizeToContentSize(const gfx::Size& size); + // content::WebContentsObserver: void RenderViewCreated(content::RenderViewHost* render_view_host) override; void BeforeUnloadDialogCancelled() override; @@ -269,6 +280,9 @@ class NativeWindow : public base::SupportsUserData, // has to been explicitly provided. scoped_ptr draggable_region_; // used in custom drag. + // Minimum and maximum size, stored as content size. + extensions::SizeConstraints size_constraints_; + // Whether window can be resized larger than screen. bool enable_larger_than_screen_; diff --git a/atom/browser/native_window_mac.h b/atom/browser/native_window_mac.h index 20ad605314..60581a2d97 100644 --- a/atom/browser/native_window_mac.h +++ b/atom/browser/native_window_mac.h @@ -44,12 +44,8 @@ class NativeWindowMac : public NativeWindow { bool IsFullscreen() const override; void SetBounds(const gfx::Rect& bounds) override; gfx::Rect GetBounds() override; - void SetContentSize(const gfx::Size& size) override; - gfx::Size GetContentSize() override; - void SetMinimumSize(const gfx::Size& size) override; - gfx::Size GetMinimumSize() override; - void SetMaximumSize(const gfx::Size& size) override; - gfx::Size GetMaximumSize() override; + void SetContentSizeConstraints( + const extensions::SizeConstraints& size_constraints) override; void SetResizable(bool resizable) override; bool IsResizable() override; void SetAlwaysOnTop(bool top) override; @@ -89,6 +85,10 @@ class NativeWindowMac : public NativeWindow { const content::NativeWebKeyboardEvent&) override; private: + // NativeWindow: + gfx::Size ContentSizeToWindowSize(const gfx::Size& size) override; + gfx::Size WindowSizeToContentSize(const gfx::Size& size) override; + void InstallView(); void UninstallView(); diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 3e8dab2133..76f9b0d0de 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -22,6 +22,11 @@ namespace { +// Converts gfx::Size to NSSize. +inline NSSize ToNSSize(const gfx::Size& size) { + return NSMakeSize(size.width(), size.height()); +} + // Prevents window from resizing during the scope. class ScopedDisableResize { public: @@ -549,56 +554,18 @@ gfx::Rect NativeWindowMac::GetBounds() { return bounds; } -void NativeWindowMac::SetContentSize(const gfx::Size& size) { - if (!has_frame()) { - SetSize(size); - return; +void NativeWindowMac::SetContentSizeConstraints( + const extensions::SizeConstraints& size_constraints) { + NSView* content = [window_ contentView]; + if (size_constraints.HasMinimumSize()) { + NSSize min_size = ToNSSize(size_constraints.GetMinimumSize()); + [window_ setMinSize:[content convertSize:min_size toView:nil]]; } - - NSRect frame_nsrect = [window_ frame]; - NSSize frame = frame_nsrect.size; - NSSize content = [window_ contentRectForFrameRect:frame_nsrect].size; - - int width = size.width() + frame.width - content.width; - int height = size.height() + frame.height - content.height; - frame_nsrect.origin.y -= height - frame_nsrect.size.height; - frame_nsrect.size.width = width; - frame_nsrect.size.height = height; - [window_ setFrame:frame_nsrect display:YES]; -} - -gfx::Size NativeWindowMac::GetContentSize() { - if (!has_frame()) - return GetSize(); - - NSRect bounds = [[window_ contentView] bounds]; - return gfx::Size(bounds.size.width, bounds.size.height); -} - -void NativeWindowMac::SetMinimumSize(const gfx::Size& size) { - NSSize min_size = NSMakeSize(size.width(), size.height()); - NSView* content = [window_ contentView]; - [window_ setContentMinSize:[content convertSize:min_size toView:nil]]; -} - -gfx::Size NativeWindowMac::GetMinimumSize() { - NSView* content = [window_ contentView]; - NSSize min_size = [content convertSize:[window_ contentMinSize] - fromView:nil]; - return gfx::Size(min_size.width, min_size.height); -} - -void NativeWindowMac::SetMaximumSize(const gfx::Size& size) { - NSSize max_size = NSMakeSize(size.width(), size.height()); - NSView* content = [window_ contentView]; - [window_ setContentMaxSize:[content convertSize:max_size toView:nil]]; -} - -gfx::Size NativeWindowMac::GetMaximumSize() { - NSView* content = [window_ contentView]; - NSSize max_size = [content convertSize:[window_ contentMaxSize] - fromView:nil]; - return gfx::Size(max_size.width, max_size.height); + if (size_constraints.HasMaximumSize()) { + NSSize max_size = ToNSSize(size_constraints.GetMaximumSize()); + [window_ setMaxSize:[content convertSize:max_size toView:nil]]; + } + NativeWindow::SetContentSizeConstraints(size_constraints); } void NativeWindowMac::SetResizable(bool resizable) { @@ -821,6 +788,18 @@ void NativeWindowMac::HandleKeyboardEvent( } } +gfx::Size NativeWindowMac::ContentSizeToWindowSize(const gfx::Size& size) { + NSRect content = NSMakeRect(0, 0, size.width(), size.height()); + NSRect frame = [window_ frameRectForContentRect:content]; + return gfx::Size(frame.size); +} + +gfx::Size NativeWindowMac::WindowSizeToContentSize(const gfx::Size& size) { + NSRect frame = NSMakeRect(0, 0, size.width(), size.height()); + NSRect content = [window_ contentRectForFrameRect:frame]; + return gfx::Size(content.size); +} + void NativeWindowMac::InstallView() { // Make sure the bottom corner is rounded: http://crbug.com/396264. [[window_ contentView] setWantsLayer:YES]; diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index f9e2089a4e..1c7546854e 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -440,6 +440,22 @@ gfx::Rect NativeWindowViews::GetBounds() { return window_->GetWindowBoundsInScreen(); } +void NativeWindowViews::SetSizeConstraints( + const extensions::SizeConstraints& size_constraints) { +} + +extensions::SizeConstraints NativeWindowViews::GetSizeConstraints() { + return extensions::SizeConstraints(); +} + +void NativeWindowViews::SetContentSizeConstraints( + const extensions::SizeConstraints& size_constraints) { +} + +extensions::SizeConstraints NativeWindowViews::GetContentSizeConstraints() { + return extensions::SizeConstraints(); +} + void NativeWindowViews::SetContentSize(const gfx::Size& size) { if (!has_frame()) { NativeWindow::SetSize(size); diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index 2b2322f195..5a90e6a221 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -63,6 +63,12 @@ class NativeWindowViews : public NativeWindow, bool IsFullscreen() const override; void SetBounds(const gfx::Rect& bounds) override; gfx::Rect GetBounds() override; + void SetSizeConstraints( + const extensions::SizeConstraints& size_constraints) override; + extensions::SizeConstraints GetSizeConstraints() override; + void SetContentSizeConstraints( + const extensions::SizeConstraints& size_constraints) override; + extensions::SizeConstraints GetContentSizeConstraints() override; void SetContentSize(const gfx::Size& size) override; gfx::Size GetContentSize() override; void SetMinimumSize(const gfx::Size& size) override; diff --git a/chromium_src/extensions/browser/app_window/size_constraints.cc b/chromium_src/extensions/browser/app_window/size_constraints.cc new file mode 100644 index 0000000000..6d248c1601 --- /dev/null +++ b/chromium_src/extensions/browser/app_window/size_constraints.cc @@ -0,0 +1,83 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "extensions/browser/app_window/size_constraints.h" + +#include + +#include "ui/gfx/geometry/insets.h" + +namespace extensions { + +SizeConstraints::SizeConstraints() + : maximum_size_(kUnboundedSize, kUnboundedSize) {} + +SizeConstraints::SizeConstraints(const gfx::Size& min_size, + const gfx::Size& max_size) + : minimum_size_(min_size), maximum_size_(max_size) {} + +SizeConstraints::~SizeConstraints() {} + +// static +gfx::Size SizeConstraints::AddFrameToConstraints( + const gfx::Size& size_constraints, + const gfx::Insets& frame_insets) { + return gfx::Size( + size_constraints.width() == kUnboundedSize + ? kUnboundedSize + : size_constraints.width() + frame_insets.width(), + size_constraints.height() == kUnboundedSize + ? kUnboundedSize + : size_constraints.height() + frame_insets.height()); +} + +gfx::Size SizeConstraints::ClampSize(gfx::Size size) const { + const gfx::Size max_size = GetMaximumSize(); + if (max_size.width() != kUnboundedSize) + size.set_width(std::min(size.width(), max_size.width())); + if (max_size.height() != kUnboundedSize) + size.set_height(std::min(size.height(), max_size.height())); + size.SetToMax(GetMinimumSize()); + return size; +} + +bool SizeConstraints::HasMinimumSize() const { + const gfx::Size min_size = GetMinimumSize(); + return min_size.width() != kUnboundedSize || + min_size.height() != kUnboundedSize; +} + +bool SizeConstraints::HasMaximumSize() const { + const gfx::Size max_size = GetMaximumSize(); + return max_size.width() != kUnboundedSize || + max_size.height() != kUnboundedSize; +} + +bool SizeConstraints::HasFixedSize() const { + return !GetMinimumSize().IsEmpty() && GetMinimumSize() == GetMaximumSize(); +} + +gfx::Size SizeConstraints::GetMinimumSize() const { + return minimum_size_; +} + +gfx::Size SizeConstraints::GetMaximumSize() const { + return gfx::Size( + maximum_size_.width() == kUnboundedSize + ? kUnboundedSize + : std::max(maximum_size_.width(), minimum_size_.width()), + maximum_size_.height() == kUnboundedSize + ? kUnboundedSize + : std::max(maximum_size_.height(), minimum_size_.height())); +} + +void SizeConstraints::set_minimum_size(const gfx::Size& min_size) { + minimum_size_ = min_size; +} + +void SizeConstraints::set_maximum_size(const gfx::Size& max_size) { + maximum_size_ = max_size; +} + +} // namespace extensions diff --git a/chromium_src/extensions/browser/app_window/size_constraints.h b/chromium_src/extensions/browser/app_window/size_constraints.h new file mode 100644 index 0000000000..ecacf1e5eb --- /dev/null +++ b/chromium_src/extensions/browser/app_window/size_constraints.h @@ -0,0 +1,57 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef EXTENSIONS_BROWSER_APP_WINDOW_SIZE_CONSTRAINTS_H_ +#define EXTENSIONS_BROWSER_APP_WINDOW_SIZE_CONSTRAINTS_H_ + +#include "ui/gfx/geometry/size.h" + +namespace gfx { +class Insets; +} + +namespace extensions { + +class SizeConstraints { + public: + // The value SizeConstraints uses to represent an unbounded width or height. + // This is an enum so that it can be declared inline here. + enum { kUnboundedSize = 0 }; + + SizeConstraints(); + SizeConstraints(const gfx::Size& min_size, const gfx::Size& max_size); + ~SizeConstraints(); + + // Adds frame insets to a size constraint. + static gfx::Size AddFrameToConstraints(const gfx::Size& size_constraints, + const gfx::Insets& frame_insets); + + // Returns the bounds with its size clamped to the min/max size. + gfx::Size ClampSize(gfx::Size size) const; + + // When gfx::Size is used as a min/max size, a zero represents an unbounded + // component. This method checks whether either component is specified. + // Note we can't use gfx::Size::IsEmpty as it returns true if either width + // or height is zero. + bool HasMinimumSize() const; + bool HasMaximumSize() const; + + // This returns true if all components are specified, and min and max are + // equal. + bool HasFixedSize() const; + + gfx::Size GetMaximumSize() const; + gfx::Size GetMinimumSize() const; + + void set_minimum_size(const gfx::Size& min_size); + void set_maximum_size(const gfx::Size& max_size); + + private: + gfx::Size minimum_size_; + gfx::Size maximum_size_; +}; + +} // namespace extensions + +#endif // EXTENSIONS_BROWSER_APP_WINDOW_SIZE_CONSTRAINTS_H_ diff --git a/filenames.gypi b/filenames.gypi index 04b82992bc..a6e799cd67 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -429,6 +429,8 @@ 'chromium_src/chrome/renderer/tts_dispatcher.cc', 'chromium_src/chrome/renderer/tts_dispatcher.h', 'chromium_src/chrome/utility/utility_message_handler.h', + 'chromium_src/extensions/browser/app_window/size_constraints.cc', + 'chromium_src/extensions/browser/app_window/size_constraints.h', 'chromium_src/library_loaders/libspeechd_loader.cc', 'chromium_src/library_loaders/libspeechd.h', 'chromium_src/net/test/embedded_test_server/stream_listen_socket.cc', From a76ea00249286b791a3308230ea7179516ef38d0 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 5 Oct 2015 19:05:59 +0800 Subject: [PATCH 138/165] views: Implement NativeWindow::SetSizeConstraints --- atom/browser/native_window_views.cc | 139 +++++++++------------ atom/browser/native_window_views.h | 22 +--- atom/browser/ui/views/frameless_view.cc | 4 +- atom/browser/ui/views/native_frame_view.cc | 5 +- atom/browser/ui/views/native_frame_view.h | 6 +- atom/browser/ui/views/win_frame_view.cc | 4 +- 6 files changed, 71 insertions(+), 109 deletions(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 1c7546854e..fdcbe42205 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -186,7 +186,8 @@ NativeWindowViews::NativeWindowViews( // will not allow us to resize the window larger than scree. // Setting directly to INT_MAX somehow doesn't work, so we just devide // by 10, which should still be large enough. - maximum_size_.SetSize(INT_MAX / 10, INT_MAX / 10); + SetContentSizeConstraints(extensions::SizeConstraints( + gfx::Size(), gfx::Size(INT_MAX / 10, INT_MAX / 10))); int width = 800, height = 600; options.Get(switches::kWidth, &width); @@ -271,11 +272,6 @@ NativeWindowViews::NativeWindowViews( set_background(views::Background::CreateStandardPanelBackground()); AddChildView(web_view_); - if (has_frame() && - options.Get(switches::kUseContentSize, &use_content_size_) && - use_content_size_) - bounds = ContentBoundsToWindowBounds(bounds); - #if defined(OS_WIN) // Save initial window state. if (fullscreen) @@ -316,8 +312,14 @@ NativeWindowViews::NativeWindowViews( if (transparent() && !has_frame()) wm::SetShadowType(GetNativeWindow(), wm::SHADOW_TYPE_NONE); + gfx::Size size = bounds.size(); + if (has_frame() && + options.Get(switches::kUseContentSize, &use_content_size_) && + use_content_size_) + size = ContentSizeToWindowSize(size); + window_->UpdateWindowIcon(); - window_->CenterWindow(bounds.size()); + window_->CenterWindow(size); Layout(); } @@ -440,60 +442,6 @@ gfx::Rect NativeWindowViews::GetBounds() { return window_->GetWindowBoundsInScreen(); } -void NativeWindowViews::SetSizeConstraints( - const extensions::SizeConstraints& size_constraints) { -} - -extensions::SizeConstraints NativeWindowViews::GetSizeConstraints() { - return extensions::SizeConstraints(); -} - -void NativeWindowViews::SetContentSizeConstraints( - const extensions::SizeConstraints& size_constraints) { -} - -extensions::SizeConstraints NativeWindowViews::GetContentSizeConstraints() { - return extensions::SizeConstraints(); -} - -void NativeWindowViews::SetContentSize(const gfx::Size& size) { - if (!has_frame()) { - NativeWindow::SetSize(size); - return; - } - - gfx::Rect bounds = window_->GetWindowBoundsInScreen(); - bounds.set_size(size); - SetBounds(ContentBoundsToWindowBounds(bounds)); -} - -gfx::Size NativeWindowViews::GetContentSize() { - if (!has_frame()) - return GetSize(); - - gfx::Size content_size = - window_->non_client_view()->frame_view()->GetBoundsForClientView().size(); - if (menu_bar_ && menu_bar_visible_) - content_size.set_height(content_size.height() - kMenuBarHeight); - return content_size; -} - -void NativeWindowViews::SetMinimumSize(const gfx::Size& size) { - minimum_size_ = size; -} - -gfx::Size NativeWindowViews::GetMinimumSize() { - return minimum_size_; -} - -void NativeWindowViews::SetMaximumSize(const gfx::Size& size) { - maximum_size_ = size; -} - -gfx::Size NativeWindowViews::GetMaximumSize() { - return maximum_size_; -} - void NativeWindowViews::SetResizable(bool resizable) { #if defined(OS_WIN) // WS_MAXIMIZEBOX => Maximize button @@ -929,6 +877,47 @@ gfx::Size NativeWindowViews::WindowSizeToFramelessSize( return window_bounds.size(); } +gfx::Size NativeWindowViews::ContentSizeToWindowSize(const gfx::Size& size) { + if (!has_frame()) + return size; + + gfx::Size window_size(size); +#if defined(OS_WIN) + gfx::Rect dpi_bounds = + gfx::Rect(gfx::Point(), gfx::win::DIPToScreenSize(size)); + gfx::Rect window_bounds = gfx::win::ScreenToDIPRect( + window_->non_client_view()->GetWindowBoundsForClientBounds(dpi_bounds)); + window_size = window_bounds.size(); +#endif + + if (menu_bar_ && menu_bar_visible_) + window_size.set_height(window_size.height() + kMenuBarHeight); + return window_size; +} + +gfx::Size NativeWindowViews::WindowSizeToContentSize(const gfx::Size& size) { + if (!has_frame()) + return size; + + gfx::Size content_size(size); +#if defined(OS_WIN) + content_size = gfx::win::DIPToScreenSize(content_size); + RECT rect; + SetRectEmpty(&rect); + HWND hwnd = GetAcceleratedWidget(); + DWORD style = ::GetWindowLong(hwnd, GWL_STYLE); + DWORD ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE); + AdjustWindowRectEx(&rect, style, FALSE, ex_style); + content_size.set_width(content_size.width() - (rect.right - rect.left)); + content_size.set_height(content_size.height() - (rect.bottom - rect.top)); + content_size = gfx::win::ScreenToDIPSize(content_size); +#endif + + if (menu_bar_ && menu_bar_visible_) + content_size.set_height(content_size.height() - kMenuBarHeight); + return content_size; +} + void NativeWindowViews::HandleKeyboardEvent( content::WebContents*, const content::NativeWebKeyboardEvent& event) { @@ -970,6 +959,14 @@ void NativeWindowViews::HandleKeyboardEvent( } } +gfx::Size NativeWindowViews::GetMinimumSize() { + return NativeWindow::GetMinimumSize(); +} + +gfx::Size NativeWindowViews::GetMaximumSize() { + return NativeWindow::GetMaximumSize(); +} + bool NativeWindowViews::AcceleratorPressed(const ui::Accelerator& accelerator) { return accelerator_util::TriggerAcceleratorTableCommand( &accelerator_table_, accelerator); @@ -992,26 +989,6 @@ void NativeWindowViews::RegisterAccelerators(ui::MenuModel* menu_model) { } } -gfx::Rect NativeWindowViews::ContentBoundsToWindowBounds( - const gfx::Rect& bounds) { - gfx::Point origin = bounds.origin(); -#if defined(OS_WIN) - gfx::Rect dpi_bounds = gfx::win::DIPToScreenRect(bounds); - gfx::Rect window_bounds = gfx::win::ScreenToDIPRect( - window_->non_client_view()->GetWindowBoundsForClientBounds(dpi_bounds)); -#else - gfx::Rect window_bounds = - window_->non_client_view()->GetWindowBoundsForClientBounds(bounds); -#endif - // The window's position would also be changed, but we only want to change - // the size. - window_bounds.set_origin(origin); - - if (menu_bar_ && menu_bar_visible_) - window_bounds.set_height(window_bounds.height() + kMenuBarHeight); - return window_bounds; -} - ui::WindowShowState NativeWindowViews::GetRestoredState() { if (IsMaximized()) return ui::SHOW_STATE_MAXIMIZED; diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index 5a90e6a221..0e74410868 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -63,18 +63,6 @@ class NativeWindowViews : public NativeWindow, bool IsFullscreen() const override; void SetBounds(const gfx::Rect& bounds) override; gfx::Rect GetBounds() override; - void SetSizeConstraints( - const extensions::SizeConstraints& size_constraints) override; - extensions::SizeConstraints GetSizeConstraints() override; - void SetContentSizeConstraints( - const extensions::SizeConstraints& size_constraints) override; - extensions::SizeConstraints GetContentSizeConstraints() override; - void SetContentSize(const gfx::Size& size) override; - gfx::Size GetContentSize() override; - void SetMinimumSize(const gfx::Size& size) override; - gfx::Size GetMinimumSize() override; - void SetMaximumSize(const gfx::Size& size) override; - gfx::Size GetMaximumSize() override; void SetResizable(bool resizable) override; bool IsResizable() override; void SetAlwaysOnTop(bool top) override; @@ -148,20 +136,20 @@ class NativeWindowViews : public NativeWindow, #endif // NativeWindow: + gfx::Size ContentSizeToWindowSize(const gfx::Size& size) override; + gfx::Size WindowSizeToContentSize(const gfx::Size& size) override; void HandleKeyboardEvent( content::WebContents*, const content::NativeWebKeyboardEvent& event) override; // views::View: + gfx::Size GetMinimumSize() override; + gfx::Size GetMaximumSize() override; bool AcceleratorPressed(const ui::Accelerator& accelerator) override; // Register accelerators supported by the menu model. void RegisterAccelerators(ui::MenuModel* menu_model); - // Converts between client area and window area, since we include the menu bar - // in client area we need to substract/add menu bar's height in convertions. - gfx::Rect ContentBoundsToWindowBounds(const gfx::Rect& content_bounds); - // Returns the restore state for the window. ui::WindowShowState GetRestoredState(); @@ -203,8 +191,6 @@ class NativeWindowViews : public NativeWindow, bool use_content_size_; bool resizable_; std::string title_; - gfx::Size minimum_size_; - gfx::Size maximum_size_; gfx::Size widget_size_; DISALLOW_COPY_AND_ASSIGN(NativeWindowViews); diff --git a/atom/browser/ui/views/frameless_view.cc b/atom/browser/ui/views/frameless_view.cc index 03a31e0828..f5e28025e9 100644 --- a/atom/browser/ui/views/frameless_view.cc +++ b/atom/browser/ui/views/frameless_view.cc @@ -104,11 +104,11 @@ gfx::Size FramelessView::GetPreferredSize() const { } gfx::Size FramelessView::GetMinimumSize() const { - return window_->GetMinimumSize(); + return static_cast(window_)->GetMinimumSize(); } gfx::Size FramelessView::GetMaximumSize() const { - return window_->GetMaximumSize(); + return static_cast(window_)->GetMaximumSize(); } const char* FramelessView::GetClassName() const { diff --git a/atom/browser/ui/views/native_frame_view.cc b/atom/browser/ui/views/native_frame_view.cc index a434fb4349..134255f484 100644 --- a/atom/browser/ui/views/native_frame_view.cc +++ b/atom/browser/ui/views/native_frame_view.cc @@ -4,7 +4,7 @@ #include "atom/browser/ui/views/native_frame_view.h" -#include "atom/browser/native_window_views.h" +#include "atom/browser/native_window.h" namespace atom { @@ -14,8 +14,7 @@ const char kViewClassName[] = "AtomNativeFrameView"; } // namespace -NativeFrameView::NativeFrameView(NativeWindowViews* window, - views::Widget* widget) +NativeFrameView::NativeFrameView(NativeWindow* window, views::Widget* widget) : views::NativeFrameView(widget), window_(window) { } diff --git a/atom/browser/ui/views/native_frame_view.h b/atom/browser/ui/views/native_frame_view.h index acbe9cddc8..670459f1cb 100644 --- a/atom/browser/ui/views/native_frame_view.h +++ b/atom/browser/ui/views/native_frame_view.h @@ -9,13 +9,13 @@ namespace atom { -class NativeWindowViews; +class NativeWindow; // Like the views::NativeFrameView, but returns the min/max size from the // NativeWindowViews. class NativeFrameView : public views::NativeFrameView { public: - NativeFrameView(NativeWindowViews* window, views::Widget* widget); + NativeFrameView(NativeWindow* window, views::Widget* widget); protected: // views::View: @@ -24,7 +24,7 @@ class NativeFrameView : public views::NativeFrameView { const char* GetClassName() const override; private: - NativeWindowViews* window_; // weak ref. + NativeWindow* window_; // weak ref. DISALLOW_COPY_AND_ASSIGN(NativeFrameView); }; diff --git a/atom/browser/ui/views/win_frame_view.cc b/atom/browser/ui/views/win_frame_view.cc index d0338af19d..7106d8f759 100644 --- a/atom/browser/ui/views/win_frame_view.cc +++ b/atom/browser/ui/views/win_frame_view.cc @@ -41,13 +41,13 @@ int WinFrameView::NonClientHitTest(const gfx::Point& point) { gfx::Size WinFrameView::GetMinimumSize() const { gfx::Size size = window_->WindowSizeToFramelessSize( - window_->GetMinimumSize()); + FramelessView::GetMinimumSize()); return gfx::win::DIPToScreenSize(size); } gfx::Size WinFrameView::GetMaximumSize() const { gfx::Size size = window_->WindowSizeToFramelessSize( - window_->GetMaximumSize()); + FramelessView::GetMaximumSize()); return gfx::win::DIPToScreenSize(size); } From 279407f7a300e0914b5fdc6b0b6cb0fb3b23a2f8 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 5 Oct 2015 19:32:23 +0800 Subject: [PATCH 139/165] osx: Fix converting size for frameless window --- atom/browser/native_window_mac.mm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 76f9b0d0de..70c3cfc0cc 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -789,12 +789,18 @@ void NativeWindowMac::HandleKeyboardEvent( } gfx::Size NativeWindowMac::ContentSizeToWindowSize(const gfx::Size& size) { + if (!has_frame()) + return size; + NSRect content = NSMakeRect(0, 0, size.width(), size.height()); NSRect frame = [window_ frameRectForContentRect:content]; return gfx::Size(frame.size); } gfx::Size NativeWindowMac::WindowSizeToContentSize(const gfx::Size& size) { + if (!has_frame()) + return size; + NSRect frame = NSMakeRect(0, 0, size.width(), size.height()); NSRect content = [window_ contentRectForFrameRect:frame]; return gfx::Size(content.size); From a9b0111c3e312d5797d1d4e5e64447f50e856467 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 5 Oct 2015 20:03:43 +0800 Subject: [PATCH 140/165] views: Use the quicker way of return content size Converting content size to window size on high DPI systems will lose percise and have 1px offset sometimes. --- atom/browser/native_window_views.cc | 4 ++++ atom/browser/native_window_views.h | 1 + 2 files changed, 5 insertions(+) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index fdcbe42205..0264ac59e1 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -442,6 +442,10 @@ gfx::Rect NativeWindowViews::GetBounds() { return window_->GetWindowBoundsInScreen(); } +gfx::Size NativeWindowViews::GetContentSize() { + return web_view_->size(); +} + void NativeWindowViews::SetResizable(bool resizable) { #if defined(OS_WIN) // WS_MAXIMIZEBOX => Maximize button diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index 0e74410868..1ba02e89a3 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -63,6 +63,7 @@ class NativeWindowViews : public NativeWindow, bool IsFullscreen() const override; void SetBounds(const gfx::Rect& bounds) override; gfx::Rect GetBounds() override; + gfx::Size GetContentSize() override; void SetResizable(bool resizable) override; bool IsResizable() override; void SetAlwaysOnTop(bool top) override; From d19ead1907acbbf60b069f25709562d66cf6aad8 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 5 Oct 2015 20:09:29 +0800 Subject: [PATCH 141/165] osx: Call setContentMinSize in SetContentSizeConstraints --- atom/browser/native_window_mac.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 70c3cfc0cc..bb00a82451 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -559,11 +559,11 @@ void NativeWindowMac::SetContentSizeConstraints( NSView* content = [window_ contentView]; if (size_constraints.HasMinimumSize()) { NSSize min_size = ToNSSize(size_constraints.GetMinimumSize()); - [window_ setMinSize:[content convertSize:min_size toView:nil]]; + [window_ setContentMinSize:[content convertSize:min_size toView:nil]]; } if (size_constraints.HasMaximumSize()) { NSSize max_size = ToNSSize(size_constraints.GetMaximumSize()); - [window_ setMaxSize:[content convertSize:max_size toView:nil]]; + [window_ setContentMaxSize:[content convertSize:max_size toView:nil]]; } NativeWindow::SetContentSizeConstraints(size_constraints); } From e675407552c808a43dea74ad8796cd0fa9d8c05e Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 5 Oct 2015 20:36:28 +0800 Subject: [PATCH 142/165] Make min/max size respect use-content-size --- atom/browser/native_window.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index cad6942d2e..f8023222fb 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -119,15 +119,23 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) { } else if (options.Get(switches::kCenter, ¢er) && center) { Center(); } + extensions::SizeConstraints size_constraints; int min_height = 0, min_width = 0; if (options.Get(switches::kMinHeight, &min_height) | options.Get(switches::kMinWidth, &min_width)) { - SetMinimumSize(gfx::Size(min_width, min_height)); + size_constraints.set_minimum_size(gfx::Size(min_width, min_height)); } int max_height = INT_MAX, max_width = INT_MAX; if (options.Get(switches::kMaxHeight, &max_height) | options.Get(switches::kMaxWidth, &max_width)) { - SetMaximumSize(gfx::Size(max_width, max_height)); + size_constraints.set_maximum_size(gfx::Size(max_width, max_height)); + } + bool use_content_size = false; + options.Get(switches::kUseContentSize, &use_content_size); + if (use_content_size) { + SetContentSizeConstraints(size_constraints); + } else { + SetSizeConstraints(size_constraints); } bool resizable; if (options.Get(switches::kResizable, &resizable)) { From 3b1ee994e21f5afc361c830913bce175a37a6217 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 5 Oct 2015 20:37:08 +0800 Subject: [PATCH 143/165] views: Remove hack on setting min/max size for frameless window --- atom/browser/native_window_views.cc | 27 ------------------------- atom/browser/native_window_views.h | 2 -- atom/browser/ui/views/frameless_view.cc | 4 ++-- atom/browser/ui/views/win_frame_view.cc | 13 ------------ atom/browser/ui/views/win_frame_view.h | 2 -- 5 files changed, 2 insertions(+), 46 deletions(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 0264ac59e1..5cd99dbdef 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -854,33 +854,6 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) { } #endif -gfx::Size NativeWindowViews::WindowSizeToFramelessSize( - const gfx::Size& size) { - if (size.width() == 0 && size.height() == 0) - return size; - - gfx::Rect window_bounds = gfx::Rect(size); - if (use_content_size_) { - if (menu_bar_ && menu_bar_visible_) { - window_bounds.set_height(window_bounds.height() + kMenuBarHeight); - } - } else if (has_frame()) { -#if defined(OS_WIN) - gfx::Size frame_size = gfx::win::ScreenToDIPRect( - window_->non_client_view()->GetWindowBoundsForClientBounds( - gfx::Rect())).size(); -#else - gfx::Size frame_size = - window_->non_client_view()->GetWindowBoundsForClientBounds( - gfx::Rect()).size(); -#endif - window_bounds.set_height(window_bounds.height() - frame_size.height()); - window_bounds.set_width(window_bounds.width() - frame_size.width()); - } - - return window_bounds.size(); -} - gfx::Size NativeWindowViews::ContentSizeToWindowSize(const gfx::Size& size) { if (!has_frame()) return size; diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index 1ba02e89a3..35ca7b63e2 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -89,8 +89,6 @@ class NativeWindowViews : public NativeWindow, gfx::AcceleratedWidget GetAcceleratedWidget(); - gfx::Size WindowSizeToFramelessSize(const gfx::Size& size); - views::Widget* widget() const { return window_.get(); } #if defined(OS_WIN) diff --git a/atom/browser/ui/views/frameless_view.cc b/atom/browser/ui/views/frameless_view.cc index f5e28025e9..2ec4459f6b 100644 --- a/atom/browser/ui/views/frameless_view.cc +++ b/atom/browser/ui/views/frameless_view.cc @@ -104,11 +104,11 @@ gfx::Size FramelessView::GetPreferredSize() const { } gfx::Size FramelessView::GetMinimumSize() const { - return static_cast(window_)->GetMinimumSize(); + return window_->GetContentSizeConstraints().GetMinimumSize(); } gfx::Size FramelessView::GetMaximumSize() const { - return static_cast(window_)->GetMaximumSize(); + return window_->GetContentSizeConstraints().GetMaximumSize(); } const char* FramelessView::GetClassName() const { diff --git a/atom/browser/ui/views/win_frame_view.cc b/atom/browser/ui/views/win_frame_view.cc index 7106d8f759..fca7cb2334 100644 --- a/atom/browser/ui/views/win_frame_view.cc +++ b/atom/browser/ui/views/win_frame_view.cc @@ -5,7 +5,6 @@ #include "atom/browser/ui/views/win_frame_view.h" #include "atom/browser/native_window_views.h" -#include "ui/gfx/win/dpi.h" #include "ui/views/widget/widget.h" #include "ui/views/win/hwnd_util.h" @@ -39,18 +38,6 @@ int WinFrameView::NonClientHitTest(const gfx::Point& point) { return FramelessView::NonClientHitTest(point); } -gfx::Size WinFrameView::GetMinimumSize() const { - gfx::Size size = window_->WindowSizeToFramelessSize( - FramelessView::GetMinimumSize()); - return gfx::win::DIPToScreenSize(size); -} - -gfx::Size WinFrameView::GetMaximumSize() const { - gfx::Size size = window_->WindowSizeToFramelessSize( - FramelessView::GetMaximumSize()); - return gfx::win::DIPToScreenSize(size); -} - const char* WinFrameView::GetClassName() const { return kViewClassName; } diff --git a/atom/browser/ui/views/win_frame_view.h b/atom/browser/ui/views/win_frame_view.h index 825677bff3..b2c1ef3a15 100644 --- a/atom/browser/ui/views/win_frame_view.h +++ b/atom/browser/ui/views/win_frame_view.h @@ -20,8 +20,6 @@ class WinFrameView : public FramelessView { int NonClientHitTest(const gfx::Point& point) override; // views::View: - gfx::Size GetMinimumSize() const override; - gfx::Size GetMaximumSize() const override; const char* GetClassName() const override; private: From 857acd25741969d390dec96a23ad65a01fdd93a1 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 5 Oct 2015 21:06:57 +0800 Subject: [PATCH 144/165] win: Fix GetContentSize for minimized window --- atom/browser/native_window_views.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 5cd99dbdef..d7d6cf8add 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -443,6 +443,11 @@ gfx::Rect NativeWindowViews::GetBounds() { } gfx::Size NativeWindowViews::GetContentSize() { +#if defined(OS_WIN) + if (IsMinimized()) + return NativeWindow::GetContentSize(); +#endif + return web_view_->size(); } From 239b97cde16896e127d1f814549e26ee474a4abf Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Mon, 5 Oct 2015 16:51:49 +0300 Subject: [PATCH 145/165] Update process.md Fixed the `loaded` example according to [this](https://github.com/atom/electron/issues/2984#issuecomment-145465907) comment. --- docs/api/process.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/api/process.md b/docs/api/process.md index 4e0fa4d602..a2157886bc 100644 --- a/docs/api/process.md +++ b/docs/api/process.md @@ -21,9 +21,11 @@ the global scope when node integration is turned off: ```js // preload.js +var _setImmediate = setImmediate; +var _clearImmediate = clearImmediate; process.once('loaded', function() { - global.setImmediate = setImmediate; - global.clearImmediate = clearImmediate; + global.setImmediate = _setImmediate; + global.clearImmediate = _clearImmediate; }); ``` From ea3e84e7ff38393449c70e447019342766836e2d Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Mon, 5 Oct 2015 16:56:36 +0300 Subject: [PATCH 146/165] Update screen.md Removed a trailing comma. --- docs/api/screen.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/screen.md b/docs/api/screen.md index 3b6c276daf..42468da160 100644 --- a/docs/api/screen.md +++ b/docs/api/screen.md @@ -47,7 +47,7 @@ app.on('ready', function() { if (externalDisplay) { mainWindow = new BrowserWindow({ x: externalDisplay.bounds.x + 50, - y: externalDisplay.bounds.y + 50, + y: externalDisplay.bounds.y + 50 }); } }); From 87e0c812e9de44c96b33a65432decbd012c2d17a Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Mon, 5 Oct 2015 17:48:48 +0300 Subject: [PATCH 147/165] Update native modules doc --- docs/tutorial/using-native-node-modules.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/tutorial/using-native-node-modules.md b/docs/tutorial/using-native-node-modules.md index 0e6477fc4c..491415b900 100644 --- a/docs/tutorial/using-native-node-modules.md +++ b/docs/tutorial/using-native-node-modules.md @@ -6,16 +6,17 @@ the location of Electron's headers when building native modules. ## Native Node Module Compatibility -Since Node v0.11.x there were vital changes in the V8 API. So generally all -native modules written for Node v0.10.x won't work for newer Node or io.js -versions. And because Electron internally uses __io.js v3.1.0__, it has the -same problem. +Native modules might break when Node starts using a new version of V8. +To make sure the module you're interested in will work with Electron, you should +check if it supports the internal Node version used by Electron. +You can check what version of Node is used in Electron by looking it up in +the [releases](https://github.com/atom/electron/releases) page or by using +`process.version` (see [Quick Start](https://github.com/atom/electron/blob/master/docs/tutorial/quick-start.md) +for example). -To solve this, you should use modules that support Node v0.11.x or later, -[many modules](https://www.npmjs.org/browse/depended/nan) do support both now. -For old modules that only support Node v0.10.x, you should use the -[nan](https://github.com/rvagg/nan) module to port it to v0.11.x or later -versions of Node or io.js. +Consider using [NAN](https://github.com/nodejs/nan/) for your own modules, since +it makes it easier to support multiple versions of Node. It's also helpful for +porting old modules to newer versions of Node so they can work with Electron. ## How to Install Native Modules From bb4951514582b366a91b4367158e710f5cc1eee0 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 6 Oct 2015 00:13:57 +0800 Subject: [PATCH 148/165] Separate Windows specific code of NativeWindow to another file --- atom/browser/native_window_views.cc | 136 ---------------------- atom/browser/native_window_views_win.cc | 145 ++++++++++++++++++++++++ filenames.gypi | 1 + 3 files changed, 146 insertions(+), 136 deletions(-) create mode 100644 atom/browser/native_window_views_win.cc diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index d7d6cf8add..308e8ee3dc 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -77,70 +77,6 @@ bool IsAltModifier(const content::NativeWebKeyboardEvent& event) { (modifiers == (Modifiers::AltKey | Modifiers::IsRight)); } -#if defined(OS_WIN) -// Convert Win32 WM_APPCOMMANDS to strings. -const char* AppCommandToString(int command_id) { - switch (command_id) { - case APPCOMMAND_BROWSER_BACKWARD : return "browser-backward"; - case APPCOMMAND_BROWSER_FORWARD : return "browser-forward"; - case APPCOMMAND_BROWSER_REFRESH : return "browser-refresh"; - case APPCOMMAND_BROWSER_STOP : return "browser-stop"; - case APPCOMMAND_BROWSER_SEARCH : return "browser-search"; - case APPCOMMAND_BROWSER_FAVORITES : return "browser-favorites"; - case APPCOMMAND_BROWSER_HOME : return "browser-home"; - case APPCOMMAND_VOLUME_MUTE : return "volume-mute"; - case APPCOMMAND_VOLUME_DOWN : return "volume-down"; - case APPCOMMAND_VOLUME_UP : return "volume-up"; - case APPCOMMAND_MEDIA_NEXTTRACK : return "media-nexttrack"; - case APPCOMMAND_MEDIA_PREVIOUSTRACK : return "media-previoustrack"; - case APPCOMMAND_MEDIA_STOP : return "media-stop"; - case APPCOMMAND_MEDIA_PLAY_PAUSE : return "media-play_pause"; - case APPCOMMAND_LAUNCH_MAIL : return "launch-mail"; - case APPCOMMAND_LAUNCH_MEDIA_SELECT : return "launch-media-select"; - case APPCOMMAND_LAUNCH_APP1 : return "launch-app1"; - case APPCOMMAND_LAUNCH_APP2 : return "launch-app2"; - case APPCOMMAND_BASS_DOWN : return "bass-down"; - case APPCOMMAND_BASS_BOOST : return "bass-boost"; - case APPCOMMAND_BASS_UP : return "bass-up"; - case APPCOMMAND_TREBLE_DOWN : return "treble-down"; - case APPCOMMAND_TREBLE_UP : return "treble-up"; - case APPCOMMAND_MICROPHONE_VOLUME_MUTE : return "microphone-volume-mute"; - case APPCOMMAND_MICROPHONE_VOLUME_DOWN : return "microphone-volume-down"; - case APPCOMMAND_MICROPHONE_VOLUME_UP : return "microphone-volume-up"; - case APPCOMMAND_HELP : return "help"; - case APPCOMMAND_FIND : return "find"; - case APPCOMMAND_NEW : return "new"; - case APPCOMMAND_OPEN : return "open"; - case APPCOMMAND_CLOSE : return "close"; - case APPCOMMAND_SAVE : return "save"; - case APPCOMMAND_PRINT : return "print"; - case APPCOMMAND_UNDO : return "undo"; - case APPCOMMAND_REDO : return "redo"; - case APPCOMMAND_COPY : return "copy"; - case APPCOMMAND_CUT : return "cut"; - case APPCOMMAND_PASTE : return "paste"; - case APPCOMMAND_REPLY_TO_MAIL : return "reply-to-mail"; - case APPCOMMAND_FORWARD_MAIL : return "forward-mail"; - case APPCOMMAND_SEND_MAIL : return "send-mail"; - case APPCOMMAND_SPELL_CHECK : return "spell-check"; - case APPCOMMAND_MIC_ON_OFF_TOGGLE : return "mic-on-off-toggle"; - case APPCOMMAND_CORRECTION_LIST : return "correction-list"; - case APPCOMMAND_MEDIA_PLAY : return "media-play"; - case APPCOMMAND_MEDIA_PAUSE : return "media-pause"; - case APPCOMMAND_MEDIA_RECORD : return "media-record"; - case APPCOMMAND_MEDIA_FAST_FORWARD : return "media-fast-forward"; - case APPCOMMAND_MEDIA_REWIND : return "media-rewind"; - case APPCOMMAND_MEDIA_CHANNEL_UP : return "media-channel-up"; - case APPCOMMAND_MEDIA_CHANNEL_DOWN : return "media-channel-down"; - case APPCOMMAND_DELETE : return "delete"; - case APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE: - return "dictate-or-command-control-toggle"; - default: - return "unknown"; - } -} -#endif - class NativeWindowClientView : public views::ClientView { public: NativeWindowClientView(views::Widget* widget, @@ -787,78 +723,6 @@ void NativeWindowViews::OnWidgetMove() { NotifyWindowMove(); } -#if defined(OS_WIN) -bool NativeWindowViews::ExecuteWindowsCommand(int command_id) { - std::string command = AppCommandToString(command_id); - NotifyWindowExecuteWindowsCommand(command); - return false; -} - -bool NativeWindowViews::PreHandleMSG( - UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) { - switch (message) { - case WM_COMMAND: - // Handle thumbar button click message. - if (HIWORD(w_param) == THBN_CLICKED) - return taskbar_host_.HandleThumbarButtonEvent(LOWORD(w_param)); - return false; - case WM_SIZE: - // Handle window state change. - HandleSizeEvent(w_param, l_param); - return false; - default: - return false; - } -} - -void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) { - // Here we handle the WM_SIZE event in order to figure out what is the current - // window state and notify the user accordingly. - switch (w_param) { - case SIZE_MAXIMIZED: - last_window_state_ = ui::SHOW_STATE_MAXIMIZED; - NotifyWindowMaximize(); - break; - case SIZE_MINIMIZED: - last_window_state_ = ui::SHOW_STATE_MINIMIZED; - NotifyWindowMinimize(); - break; - case SIZE_RESTORED: - if (last_window_state_ == ui::SHOW_STATE_NORMAL) { - // Window was resized so we save it's new size. - last_normal_size_ = GetSize(); - } else { - switch (last_window_state_) { - case ui::SHOW_STATE_MAXIMIZED: - last_window_state_ = ui::SHOW_STATE_NORMAL; - - // When the window is restored we resize it to the previous known - // normal size. - NativeWindow::SetSize(last_normal_size_); - - NotifyWindowUnmaximize(); - break; - case ui::SHOW_STATE_MINIMIZED: - if (IsFullscreen()) { - last_window_state_ = ui::SHOW_STATE_FULLSCREEN; - NotifyWindowEnterFullScreen(); - } else { - last_window_state_ = ui::SHOW_STATE_NORMAL; - - // When the window is restored we resize it to the previous known - // normal size. - NativeWindow::SetSize(last_normal_size_); - - NotifyWindowRestore(); - } - break; - } - } - break; - } -} -#endif - gfx::Size NativeWindowViews::ContentSizeToWindowSize(const gfx::Size& size) { if (!has_frame()) return size; diff --git a/atom/browser/native_window_views_win.cc b/atom/browser/native_window_views_win.cc new file mode 100644 index 0000000000..79c5128943 --- /dev/null +++ b/atom/browser/native_window_views_win.cc @@ -0,0 +1,145 @@ +// Copyright (c) 2015 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#include "atom/browser/native_window_views.h" + +namespace atom { + +namespace { + +// Convert Win32 WM_APPCOMMANDS to strings. +const char* AppCommandToString(int command_id) { + switch (command_id) { + case APPCOMMAND_BROWSER_BACKWARD : return "browser-backward"; + case APPCOMMAND_BROWSER_FORWARD : return "browser-forward"; + case APPCOMMAND_BROWSER_REFRESH : return "browser-refresh"; + case APPCOMMAND_BROWSER_STOP : return "browser-stop"; + case APPCOMMAND_BROWSER_SEARCH : return "browser-search"; + case APPCOMMAND_BROWSER_FAVORITES : return "browser-favorites"; + case APPCOMMAND_BROWSER_HOME : return "browser-home"; + case APPCOMMAND_VOLUME_MUTE : return "volume-mute"; + case APPCOMMAND_VOLUME_DOWN : return "volume-down"; + case APPCOMMAND_VOLUME_UP : return "volume-up"; + case APPCOMMAND_MEDIA_NEXTTRACK : return "media-nexttrack"; + case APPCOMMAND_MEDIA_PREVIOUSTRACK : return "media-previoustrack"; + case APPCOMMAND_MEDIA_STOP : return "media-stop"; + case APPCOMMAND_MEDIA_PLAY_PAUSE : return "media-play_pause"; + case APPCOMMAND_LAUNCH_MAIL : return "launch-mail"; + case APPCOMMAND_LAUNCH_MEDIA_SELECT : return "launch-media-select"; + case APPCOMMAND_LAUNCH_APP1 : return "launch-app1"; + case APPCOMMAND_LAUNCH_APP2 : return "launch-app2"; + case APPCOMMAND_BASS_DOWN : return "bass-down"; + case APPCOMMAND_BASS_BOOST : return "bass-boost"; + case APPCOMMAND_BASS_UP : return "bass-up"; + case APPCOMMAND_TREBLE_DOWN : return "treble-down"; + case APPCOMMAND_TREBLE_UP : return "treble-up"; + case APPCOMMAND_MICROPHONE_VOLUME_MUTE : return "microphone-volume-mute"; + case APPCOMMAND_MICROPHONE_VOLUME_DOWN : return "microphone-volume-down"; + case APPCOMMAND_MICROPHONE_VOLUME_UP : return "microphone-volume-up"; + case APPCOMMAND_HELP : return "help"; + case APPCOMMAND_FIND : return "find"; + case APPCOMMAND_NEW : return "new"; + case APPCOMMAND_OPEN : return "open"; + case APPCOMMAND_CLOSE : return "close"; + case APPCOMMAND_SAVE : return "save"; + case APPCOMMAND_PRINT : return "print"; + case APPCOMMAND_UNDO : return "undo"; + case APPCOMMAND_REDO : return "redo"; + case APPCOMMAND_COPY : return "copy"; + case APPCOMMAND_CUT : return "cut"; + case APPCOMMAND_PASTE : return "paste"; + case APPCOMMAND_REPLY_TO_MAIL : return "reply-to-mail"; + case APPCOMMAND_FORWARD_MAIL : return "forward-mail"; + case APPCOMMAND_SEND_MAIL : return "send-mail"; + case APPCOMMAND_SPELL_CHECK : return "spell-check"; + case APPCOMMAND_MIC_ON_OFF_TOGGLE : return "mic-on-off-toggle"; + case APPCOMMAND_CORRECTION_LIST : return "correction-list"; + case APPCOMMAND_MEDIA_PLAY : return "media-play"; + case APPCOMMAND_MEDIA_PAUSE : return "media-pause"; + case APPCOMMAND_MEDIA_RECORD : return "media-record"; + case APPCOMMAND_MEDIA_FAST_FORWARD : return "media-fast-forward"; + case APPCOMMAND_MEDIA_REWIND : return "media-rewind"; + case APPCOMMAND_MEDIA_CHANNEL_UP : return "media-channel-up"; + case APPCOMMAND_MEDIA_CHANNEL_DOWN : return "media-channel-down"; + case APPCOMMAND_DELETE : return "delete"; + case APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE: + return "dictate-or-command-control-toggle"; + default: + return "unknown"; + } +} + +} // namespace + +bool NativeWindowViews::ExecuteWindowsCommand(int command_id) { + std::string command = AppCommandToString(command_id); + NotifyWindowExecuteWindowsCommand(command); + return false; +} + +bool NativeWindowViews::PreHandleMSG( + UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) { + switch (message) { + case WM_COMMAND: + // Handle thumbar button click message. + if (HIWORD(w_param) == THBN_CLICKED) + return taskbar_host_.HandleThumbarButtonEvent(LOWORD(w_param)); + return false; + case WM_SIZE: + // Handle window state change. + HandleSizeEvent(w_param, l_param); + return false; + default: + return false; + } +} + +void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) { + // Here we handle the WM_SIZE event in order to figure out what is the current + // window state and notify the user accordingly. + switch (w_param) { + case SIZE_MAXIMIZED: + last_window_state_ = ui::SHOW_STATE_MAXIMIZED; + NotifyWindowMaximize(); + break; + case SIZE_MINIMIZED: + last_window_state_ = ui::SHOW_STATE_MINIMIZED; + NotifyWindowMinimize(); + break; + case SIZE_RESTORED: + if (last_window_state_ == ui::SHOW_STATE_NORMAL) { + // Window was resized so we save it's new size. + last_normal_size_ = GetSize(); + } else { + switch (last_window_state_) { + case ui::SHOW_STATE_MAXIMIZED: + last_window_state_ = ui::SHOW_STATE_NORMAL; + + // When the window is restored we resize it to the previous known + // normal size. + SetSize(last_normal_size_); + + NotifyWindowUnmaximize(); + break; + case ui::SHOW_STATE_MINIMIZED: + if (IsFullscreen()) { + last_window_state_ = ui::SHOW_STATE_FULLSCREEN; + NotifyWindowEnterFullScreen(); + } else { + last_window_state_ = ui::SHOW_STATE_NORMAL; + + // When the window is restored we resize it to the previous known + // normal size. + SetSize(last_normal_size_); + + NotifyWindowRestore(); + } + break; + } + } + break; + } +} + +} // namespace atom diff --git a/filenames.gypi b/filenames.gypi index a6e799cd67..6418ba2872 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -154,6 +154,7 @@ 'atom/browser/mac/atom_application_delegate.mm', 'atom/browser/native_window.cc', 'atom/browser/native_window.h', + 'atom/browser/native_window_views_win.cc', 'atom/browser/native_window_views.cc', 'atom/browser/native_window_views.h', 'atom/browser/native_window_mac.h', From 60fb406c614af764b21df19ff1cc654ee2c1edda Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 6 Oct 2015 00:15:10 +0800 Subject: [PATCH 149/165] views: Fix content size constraints in window with menubar --- atom/browser/native_window_views.cc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 308e8ee3dc..0e04414b6a 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -519,8 +519,24 @@ void NativeWindowViews::SetMenu(ui::MenuModel* menu_model) { if (!menu_bar_autohide_) { SetMenuBarVisibility(true); - if (use_content_size_) + if (use_content_size_) { + // Enlarge the size constraints for the menu. + extensions::SizeConstraints constraints = GetContentSizeConstraints(); + if (constraints.HasMinimumSize()) { + gfx::Size min_size = constraints.GetMinimumSize(); + min_size.set_height(min_size.height() + kMenuBarHeight); + constraints.set_minimum_size(min_size); + } + if (constraints.HasMaximumSize()) { + gfx::Size max_size = constraints.GetMaximumSize(); + max_size.set_height(max_size.height() + kMenuBarHeight); + constraints.set_maximum_size(max_size); + } + SetContentSizeConstraints(constraints); + + // Resize the window to make sure content size is not changed. SetContentSize(content_size); + } } } From c8723238f8fc6abb68ad42a3f9411760e1fcd048 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 6 Oct 2015 00:21:37 +0800 Subject: [PATCH 150/165] win: Fix building on Windows --- atom/browser/native_window_views_win.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/atom/browser/native_window_views_win.cc b/atom/browser/native_window_views_win.cc index 79c5128943..6092a2242a 100644 --- a/atom/browser/native_window_views_win.cc +++ b/atom/browser/native_window_views_win.cc @@ -118,7 +118,7 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) { // When the window is restored we resize it to the previous known // normal size. - SetSize(last_normal_size_); + NativeWindow::SetSize(last_normal_size_); NotifyWindowUnmaximize(); break; @@ -131,7 +131,7 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) { // When the window is restored we resize it to the previous known // normal size. - SetSize(last_normal_size_); + NativeWindow::SetSize(last_normal_size_); NotifyWindowRestore(); } From b70e7c6a4cc51548769075f3f9925430e2435746 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 6 Oct 2015 00:39:16 +0800 Subject: [PATCH 151/165] Remove default definition of ContentSizeToWindowSize --- atom/browser/native_window.cc | 8 -------- atom/browser/native_window.h | 4 ++-- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index f8023222fb..641bdd3757 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -170,14 +170,6 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) { Show(); } -gfx::Size NativeWindow::ContentSizeToWindowSize(const gfx::Size& size) { - return size; -} - -gfx::Size NativeWindow::WindowSizeToContentSize(const gfx::Size& size) { - return size; -} - void NativeWindow::SetSize(const gfx::Size& size) { SetBounds(gfx::Rect(GetPosition(), size)); } diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index 5387833064..379c23837b 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -242,8 +242,8 @@ class NativeWindow : public base::SupportsUserData, const mate::Dictionary& options); // Converts between content size to window size. - virtual gfx::Size ContentSizeToWindowSize(const gfx::Size& size); - virtual gfx::Size WindowSizeToContentSize(const gfx::Size& size); + virtual gfx::Size ContentSizeToWindowSize(const gfx::Size& size) = 0; + virtual gfx::Size WindowSizeToContentSize(const gfx::Size& size) = 0; // content::WebContentsObserver: void RenderViewCreated(content::RenderViewHost* render_view_host) override; From ccf4ed907a2ad95bcbb35925ec9ddf59195605a6 Mon Sep 17 00:00:00 2001 From: Heilig Benedek Date: Mon, 5 Oct 2015 19:11:20 +0200 Subject: [PATCH 152/165] Fix some minor bugs related to KeyboardEvent sending --- atom/common/keyboad_util.cc | 7 ++++--- atom/common/native_mate_converters/blink_converter.cc | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/atom/common/keyboad_util.cc b/atom/common/keyboad_util.cc index 1baa829ff7..29d1a800c8 100644 --- a/atom/common/keyboad_util.cc +++ b/atom/common/keyboad_util.cc @@ -10,9 +10,10 @@ namespace atom { ui::KeyboardCode KeyboardCodeFromCharCode(char c, bool* shifted) { *shifted = false; switch (c) { - case 8: case 0x7F: return ui::VKEY_BACK; - case 9: return ui::VKEY_TAB; - case 0xD: case 3: return ui::VKEY_RETURN; + case 0x08: return ui::VKEY_BACK; + case 0x7F: return ui::VKEY_DELETE; + case 0x09: return ui::VKEY_TAB; + case 0x0D: return ui::VKEY_RETURN; case 0x1B: return ui::VKEY_ESCAPE; case ' ': return ui::VKEY_SPACE; diff --git a/atom/common/native_mate_converters/blink_converter.cc b/atom/common/native_mate_converters/blink_converter.cc index 0a599bfdf0..fcfc8905b3 100644 --- a/atom/common/native_mate_converters/blink_converter.cc +++ b/atom/common/native_mate_converters/blink_converter.cc @@ -61,7 +61,7 @@ struct Converter { else if (type == "mousewheel") *out = blink::WebInputEvent::MouseWheel; else if (type == "keydown") - *out = blink::WebInputEvent::KeyDown; + *out = blink::WebInputEvent::RawKeyDown; else if (type == "keyup") *out = blink::WebInputEvent::KeyUp; else if (type == "char") From c3cd438d34a265074c2896a688811d5f71f6d60a Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Mon, 5 Oct 2015 21:12:29 +0300 Subject: [PATCH 153/165] Replace io.js references with node.js references --- README.md | 2 +- docs/api/native-image.md | 2 +- docs/tutorial/quick-start.md | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fa122c9b6c..94d4c09982 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ :zap: *Formerly known as Atom Shell* :zap: The Electron framework lets you write cross-platform desktop applications -using JavaScript, HTML and CSS. It is based on [io.js](http://iojs.org) and +using JavaScript, HTML and CSS. It is based on [Node.js](https://nodejs.org) and [Chromium](http://www.chromium.org) and is used in the [Atom editor](https://github.com/atom/atom). diff --git a/docs/api/native-image.md b/docs/api/native-image.md index df2bb96ff9..097a8130c2 100644 --- a/docs/api/native-image.md +++ b/docs/api/native-image.md @@ -142,7 +142,7 @@ Returns a boolean whether the image is empty. Returns the size of the image. -[buffer]: https://iojs.org/api/buffer.html#buffer_class_buffer +[buffer]: https://nodejs.org/api/buffer.html#buffer_class_buffer ### `image.setTemplateImage(option)` diff --git a/docs/tutorial/quick-start.md b/docs/tutorial/quick-start.md index 94368df09c..5300d754a6 100644 --- a/docs/tutorial/quick-start.md +++ b/docs/tutorial/quick-start.md @@ -2,7 +2,7 @@ Electron enables you to create desktop applications with pure JavaScript by providing a runtime with rich native (operating system) APIs. You could see it -as a variant of the io.js runtime that is focused on desktop applications +as a variant of the Node.js runtime that is focused on desktop applications instead of web servers. This doesn't mean Electron is a JavaScript binding to graphical user interface @@ -22,8 +22,9 @@ multi-process architecture is also used. Each web page in Electron runs in its own process, which is called __the renderer process__. In normal browsers, web pages usually run in a sandboxed environment and are not -allowed access to native resources. Electron users, however, have the power to use -io.js APIs in web pages allowing lower level operating system interactions. +allowed access to native resources. Electron users, however, have the power to +use Node.js APIs in web pages allowing lower level operating system +interactions. ### Differences Between Main Process and Renderer Process @@ -129,7 +130,7 @@ Finally the `index.html` is the web page you want to show:

Hello World!

- We are using io.js + We are using Node.js and Electron . From db46c1b92561a7145ff1920de1b49c085cc2d380 Mon Sep 17 00:00:00 2001 From: Plusb Preco Date: Tue, 6 Oct 2015 13:48:39 +0900 Subject: [PATCH 154/165] Update as upstream --- docs-translations/ko-KR/api/process.md | 16 ++++++++++++++++ docs-translations/ko-KR/api/screen.md | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docs-translations/ko-KR/api/process.md b/docs-translations/ko-KR/api/process.md index f557f8cc6b..57ba0fa768 100644 --- a/docs-translations/ko-KR/api/process.md +++ b/docs-translations/ko-KR/api/process.md @@ -7,6 +7,22 @@ Electron의 `process` 객체는 기존의 node와는 달리 약간의 차이점 * `process.versions['chrome']` String - Chromium의 버전. * `process.resourcesPath` String - JavaScript 소스코드의 경로. +## Events + +### Event: 'loaded' + +Electron 내부 초기화 스크립트의 로드가 완료되고, 웹 페이지나 메인 스크립트를 로드하기 시작할 때 발생하는 이벤트입니다. + +이 이벤트는 preload 스크립트를 통해 node 통합이 꺼져있는 전역 스코프에 node의 전역 심볼들을 다시 추가할 때 사용할 수 있습니다: + +```javascript +// preload.js +process.once('loaded', function() { + global.setImmediate = setImmediate; + global.clearImmediate = clearImmediate; +}); +``` + ## Methods `process` 객체는 다음과 같은 메서드를 가지고 있습니다: diff --git a/docs-translations/ko-KR/api/screen.md b/docs-translations/ko-KR/api/screen.md index 2d3c02f854..de2d8baf4e 100644 --- a/docs-translations/ko-KR/api/screen.md +++ b/docs-translations/ko-KR/api/screen.md @@ -36,7 +36,7 @@ app.on('ready', function() { var displays = electronScreen.getAllDisplays(); var externalDisplay = null; for (var i in displays) { - if (displays[i].bounds.x > 0 || displays[i].bounds.y > 0) { + if (displays[i].bounds.x != 0 || displays[i].bounds.y != 0) { externalDisplay = displays[i]; break; } From 428c5b6d01fb0cc7aaa465ca98832d395e16e2b2 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 6 Oct 2015 14:50:18 +0800 Subject: [PATCH 155/165] Setting "x" and "y" should not change window size --- atom/browser/native_window.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 641bdd3757..981804cb22 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -112,10 +112,7 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) { int x = -1, y = -1; bool center; if (options.Get(switches::kX, &x) && options.Get(switches::kY, &y)) { - int width = -1, height = -1; - options.Get(switches::kWidth, &width); - options.Get(switches::kHeight, &height); - SetBounds(gfx::Rect(x, y, width, height)); + SetPosition(gfx::Point(x, y)); } else if (options.Get(switches::kCenter, ¢er) && center) { Center(); } From 6fea6cf58acbc00a66837628d3a20d5bd1938fa1 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 6 Oct 2015 15:15:23 +0800 Subject: [PATCH 156/165] osx: Fix setting size constraints for frameless window --- atom/browser/native_window_mac.mm | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index bb00a82451..5f867d9b1a 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -22,11 +22,6 @@ namespace { -// Converts gfx::Size to NSSize. -inline NSSize ToNSSize(const gfx::Size& size) { - return NSMakeSize(size.width(), size.height()); -} - // Prevents window from resizing during the scope. class ScopedDisableResize { public: @@ -556,13 +551,25 @@ gfx::Rect NativeWindowMac::GetBounds() { void NativeWindowMac::SetContentSizeConstraints( const extensions::SizeConstraints& size_constraints) { + auto convertSize = [this](const gfx::Size& size) { + // Our frameless window still has titlebar attached, so setting contentSize + // will result in actual content size being larger. + if (!has_frame()) { + NSRect frame = NSMakeRect(0, 0, size.width(), size.height()); + NSRect content = [window_ contentRectForFrameRect:frame]; + return content.size; + } else { + return NSMakeSize(size.width(), size.height()); + } + }; + NSView* content = [window_ contentView]; if (size_constraints.HasMinimumSize()) { - NSSize min_size = ToNSSize(size_constraints.GetMinimumSize()); + NSSize min_size = convertSize(size_constraints.GetMinimumSize()); [window_ setContentMinSize:[content convertSize:min_size toView:nil]]; } if (size_constraints.HasMaximumSize()) { - NSSize max_size = ToNSSize(size_constraints.GetMaximumSize()); + NSSize max_size = convertSize(size_constraints.GetMaximumSize()); [window_ setContentMaxSize:[content convertSize:max_size toView:nil]]; } NativeWindow::SetContentSizeConstraints(size_constraints); From 898db4d6bd5838b2461174726d022054f19f123e Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 6 Oct 2015 15:23:23 +0800 Subject: [PATCH 157/165] osx: Set resizable flag when creating window Setting resizable for frameless window before it is shown will change its size. --- atom/browser/native_window.cc | 2 ++ atom/browser/native_window_mac.mm | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 981804cb22..dd4694b3bd 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -134,10 +134,12 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) { } else { SetSizeConstraints(size_constraints); } +#if defined(OS_WIN) || defined(USE_X11) bool resizable; if (options.Get(switches::kResizable, &resizable)) { SetResizable(resizable); } +#endif bool top; if (options.Get(switches::kAlwaysOnTop, &top) && top) { SetAlwaysOnTop(true); diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 5f867d9b1a..6420345da9 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -350,6 +350,8 @@ NativeWindowMac::NativeWindowMac( bool useStandardWindow = true; options.Get(switches::kStandardWindow, &useStandardWindow); + bool resizable = true; + options.Get(switches::kResizable, &resizable); // New title bar styles are available in Yosemite or newer std::string titleBarStyle; @@ -357,10 +359,13 @@ NativeWindowMac::NativeWindowMac( options.Get(switches::kTitleBarStyle, &titleBarStyle); NSUInteger styleMask = NSTitledWindowMask | NSClosableWindowMask | - NSMiniaturizableWindowMask | NSResizableWindowMask; + NSMiniaturizableWindowMask; if (!useStandardWindow || transparent() || !has_frame()) { styleMask |= NSTexturedBackgroundWindowMask; } + if (resizable) { + styleMask |= NSResizableWindowMask; + } if ((titleBarStyle == "hidden") || (titleBarStyle == "hidden-inset")) { styleMask |= NSFullSizeContentViewWindowMask; styleMask |= NSUnifiedTitleAndToolbarWindowMask; From 8e4094793890cc060912fffb30849e7f7322cdec Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 6 Oct 2015 15:43:36 +0800 Subject: [PATCH 158/165] spec: Make window.open specs more reliable --- spec/chromium-spec.coffee | 41 ++++++++++++-------------- spec/fixtures/pages/window-opener.html | 5 +++- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/spec/chromium-spec.coffee b/spec/chromium-spec.coffee index a782079026..2c4853a0d6 100644 --- a/spec/chromium-spec.coffee +++ b/spec/chromium-spec.coffee @@ -4,10 +4,17 @@ https = require 'https' path = require 'path' ws = require 'ws' remote = require 'remote' +BrowserWindow = remote.require 'browser-window' describe 'chromium feature', -> fixtures = path.resolve __dirname, 'fixtures' + listener = null + afterEach -> + if listener? + window.removeEventListener 'message', listener + listener = null + xdescribe 'heap snapshot', -> it 'does not crash', -> process.atomBinding('v8_util').takeHeapSnapshot() @@ -24,20 +31,17 @@ describe 'chromium feature', -> $.get "http://127.0.0.1:#{port}" describe 'document.hidden', -> - BrowserWindow = remote.require 'browser-window' - ipc = remote.require 'ipc' url = "file://#{fixtures}/pages/document-hidden.html" w = null afterEach -> w?.destroy() - ipc.removeAllListeners 'hidden' it 'is set correctly when window is not shown', (done) -> - ipc.once 'hidden', (event, hidden) -> - assert hidden - done() w = new BrowserWindow(show:false) + w.webContents.on 'ipc-message', (event, args) -> + assert.deepEqual args, ['hidden', true] + done() w.loadUrl url describe 'navigator.webkitGetUserMedia', -> @@ -52,8 +56,6 @@ describe 'chromium feature', -> assert.notEqual navigator.language, '' describe 'window.open', -> - @timeout 10000 - it 'returns a BrowserWindowProxy object', -> b = window.open 'about:blank', '', 'show=no' assert.equal b.closed, false @@ -62,46 +64,41 @@ describe 'chromium feature', -> it 'accepts "node-integration" as feature', (done) -> listener = (event) -> - window.removeEventListener 'message', listener - b.close() assert.equal event.data, 'undefined' + b.close() done() window.addEventListener 'message', listener b = window.open "file://#{fixtures}/pages/window-opener-node.html", '', 'node-integration=no,show=no' it 'inherit options of parent window', (done) -> listener = (event) -> - window.removeEventListener 'message', listener - b.close() size = remote.getCurrentWindow().getSize() assert.equal event.data, "size: #{size.width} #{size.height}" + b.close() done() window.addEventListener 'message', listener b = window.open "file://#{fixtures}/pages/window-open-size.html", '', 'show=no' describe 'window.opener', -> - @timeout 10000 - - ipc = remote.require 'ipc' url = "file://#{fixtures}/pages/window-opener.html" w = null afterEach -> w?.destroy() - ipc.removeAllListeners 'opener' it 'is null for main window', (done) -> - ipc.once 'opener', (event, opener) -> - assert.equal opener, null - done() - BrowserWindow = remote.require 'browser-window' w = new BrowserWindow(show: false) + w.webContents.on 'ipc-message', (event, args) -> + assert.deepEqual args, ['opener', null] + done() w.loadUrl url it 'is not null for window opened by window.open', (done) -> - ipc.once 'opener', (event, opener) -> + listener = (event) -> + assert.equal event.data, 'object' b.close() - done(if opener isnt null then undefined else opener) + done() + window.addEventListener 'message', listener b = window.open url, '', 'show=no' describe 'window.opener.postMessage', -> diff --git a/spec/fixtures/pages/window-opener.html b/spec/fixtures/pages/window-opener.html index 0b5ecd556c..226b57dbd7 100644 --- a/spec/fixtures/pages/window-opener.html +++ b/spec/fixtures/pages/window-opener.html @@ -1,7 +1,10 @@ From f6327de7f748fe92de91aa6cc99db9df64c6fe09 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 6 Oct 2015 16:08:32 +0800 Subject: [PATCH 159/165] spec: Increase timeout for window.open specs --- spec/chromium-spec.coffee | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/chromium-spec.coffee b/spec/chromium-spec.coffee index 2c4853a0d6..a034f93782 100644 --- a/spec/chromium-spec.coffee +++ b/spec/chromium-spec.coffee @@ -56,6 +56,8 @@ describe 'chromium feature', -> assert.notEqual navigator.language, '' describe 'window.open', -> + @timeout 10000 + it 'returns a BrowserWindowProxy object', -> b = window.open 'about:blank', '', 'show=no' assert.equal b.closed, false @@ -80,6 +82,8 @@ describe 'chromium feature', -> b = window.open "file://#{fixtures}/pages/window-open-size.html", '', 'show=no' describe 'window.opener', -> + @timeout 10000 + url = "file://#{fixtures}/pages/window-opener.html" w = null From e06778178a1f5369c93530d678e6af059f59995b Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 6 Oct 2015 16:06:39 +0800 Subject: [PATCH 160/165] linux: Restore size constraints when became sizable --- atom/browser/native_window_views.cc | 19 +++++++++++++++---- atom/browser/native_window_views.h | 7 +++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 0e04414b6a..6d89ee1d06 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -387,6 +387,15 @@ gfx::Size NativeWindowViews::GetContentSize() { return web_view_->size(); } +void NativeWindowViews::SetContentSizeConstraints( + const extensions::SizeConstraints& size_constraints) { + NativeWindow::SetContentSizeConstraints(size_constraints); +#if defined(USE_X11) + if (resizable_) + old_size_constraints_ = size_constraints; +#endif +} + void NativeWindowViews::SetResizable(bool resizable) { #if defined(OS_WIN) // WS_MAXIMIZEBOX => Maximize button @@ -403,11 +412,13 @@ void NativeWindowViews::SetResizable(bool resizable) { // On Linux there is no "resizable" property of a window, we have to set // both the minimum and maximum size to the window size to achieve it. if (resizable) { - SetMaximumSize(gfx::Size()); - SetMinimumSize(gfx::Size()); + SetContentSizeConstraints(old_size_constraints_); } else { - SetMaximumSize(GetSize()); - SetMinimumSize(GetSize()); + old_size_constraints_ = GetContentSizeConstraints(); + resizable_ = false; + gfx::Size content_size = GetContentSize(); + SetContentSizeConstraints( + extensions::SizeConstraints(content_size, content_size)); } } #endif diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index 35ca7b63e2..0014acd073 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -64,6 +64,8 @@ class NativeWindowViews : public NativeWindow, void SetBounds(const gfx::Rect& bounds) override; gfx::Rect GetBounds() override; gfx::Size GetContentSize() override; + void SetContentSizeConstraints( + const extensions::SizeConstraints& size_constraints) override; void SetResizable(bool resizable) override; bool IsResizable() override; void SetAlwaysOnTop(bool top) override; @@ -165,6 +167,11 @@ class NativeWindowViews : public NativeWindow, // Handles window state events. scoped_ptr window_state_watcher_; + + // The "resizable" flag on Linux is implemented by setting size constraints, + // we need to make sure size constraints are restored when window becomes + // resizable again. + extensions::SizeConstraints old_size_constraints_; #elif defined(OS_WIN) // Weak ref. AtomDesktopWindowTreeHostWin* atom_desktop_window_tree_host_win_; From f607e81facac1dd27665ef4a81469ff1ea4bdd82 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 6 Oct 2015 16:16:02 +0800 Subject: [PATCH 161/165] views: Make size constraints work immediately after set --- atom/browser/native_window_views.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 6d89ee1d06..4c8d014b1e 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -390,6 +390,7 @@ gfx::Size NativeWindowViews::GetContentSize() { void NativeWindowViews::SetContentSizeConstraints( const extensions::SizeConstraints& size_constraints) { NativeWindow::SetContentSizeConstraints(size_constraints); + window_->OnSizeConstraintsChanged(); #if defined(USE_X11) if (resizable_) old_size_constraints_ = size_constraints; From c6d5a92d349bb376c4c6f78ed618b970d343258b Mon Sep 17 00:00:00 2001 From: Plusb Preco Date: Tue, 6 Oct 2015 19:53:35 +0900 Subject: [PATCH 162/165] Update as upstream --- README-ko.md | 2 +- docs-translations/ko-KR/api/native-image.md | 2 +- docs-translations/ko-KR/api/process.md | 6 ++++-- docs-translations/ko-KR/api/screen.md | 2 +- docs-translations/ko-KR/tutorial/quick-start.md | 6 +++--- .../ko-KR/tutorial/using-native-node-modules.md | 14 ++++++++------ 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/README-ko.md b/README-ko.md index 1481e7ce3d..c722243eb5 100644 --- a/README-ko.md +++ b/README-ko.md @@ -8,7 +8,7 @@ :zap: *프레임워크 이름이 Atom Shell에서 Electron으로 변경되었습니다* :zap: -Electron 프레임워크는 JavaScript, HTML 그리고 CSS를 사용하여 Cross-Platform 데스크톱 어플리케이션을 개발할 수 있도록 해주는 프레임워크입니다. 이 프레임워크는 [io.js](http://iojs.org) 와 +Electron 프레임워크는 JavaScript, HTML 그리고 CSS를 사용하여 Cross-Platform 데스크톱 어플리케이션을 개발할 수 있도록 해주는 프레임워크입니다. 이 프레임워크는 [Node.js](https://nodejs.org) 와 [Chromium](http://www.chromium.org)을 기반으로 만들어 졌으며 [Atom Editor](https://github.com/atom/atom)에 사용되고 있습니다. Electron에 대한 중요한 알림을 받고 싶다면 Twitter에서 [@ElectronJS](https://twitter.com/electronjs)를 팔로우 하세요. diff --git a/docs-translations/ko-KR/api/native-image.md b/docs-translations/ko-KR/api/native-image.md index 423cedb983..485ab7bc71 100644 --- a/docs-translations/ko-KR/api/native-image.md +++ b/docs-translations/ko-KR/api/native-image.md @@ -142,4 +142,4 @@ var image = NativeImage.createFromPath('/Users/somebody/images/icon.png'); 이미지가 템플릿 이미지인지 확인합니다. -[buffer]: https://iojs.org/api/buffer.html#buffer_class_buffer +[buffer]: https://nodejs.org/api/buffer.html#buffer_class_buffer diff --git a/docs-translations/ko-KR/api/process.md b/docs-translations/ko-KR/api/process.md index 57ba0fa768..a35c8b4e93 100644 --- a/docs-translations/ko-KR/api/process.md +++ b/docs-translations/ko-KR/api/process.md @@ -17,9 +17,11 @@ Electron 내부 초기화 스크립트의 로드가 완료되고, 웹 페이지 ```javascript // preload.js +var _setImmediate = setImmediate; +var _clearImmediate = clearImmediate; process.once('loaded', function() { - global.setImmediate = setImmediate; - global.clearImmediate = clearImmediate; + global.setImmediate = _setImmediate; + global.clearImmediate = _clearImmediate; }); ``` diff --git a/docs-translations/ko-KR/api/screen.md b/docs-translations/ko-KR/api/screen.md index de2d8baf4e..c65540eba2 100644 --- a/docs-translations/ko-KR/api/screen.md +++ b/docs-translations/ko-KR/api/screen.md @@ -45,7 +45,7 @@ app.on('ready', function() { if (externalDisplay) { mainWindow = new BrowserWindow({ x: externalDisplay.bounds.x + 50, - y: externalDisplay.bounds.y + 50, + y: externalDisplay.bounds.y + 50 }); } }); diff --git a/docs-translations/ko-KR/tutorial/quick-start.md b/docs-translations/ko-KR/tutorial/quick-start.md index 3edf13cc47..6eaad74769 100644 --- a/docs-translations/ko-KR/tutorial/quick-start.md +++ b/docs-translations/ko-KR/tutorial/quick-start.md @@ -3,7 +3,7 @@ ## 소개 Electron은 자바스크립트와 함께 제공된 풍부한 네이티브 API를 사용하여 멋진 데스크탑 어플리케이션을 만들 수 있도록 해주는 프레임워크입니다. -이 프레임워크의 io.js(node.js)는 웹 서버 개발이 아닌 데스크탑 어플리케이션 개발에 초점을 맞췄습니다. +이 프레임워크의 Node.js는 웹 서버 개발이 아닌 데스크탑 어플리케이션 개발에 초점을 맞췄습니다. 이 말은 Electron이 GUI 라이브러리의 자바스크립트 바인딩이라는 뜻이 아닙니다. 대신, Electron은 웹 페이지의 GUI를 사용합니다. 쉽게 말해 Electron은 자바스크립트를 사용하여 조작하는 작은 Chromium 브라우저로 볼 수 있습니다. @@ -19,7 +19,7 @@ Electron이 웹페이지를 보여줄 때 Chromium의 multi-processes 구조도 Electron 프로세스 내에서 작동하는 웹 페이지를 __랜더러 프로세스__ 라고 불립니다. 보통 일반 브라우저의 웹 페이지들은 샌드박스가 적용된 환경에서 작동하며 네이티브 리소스에는 접근할 수 없도록 되어 있습니다. -하지만 Electron은 웹 페이지 내에서 io.js(node.js) API를 사용하여 low-level 수준으로 운영체제와 상호작용할 수 있습니다. +하지만 Electron은 웹 페이지 내에서 Node.js API를 사용하여 low-level 수준으로 운영체제와 상호작용할 수 있습니다. ### 메인 프로세스와 랜더러 프로세스의 차이점 @@ -116,7 +116,7 @@ app.on('ready', function() {

헬로 월드!

- 이 어플리케이션은 io.js 과 + 이 어플리케이션은 Node.js 과 Electron 을 사용합니다. diff --git a/docs-translations/ko-KR/tutorial/using-native-node-modules.md b/docs-translations/ko-KR/tutorial/using-native-node-modules.md index ed64abb492..6a0c67770b 100644 --- a/docs-translations/ko-KR/tutorial/using-native-node-modules.md +++ b/docs-translations/ko-KR/tutorial/using-native-node-modules.md @@ -5,14 +5,16 @@ Electron에선 node.js 네이티브 모듈이 지원됩니다. 하지만 Electro ## 네이티브 node 모듈 호환성 -Node v0.11.x 버전부터는 V8 API의 중대한 변경이 있었습니다. 하지만 대부분의 네이티브 모듈은 Node v0.10.x 버전을 타겟으로 작성 되었기 때문에 -새로운 Node 또는 io.js 버전에서 작동하지 않을 수 있습니다. Electron은 내부적으로 __io.js v3.1.0__ 버전을 사용하기 때문에 호환성 문제가 발생할 수 있습니다. +네이티브 모듈은 node.js가 새로운 V8 버전을 사용함으로 인해 작동하지 않을 수 있습니다. +사용하는 네이티브 모듈이 Electron에 맞춰 작동할 수 있도록 하려면 Electron에서 사용하는 node.js의 버전을 확인할 필요가 있습니다. +Electron에서 사용하는 node 버전은 [releases](https://github.com/atom/electron/releases)에서 확인할 수 있으며 +`process.version`을 출력하여 버전을 확인할 수도 있습니다. ([시작하기](https://github.com/atom/electron/blob/master/docs/tutorial/quick-start.md)의 예제를 참고하세요) -이 문제를 해결하기 위해선 모듈이 v0.11.x 또는 최신 버전을 지원할 수 있도록 변경해야 합니다. -현재 [많은 모듈들](https://www.npmjs.org/browse/depended/nan)이 안정적으로 두 버전 모두 지원하고 있지만 오래된 모듈의 경우 여전히 Node v0.10.x 버전만을 지원하고 있습니다. -예를 들어 [nan](https://github.com/rvagg/nan) 모듈을 사용해야 한다면 Node v0.11.x 또는 최신 버전의 Node와 io.js로 포팅 할 필요가 있습니다. +혹시 직접 만든 네이티브 모듈이 있다면 [NAN](https://github.com/nodejs/nan/) 모듈을 사용하는 것을 고려해보는 것이 좋습니다. +이 모듈은 다중 버전의 node.js를 지원하기 쉽게 해줍니다. 이를 통해 오래된 모듈을 새 버전의 node.js에 맞게 포팅할 수 있습니다. +Electron도 이 모듈을 통해 포팅된 네이티브 모듈을 사용할 수 있습니다. -## 네이티브 모듈 설치하는 방법 +## 네이티브 모듈을 설치하는 방법 네이티브 모듈을 설치하는 방법은 세 가지 종류가 있습니다. From c916baa93968c6d874a94696a0f44868bbc18f11 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 6 Oct 2015 21:40:08 +0800 Subject: [PATCH 163/165] Update brightray, fix #2315 --- vendor/brightray | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/brightray b/vendor/brightray index c44f99278b..9e97c2b5bf 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit c44f99278bc4f6823f81b6f3a8d75881d697fd01 +Subproject commit 9e97c2b5bf5aa455f863bb29f99a219bdda4d29d From 927c3f34c3759e29948a1ffaa76a4985d38a1d69 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 6 Oct 2015 22:25:55 +0800 Subject: [PATCH 164/165] Guard against undefined, fix #2995 In theory this should never happen, seems like some object is garbage collected after the JavaScript context has been destroyed. --- atom/browser/lib/objects-registry.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/atom/browser/lib/objects-registry.coffee b/atom/browser/lib/objects-registry.coffee index ccfe2dbe0a..667adbc24e 100644 --- a/atom/browser/lib/objects-registry.coffee +++ b/atom/browser/lib/objects-registry.coffee @@ -34,6 +34,7 @@ class ObjectsRegistry extends EventEmitter @dereference id, 1 # Also reduce the count in owner. pointer = @owners[webContentsId] + return unless pointer? --pointer[id] delete pointer[id] if pointer[id] is 0 @@ -57,6 +58,7 @@ class ObjectsRegistry extends EventEmitter # Private: Dereference the object from store. dereference: (id, count) -> pointer = @storage[id] + return unless pointer? pointer.count -= count if pointer.count is 0 v8Util.deleteHiddenValue pointer.object, 'atomId' From 5bdc077b486885e5769230b40c4ae7f54b29aea9 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 6 Oct 2015 22:45:00 +0800 Subject: [PATCH 165/165] Update brightray for #2855 --- vendor/brightray | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/brightray b/vendor/brightray index 9e97c2b5bf..c25b9b2784 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 9e97c2b5bf5aa455f863bb29f99a219bdda4d29d +Subproject commit c25b9b27845a308e6a6a5966dad057d721b1f3d1