From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- widget/windows/filedialog/WinFileDialogCommands.h | 74 +++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 widget/windows/filedialog/WinFileDialogCommands.h (limited to 'widget/windows/filedialog/WinFileDialogCommands.h') diff --git a/widget/windows/filedialog/WinFileDialogCommands.h b/widget/windows/filedialog/WinFileDialogCommands.h new file mode 100644 index 0000000000..ca4561a8f2 --- /dev/null +++ b/widget/windows/filedialog/WinFileDialogCommands.h @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef widget_windows_filedialog_WinFileDialogCommands_h__ +#define widget_windows_filedialog_WinFileDialogCommands_h__ + +#include "ipc/EnumSerializer.h" +#include "mozilla/Logging.h" +#include "mozilla/MozPromise.h" +#include "mozilla/ipc/MessageLink.h" +#include "mozilla/widget/filedialog/WinFileDialogCommandsDefn.h" + +// Windows interface types, defined in +struct IFileDialog; +struct IFileOpenDialog; + +namespace mozilla::widget::filedialog { + +extern LazyLogModule sLogFileDialog; + +enum class FileDialogType : uint8_t { Open, Save }; + +// Create a file-dialog of the relevant type. Requires MSCOM to be initialized. +mozilla::Result, HRESULT> MakeFileDialog(FileDialogType); + +// Apply the selected commands to the IFileDialog, in preparation for showing +// it. (The actual showing step is left to the caller.) +[[nodiscard]] HRESULT ApplyCommands(::IFileDialog*, + nsTArray const& commands); + +// Extract one or more results from the file-picker dialog. +// +// Requires that Show() has been called and has returned S_OK. +mozilla::Result GetFileResults(::IFileDialog*); + +// Extract the chosen folder from the folder-picker dialog. +// +// Requires that Show() has been called and has returned S_OK. +mozilla::Result GetFolderResults(::IFileDialog*); + +namespace detail { +// Log the error. If it's a notable error, kill the child process. +void LogProcessingError(LogModule* aModule, ipc::IProtocol* aCaller, + ipc::HasResultCodes::Result aCode, const char* aReason); + +} // namespace detail + +template +using Promise = MozPromise; + +// Show a file-picker on another thread in the current process. +RefPtr>> SpawnFilePicker(HWND parent, + FileDialogType type, + nsTArray commands); + +// Show a folder-picker on another thread in the current process. +RefPtr>> SpawnFolderPicker(HWND parent, + nsTArray commands); + +} // namespace mozilla::widget::filedialog + +namespace IPC { +template <> +struct ParamTraits + : public ContiguousEnumSerializerInclusive< + mozilla::widget::filedialog::FileDialogType, + mozilla::widget::filedialog::FileDialogType::Open, + mozilla::widget::filedialog::FileDialogType::Save> {}; +} // namespace IPC + +#endif // widget_windows_filedialog_WinFileDialogCommands_h__ -- cgit v1.2.3