From 04606a9f97b37d3563f365f48258f3fe9eeb4f6a Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 13 Jul 2015 13:51:18 +0800 Subject: [PATCH 01/13] Enable 'accept' attribute in 'input' label. --- atom/browser/web_dialog_helper.cc | 51 +++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/atom/browser/web_dialog_helper.cc b/atom/browser/web_dialog_helper.cc index f6f2334535..bbf16b5fc2 100644 --- a/atom/browser/web_dialog_helper.cc +++ b/atom/browser/web_dialog_helper.cc @@ -4,17 +4,61 @@ #include "atom/browser/web_dialog_helper.h" +#include #include #include "atom/browser/ui/file_dialog.h" #include "base/bind.h" #include "base/files/file_enumerator.h" +#include "base/files/file_path.h" #include "base/strings/utf_string_conversions.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "content/public/common/file_chooser_file_info.h" +#include "net/base/mime_util.h" #include "ui/shell_dialogs/selected_file_info.h" +namespace { + +file_dialog::Filters GetFileTypesFromAcceptType( + const std::vector& accept_types) { + file_dialog::Filters filters; + if (accept_types.empty()) + return filters; + + std::vector extensions; + + for (const auto& accept_type : accept_types) { + std::string ascii_type = base::UTF16ToASCII(accept_type); + if (ascii_type[0] == '.') { + // If the type starts with a period it is assumed to be a file extension, + // like `.txt`, // so we just have to add it to the list. + base::FilePath::StringType extension( + ascii_type.begin(), ascii_type.end()); + // Skip the first character. + extensions.push_back(extension.substr(1)); + } else { + if (ascii_type == "image/*" || ascii_type == "audio/*" || + ascii_type == "video/*") { + // For MIME Type + net::GetExtensionsForMimeType(ascii_type, &extensions); + } + } + } + + filters.push_back(file_dialog::Filter()); + for (const auto& extension : extensions) { +#if defined(OS_WIN) + filters[0].second.push_back(base::UTF16ToASCII(extension)); +#else + filters[0].second.push_back(extension); +#endif + } + return filters; +} + +} // namespace + namespace atom { WebDialogHelper::WebDialogHelper(NativeWindow* window) @@ -25,15 +69,18 @@ WebDialogHelper::WebDialogHelper(NativeWindow* window) WebDialogHelper::~WebDialogHelper() { } + void WebDialogHelper::RunFileChooser(content::WebContents* web_contents, const content::FileChooserParams& params) { std::vector result; + file_dialog::Filters filters = GetFileTypesFromAcceptType( + params.accept_types); if (params.mode == content::FileChooserParams::Save) { base::FilePath path; if (file_dialog::ShowSaveDialog(window_, base::UTF16ToUTF8(params.title), params.default_file_name, - file_dialog::Filters(), + filters, &path)) { content::FileChooserFileInfo info; info.file_path = path; @@ -59,7 +106,7 @@ void WebDialogHelper::RunFileChooser(content::WebContents* web_contents, if (file_dialog::ShowOpenDialog(window_, base::UTF16ToUTF8(params.title), params.default_file_name, - file_dialog::Filters(), + filters, flags, &paths)) { for (auto& path : paths) { From eadd2f8de6e29dccefc73c6b8b30568c203b7822 Mon Sep 17 00:00:00 2001 From: LYK Date: Mon, 13 Jul 2015 23:29:06 +0900 Subject: [PATCH 02/13] Update README-ko.md Remove a personal email address and repository. --- docs/README-ko.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/README-ko.md b/docs/README-ko.md index 50c4b2c9c9..b48c6a42c5 100644 --- a/docs/README-ko.md +++ b/docs/README-ko.md @@ -66,6 +66,3 @@ * [빌드 설명서 (Windows)](development/build-instructions-windows-ko.md) * [빌드 설명서 (Linux)](development/build-instructions-linux-ko.md) * [디버거에서 디버그 심볼 서버 설정](development/setting-up-symbol-server-ko.md) - -이 문서는 [@preco21](https://github.com/preco21) 에 의해 번역되었습니다. -문서내에서 오타나 잘못된 번역이 발견될 경우 해당 repo를 fork한 후 수정하여 PR을 올리거나 `plusb21@gmail.com` 이메일로 알려주시면 감사하겠습니다. From b3c51e46e71da8308b9245409731a9fd37a5f401 Mon Sep 17 00:00:00 2001 From: Peter Butcher Date: Tue, 14 Jul 2015 16:37:52 +0100 Subject: [PATCH 03/13] Update window-open.md Just an irritating typo. --- docs/api/window-open.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/window-open.md b/docs/api/window-open.md index 23bcf2b95f..fa10b2e7d0 100644 --- a/docs/api/window-open.md +++ b/docs/api/window-open.md @@ -2,7 +2,7 @@ When `window.open` is called to create a new window in web page, a new instance of `BrowserWindow` will be created for the `url`, and a proxy will be returned -to `window.open` to let the page to have limited control over it. +to `window.open` to let the page have limited control over it. The proxy only has some limited standard functionality implemented to be compatible with traditional web pages, for full control of the created window From ce2422612884b4189a98a6db6a85242fc267112b Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Tue, 14 Jul 2015 16:58:15 +0100 Subject: [PATCH 04/13] Update global-shortcut.md Improved the grammar and code formatting of global-shortcut.md. --- docs/api/global-shortcut.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/api/global-shortcut.md b/docs/api/global-shortcut.md index 16399cfbfe..54da5638d1 100644 --- a/docs/api/global-shortcut.md +++ b/docs/api/global-shortcut.md @@ -1,9 +1,9 @@ # global-shortcut The `global-shortcut` module can register/unregister a global keyboard shortcut -in operating system, so that you can customize the operations for various shortcuts. -Note that the shortcut is global, even if the app does not get focused, it will still work. -You should not use this module until the ready event of app module gets emitted. +with the operating system, so that you can customize the operations for various shortcuts. +Note that the shortcut is global; it will work even if the app does not have the keyboard focus. +You should not use this module until the `ready` event of the app module is emitted. ```javascript var app = require('app'); @@ -37,14 +37,14 @@ app.on('will-quit', function() { * `accelerator` [Accelerator](accelerator.md) * `callback` Function -Registers a global shortcut of `accelerator`, the `callback` would be called when -the registered shortcut is pressed by user. +Registers a global shortcut of `accelerator`. The `callback` is called when +the registered shortcut is pressed by the user. ## globalShortcut.isRegistered(accelerator) * `accelerator` [Accelerator](accelerator.md) -Returns `true` or `false` depending on if the shortcut `accelerator` is registered. +Returns `true` or `false` depending on whether the shortcut `accelerator` is registered. ## globalShortcut.unregister(accelerator) From 00c484c68bf55376b00a47081f4f937cfcaabf21 Mon Sep 17 00:00:00 2001 From: Antonio Stoilkov Date: Wed, 15 Jul 2015 17:29:02 +0300 Subject: [PATCH 05/13] fix typo in browser-window.md --- 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 61f985ed95..48a118ffa3 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -760,7 +760,7 @@ Calling `event.preventDefault()` can prevent creating new windows. * `event` Event * `url` String -Emitted when user or the page wants to start an navigation, it can happen when +Emitted when user or the page wants to start a navigation, it can happen when `window.location` object is changed or user clicks a link in the page. This event will not emit when the navigation is started programmatically with APIs From 9ee0d46734d1e357775833e2c4645c8073842dc9 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 15 Jul 2015 13:11:01 -0700 Subject: [PATCH 06/13] Use CTRL+SHIFT+I for toggling devtools, fix #2205 --- atom/browser/default_app/main.js | 2 +- docs/tutorial/quick-start.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/atom/browser/default_app/main.js b/atom/browser/default_app/main.js index 838cb4c2bb..fd3a6b596b 100644 --- a/atom/browser/default_app/main.js +++ b/atom/browser/default_app/main.js @@ -237,7 +237,7 @@ app.once('ready', function() { }, { label: 'Toggle &Developer Tools', - accelerator: 'Alt+Ctrl+I', + accelerator: 'Shift+Ctrl+I', click: function() { var focusedWindow = BrowserWindow.getFocusedWindow(); if (focusedWindow) diff --git a/docs/tutorial/quick-start.md b/docs/tutorial/quick-start.md index 8f723bbcf6..fc6d38674c 100644 --- a/docs/tutorial/quick-start.md +++ b/docs/tutorial/quick-start.md @@ -82,7 +82,7 @@ var mainWindow = null; // Quit when all windows are closed. app.on('window-all-closed', function() { - // On OSX it is common for applications and their menu bar + // On OSX it is common for applications and their menu bar // to stay active until the user quits explicitly with Cmd + Q if (process.platform != 'darwin') { app.quit(); From 4baaf03ac700cb8c9e21bc1a9271cc913bb66fa1 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Tue, 14 Jul 2015 21:28:57 +0100 Subject: [PATCH 07/13] Improve grammar and comments Improve the grammar and sentence structure of the text and improve the code comments. --- docs/tutorial/quick-start.md | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/docs/tutorial/quick-start.md b/docs/tutorial/quick-start.md index fc6d38674c..ae60fb27ec 100644 --- a/docs/tutorial/quick-start.md +++ b/docs/tutorial/quick-start.md @@ -4,39 +4,40 @@ Electron enables you to create desktop applications with pure JavaScript by providing a runtime with rich native APIs. You could see it as a variant of the io.js runtime which is focused on desktop applications instead of web servers. -It doesn't mean Electron is a JavaScript binding to GUI libraries. Instead, +This doesn't mean Electron is a JavaScript binding to GUI libraries. Instead, Electron uses web pages as its GUI, so you could also see it as a minimal Chromium browser, controlled by JavaScript. ### Main process In Electron, the process that runs `package.json`'s `main` script is called -__the main process__. The script that runs in the main process, can display GUI by +__the main process__. The script that runs in the main process can display a GUI by creating web pages. ### Renderer process Since Electron uses Chromium for displaying web pages, Chromium's -multi-processes architecture is also used. Each web page in Electron runs in +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 +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. ### Differences between main process and renderer process The main process creates web pages by creating `BrowserWindow` instances. Each `BrowserWindow` instance runs the web page in its own renderer process. When a `BrowserWindow` instance is destroyed, the corresponding renderer process -would also be terminated. +is also terminated. The main process manages all web pages and their corresponding renderer -processes, each renderer process is isolated and only cares +processes. Each renderer process is isolated and only cares about the web page running in it. In web pages, it is not allowed to call native GUI related APIs because managing -native GUI resources in web pages is very dangerous and easy to leak resources. -If you want to do GUI operations in web pages, you have to communicate with -the main process to do it there. +native GUI resources in web pages is very dangerous and it is easy to leak resources. +If you want to perform GUI operations in a web page, the renderer process of the web +page must communicate with the main process to request the main process perform those +operations. In Electron, we have provided the [ipc](../api/ipc-renderer.md) module for communication between main process and renderer process. And there is also a @@ -77,20 +78,20 @@ var BrowserWindow = require('browser-window'); // Module to create native brows require('crash-reporter').start(); // Keep a global reference of the window object, if you don't, the window will -// be closed automatically when the javascript object is GCed. +// be closed automatically when the JavaScript object is GCed. var mainWindow = null; // Quit when all windows are closed. app.on('window-all-closed', function() { - // On OSX it is common for applications and their menu bar + // On OS X it is common for applications and their menu bar // to stay active until the user quits explicitly with Cmd + Q if (process.platform != 'darwin') { app.quit(); } }); -// This method will be called when Electron has done everything -// initialization and ready for creating browser windows. +// This method will be called when Electron has finished +// initialization and is ready to create browser windows. app.on('ready', function() { // Create the browser window. mainWindow = new BrowserWindow({width: 800, height: 600}); From a2c26b8c744c8417db590604b37331ccf2ba8eb8 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 16 Jul 2015 03:48:35 -0700 Subject: [PATCH 08/13] Fix hanlding trailing slash in asar package, close #2222 --- atom/common/asar/archive.cc | 5 +++++ spec/asar-spec.coffee | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/atom/common/asar/archive.cc b/atom/common/asar/archive.cc index 79b82416cd..be99530c9c 100644 --- a/atom/common/asar/archive.cc +++ b/atom/common/asar/archive.cc @@ -54,6 +54,11 @@ bool GetChildNode(const base::DictionaryValue* root, const std::string& name, const base::DictionaryValue* dir, const base::DictionaryValue** out) { + if (name == "") { + *out = root; + return true; + } + const base::DictionaryValue* files = NULL; return GetFilesNode(root, dir, &files) && files->GetDictionaryWithoutPathExpansion(name, out); diff --git a/spec/asar-spec.coffee b/spec/asar-spec.coffee index 977676a193..a49417258f 100644 --- a/spec/asar-spec.coffee +++ b/spec/asar-spec.coffee @@ -85,6 +85,11 @@ describe 'asar package', -> done() describe 'fs.lstatSync', -> + it 'handles path with trailing slash correctly', -> + p = path.join fixtures, 'asar', 'a.asar', 'link2', 'link2', 'file1' + fs.lstatSync p + fs.lstatSync p + '/' + it 'returns information of root', -> p = path.join fixtures, 'asar', 'a.asar' stats = fs.lstatSync p @@ -136,6 +141,10 @@ describe 'asar package', -> assert.throws throws, /ENOENT/ describe 'fs.lstat', -> + it 'handles path with trailing slash correctly', (done) -> + p = path.join fixtures, 'asar', 'a.asar', 'link2', 'link2', 'file1' + fs.lstat p + '/', done + it 'returns information of root', (done) -> p = path.join fixtures, 'asar', 'a.asar' stats = fs.lstat p, (err, stats) -> From 21e5054facefa4c54b0927df7248560069ee00dd Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 13 Jul 2015 16:19:30 +0800 Subject: [PATCH 09/13] Make remember last used directory. --- atom/browser/web_dialog_helper.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/atom/browser/web_dialog_helper.cc b/atom/browser/web_dialog_helper.cc index bbf16b5fc2..93cb32cba7 100644 --- a/atom/browser/web_dialog_helper.cc +++ b/atom/browser/web_dialog_helper.cc @@ -7,10 +7,13 @@ #include #include +#include "atom/browser/atom_browser_context.h" +#include "atom/browser/native_window.h" #include "atom/browser/ui/file_dialog.h" #include "base/bind.h" #include "base/files/file_enumerator.h" #include "base/files/file_path.h" +#include "base/prefs/pref_service.h" #include "base/strings/utf_string_conversions.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" @@ -20,6 +23,8 @@ namespace { +const char kSelectFileLastDirectory[] = "selectfile.last_directory"; + file_dialog::Filters GetFileTypesFromAcceptType( const std::vector& accept_types) { file_dialog::Filters filters; @@ -103,9 +108,13 @@ void WebDialogHelper::RunFileChooser(content::WebContents* web_contents, } std::vector paths; + AtomBrowserContext* browser_context = static_cast( + window_->web_contents()->GetBrowserContext()); + base::FilePath default_file_path = browser_context->prefs()->GetFilePath( + kSelectFileLastDirectory).Append(params.default_file_name); if (file_dialog::ShowOpenDialog(window_, base::UTF16ToUTF8(params.title), - params.default_file_name, + default_file_path, filters, flags, &paths)) { @@ -115,6 +124,10 @@ void WebDialogHelper::RunFileChooser(content::WebContents* web_contents, info.display_name = path.BaseName().value(); result.push_back(info); } + if (!paths.empty()) { + browser_context->prefs()->SetFilePath(kSelectFileLastDirectory, + paths[0].DirName()); + } } } From db6d8de5dc6875f12bab2aee565eea36a278354f Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 16 Jul 2015 06:32:09 -0700 Subject: [PATCH 10/13] docs: Say more about standard scheme --- docs/api/protocol.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/api/protocol.md b/docs/api/protocol.md index a076e3640d..2734546516 100644 --- a/docs/api/protocol.md +++ b/docs/api/protocol.md @@ -37,6 +37,11 @@ Registers a custom protocol of `scheme`, the `handler` would be called with You need to return a request job in the `handler` to specify which type of response you would like to send. +By default the scheme is treated like `http:`, which is parsed differently +from protocols that follows "generic URI syntax" like `file:`, so you probably +want to call `protocol.registerStandardSchemes` to make your scheme treated as +standard scheme. + ## protocol.unregisterProtocol(scheme, callback) * `scheme` String @@ -48,7 +53,11 @@ Unregisters the custom protocol of `scheme`. * `value` Array -`value` is an array of custom schemes to be registered to the standard. +`value` is an array of custom schemes to be registered as standard schemes. + +A standard scheme adheres to what RFC 3986 calls +[generic URI syntax](https://tools.ietf.org/html/rfc3986#section-3). This +includes `file:` and `filesystem:`. ## protocol.isHandledProtocol(scheme, callback) From 88ab23def9d14188f4797d90cd60bbe68e4cd259 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 16 Jul 2015 06:36:10 -0700 Subject: [PATCH 11/13] Update brightray for #1852 --- vendor/brightray | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/brightray b/vendor/brightray index 6328c61041..c5f41a6edf 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 6328c6104131e623da87f479ea305b83169099b8 +Subproject commit c5f41a6edf6109e862c4c286d0c156e0099678e0 From 7ab8134613577b9092f5e8e81f1c883174bee222 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 17 Jul 2015 00:54:57 +0800 Subject: [PATCH 12/13] Don't upload PDB files in CI Somehow it is blocking. --- script/upload.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/script/upload.py b/script/upload.py index 9757fe6063..6fc421e6b7 100755 --- a/script/upload.py +++ b/script/upload.py @@ -90,10 +90,6 @@ def main(): upload_atom_shell(github, release, os.path.join(DIST_DIR, MKSNAPSHOT_NAME)) if PLATFORM == 'win32' and not tag_exists: - # Upload PDBs to Windows symbol server. - execute([sys.executable, - os.path.join(SOURCE_ROOT, 'script', 'upload-windows-pdb.py')]) - # Upload node headers. execute([sys.executable, os.path.join(SOURCE_ROOT, 'script', 'upload-node-headers.py'), From 135aca02af8aef5792984d47bf1c7a35a11f90a3 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 17 Jul 2015 01:01:25 +0800 Subject: [PATCH 13/13] Bump v0.30.0 --- atom.gyp | 2 +- atom/browser/resources/mac/Info.plist | 2 +- atom/browser/resources/win/atom.rc | 8 ++++---- atom/common/atom_version.h | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/atom.gyp b/atom.gyp index 83ea66adba..d8da82cd54 100644 --- a/atom.gyp +++ b/atom.gyp @@ -4,7 +4,7 @@ 'product_name%': 'Electron', 'company_name%': 'GitHub, Inc', 'company_abbr%': 'github', - 'version%': '0.29.2', + 'version%': '0.30.0', }, 'includes': [ 'filenames.gypi', diff --git a/atom/browser/resources/mac/Info.plist b/atom/browser/resources/mac/Info.plist index edbeda36e8..68ce951ed4 100644 --- a/atom/browser/resources/mac/Info.plist +++ b/atom/browser/resources/mac/Info.plist @@ -17,7 +17,7 @@ CFBundleIconFile atom.icns CFBundleVersion - 0.29.2 + 0.30.0 LSMinimumSystemVersion 10.8.0 NSMainNibFile diff --git a/atom/browser/resources/win/atom.rc b/atom/browser/resources/win/atom.rc index 7f6d618d48..80714c55fd 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,29,2,0 - PRODUCTVERSION 0,29,2,0 + FILEVERSION 0,30,0,0 + PRODUCTVERSION 0,30,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -74,12 +74,12 @@ BEGIN BEGIN VALUE "CompanyName", "GitHub, Inc." VALUE "FileDescription", "Electron" - VALUE "FileVersion", "0.29.2" + VALUE "FileVersion", "0.30.0" VALUE "InternalName", "electron.exe" VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved." VALUE "OriginalFilename", "electron.exe" VALUE "ProductName", "Electron" - VALUE "ProductVersion", "0.29.2" + VALUE "ProductVersion", "0.30.0" VALUE "SquirrelAwareVersion", "1" END END diff --git a/atom/common/atom_version.h b/atom/common/atom_version.h index f8543df727..64d0c7bfd7 100644 --- a/atom/common/atom_version.h +++ b/atom/common/atom_version.h @@ -6,8 +6,8 @@ #define ATOM_VERSION_H #define ATOM_MAJOR_VERSION 0 -#define ATOM_MINOR_VERSION 29 -#define ATOM_PATCH_VERSION 2 +#define ATOM_MINOR_VERSION 30 +#define ATOM_PATCH_VERSION 0 #define ATOM_VERSION_IS_RELEASE 1