From 84cce6c2c1af84f83d417e8d2926a8ad3c2d73dd Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Sun, 15 May 2016 01:01:52 -0500 Subject: [PATCH] Don't default to "Open", "Save", just let OS decide --- atom/browser/atom_download_manager_delegate.cc | 2 +- atom/browser/common_web_contents_delegate.cc | 4 ++-- atom/browser/web_dialog_helper.cc | 4 ++-- lib/browser/api/dialog.js | 12 ++++-------- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/atom/browser/atom_download_manager_delegate.cc b/atom/browser/atom_download_manager_delegate.cc index 05e6899301..6d7e3c7172 100644 --- a/atom/browser/atom_download_manager_delegate.cc +++ b/atom/browser/atom_download_manager_delegate.cc @@ -78,7 +78,7 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated( base::FilePath path; if (file_dialog::ShowSaveDialog(window, item->GetURL().spec(), - "Save", default_path, + "", default_path, file_dialog::Filters(), &path)) { // Remember the last selected download directory. AtomBrowserContext* browser_context = static_cast( diff --git a/atom/browser/common_web_contents_delegate.cc b/atom/browser/common_web_contents_delegate.cc index b36566383b..2093b8f489 100644 --- a/atom/browser/common_web_contents_delegate.cc +++ b/atom/browser/common_web_contents_delegate.cc @@ -389,7 +389,7 @@ void CommonWebContentsDelegate::DevToolsSaveToFile( } else { file_dialog::Filters filters; base::FilePath default_path(base::FilePath::FromUTF8Unsafe(url)); - if (!file_dialog::ShowSaveDialog(owner_window(), url, "Save", default_path, + if (!file_dialog::ShowSaveDialog(owner_window(), url, "", default_path, filters, &path)) { base::StringValue url_value(url); web_contents_->CallClientFunction( @@ -455,7 +455,7 @@ void CommonWebContentsDelegate::DevToolsAddFileSystem( base::FilePath default_path; std::vector paths; int flag = file_dialog::FILE_DIALOG_OPEN_DIRECTORY; - if (!file_dialog::ShowOpenDialog(owner_window(), "", "Open", default_path, + if (!file_dialog::ShowOpenDialog(owner_window(), "", "", default_path, filters, flag, &paths)) return; diff --git a/atom/browser/web_dialog_helper.cc b/atom/browser/web_dialog_helper.cc index be43584a5b..2d2a9e5db8 100644 --- a/atom/browser/web_dialog_helper.cc +++ b/atom/browser/web_dialog_helper.cc @@ -84,7 +84,7 @@ void WebDialogHelper::RunFileChooser(content::WebContents* web_contents, base::FilePath path; if (file_dialog::ShowSaveDialog(window_, base::UTF16ToUTF8(params.title), - "Save", + "", params.default_file_name, filters, &path)) { @@ -115,7 +115,7 @@ void WebDialogHelper::RunFileChooser(content::WebContents* web_contents, prefs::kSelectFileLastDirectory).Append(params.default_file_name); if (file_dialog::ShowOpenDialog(window_, base::UTF16ToUTF8(params.title), - "Open", + "", default_file_path, filters, flags, diff --git a/lib/browser/api/dialog.js b/lib/browser/api/dialog.js index 55c8935b2a..73f5365570 100644 --- a/lib/browser/api/dialog.js +++ b/lib/browser/api/dialog.js @@ -76,11 +76,7 @@ module.exports = { throw new TypeError('Title must be a string') } if (options.buttonLabel == null) { - if (options.properties.indexOf('openDirectory') !== -1) { - options.buttonLabel = 'Choose' - } else { - options.buttonLabel = 'Open' - } + options.buttonLabel = '' } else if (typeof options.buttonLabel !== 'string') { throw new TypeError('buttonLabel must be a string') } @@ -95,7 +91,7 @@ module.exports = { wrappedCallback = typeof callback === 'function' ? function (success, result) { return callback(success ? result : void 0) } : null - return binding.showOpenDialog(String(options.title), String(options.buttonLabel), String(options.defaultPath), options.filters, properties, window, wrappedCallback) + return binding.showOpenDialog(options.title, options.buttonLabel, options.defaultPath, options.filters, properties, window, wrappedCallback) }, showSaveDialog: function (...args) { @@ -113,7 +109,7 @@ module.exports = { throw new TypeError('Title must be a string') } if (options.buttonLabel == null) { - options.buttonLabel = 'Save' + options.buttonLabel = '' } else if (typeof options.buttonLabel !== 'string') { throw new TypeError('buttonLabel must be a string') } @@ -128,7 +124,7 @@ module.exports = { wrappedCallback = typeof callback === 'function' ? function (success, result) { return callback(success ? result : void 0) } : null - return binding.showSaveDialog(String(options.title), String(options.buttonLabel), String(options.defaultPath), options.filters, window, wrappedCallback) + return binding.showSaveDialog(options.title, options.buttonLabel, options.defaultPath, options.filters, window, wrappedCallback) }, showMessageBox: function (...args) {