Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(646)

Unified Diff: chrome/utility/shell_handler_impl_win.cc

Issue 2122303002: Revive experiment to isolate shell operations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/utility/shell_handler_impl_win.cc
diff --git a/chrome/utility/shell_handler_impl_win.cc b/chrome/utility/shell_handler_impl_win.cc
index 6bcacda2359a3382f734cebdb0367763f29f7c10..1a883a682130018838eaee794c02d5513203a70c 100644
--- a/chrome/utility/shell_handler_impl_win.cc
+++ b/chrome/utility/shell_handler_impl_win.cc
@@ -17,6 +17,7 @@
#include "base/win/shortcut.h"
#include "chrome/installer/util/install_util.h"
#include "content/public/utility/utility_thread.h"
+#include "ui/base/win/open_file_name_win.h"
namespace {
@@ -222,3 +223,57 @@ void ShellHandlerImpl::IsPinnedToTaskbar(
bool is_pinned_to_taskbar = helper.GetResult();
callback.Run(!helper.error_occured(), is_pinned_to_taskbar);
}
+
+void ShellHandlerImpl::DoGetOpenFileName(
+ uint64_t owner,
+ uint32_t flags,
+ const std::vector<std::tuple<base::string16, base::string16>>& filters,
+ const base::FilePath& initial_directory,
+ const base::FilePath& filename,
+ const DoGetOpenFileNameCallback& callback) {
+ ui::win::OpenFileName open_file_name(reinterpret_cast<HWND>(owner), flags);
+ open_file_name.SetInitialSelection(initial_directory, filename);
+ open_file_name.SetFilters(filters);
+
+ base::FilePath directory;
+ std::vector<base::FilePath> filenames;
+
+ if (::GetOpenFileName(open_file_name.GetOPENFILENAME()))
+ open_file_name.GetResult(&directory, &filenames);
+
+ if (filenames.size()) {
sky 2016/07/08 15:28:21 nit: no {}, also !empty()
Patrick Monette 2016/07/08 19:36:10 Done.
+ callback.Run(directory, filenames);
+ } else {
+ callback.Run(base::FilePath(), std::vector<base::FilePath>());
+ }
+}
+
+void ShellHandlerImpl::DoGetSaveFileName(
+ uint64_t owner,
+ uint32_t flags,
+ const std::vector<std::tuple<base::string16, base::string16>>& filters,
+ uint32_t one_based_filter_index,
+ const base::FilePath& initial_directory,
+ const base::FilePath& suggested_filename,
+ const base::FilePath& default_extension,
+ const DoGetSaveFileNameCallback& callback) {
+ ui::win::OpenFileName open_file_name(reinterpret_cast<HWND>(owner), flags);
+ open_file_name.SetInitialSelection(initial_directory, suggested_filename);
+ open_file_name.SetFilters(filters);
+ open_file_name.GetOPENFILENAME()->nFilterIndex = one_based_filter_index;
+ open_file_name.GetOPENFILENAME()->lpstrDefExt =
+ default_extension.value().c_str();
+
+ if (::GetSaveFileName(open_file_name.GetOPENFILENAME())) {
+ callback.Run(base::FilePath(open_file_name.GetOPENFILENAME()->lpstrFile),
+ open_file_name.GetOPENFILENAME()->nFilterIndex);
+ return;
+ }
+
+ // Zero means the dialog was closed, otherwise we had an error.
+ DWORD error_code = ::CommDlgExtendedError();
+ if (error_code != 0)
+ NOTREACHED() << "GetSaveFileName failed with code: " << error_code;
+
+ callback.Run(base::FilePath(), 0);
+}

Powered by Google App Engine
This is Rietveld 408576698