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

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: Rebase 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..104a53706fc3d2112d685963518b6a46518f1f54 100644
--- a/chrome/utility/shell_handler_impl_win.cc
+++ b/chrome/utility/shell_handler_impl_win.cc
@@ -17,9 +17,14 @@
#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 {
+HWND Uint32ToHWND(uint32_t value) {
+ return reinterpret_cast<HWND>(value);
+}
+
// This class checks if the current executable is pinned to the taskbar. It also
// keeps track of the errors that occurs that prevents it from getting a result.
class IsPinnedToTaskbarHelper {
@@ -222,3 +227,56 @@ void ShellHandlerImpl::IsPinnedToTaskbar(
bool is_pinned_to_taskbar = helper.GetResult();
callback.Run(!helper.error_occured(), is_pinned_to_taskbar);
}
+
+void ShellHandlerImpl::DoGetOpenFileName(
+ uint32_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(Uint32ToHWND(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.empty())
+ callback.Run(directory, filenames);
+ else
+ callback.Run(base::FilePath(), std::vector<base::FilePath>());
+}
+
+void ShellHandlerImpl::DoGetSaveFileName(
+ uint32_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);
+}
« no previous file with comments | « chrome/utility/shell_handler_impl_win.h ('k') | mojo/public/tools/bindings/chromium_bindings_configuration.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698