2015-11-17 19:20:13 +01:00
|
|
|
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_BROWSER_FILE_DIALOG_RUNNER_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_FILE_DIALOG_RUNNER_H_
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "base/callback.h"
|
2017-05-17 11:29:28 +02:00
|
|
|
#include "base/files/file_path.h"
|
2018-10-02 14:14:11 +02:00
|
|
|
#include "third_party/blink/public/mojom/choosers/file_chooser.mojom.h"
|
2015-11-17 19:20:13 +01:00
|
|
|
|
2020-09-22 21:54:02 +02:00
|
|
|
class AlloyBrowserHostImpl;
|
2015-11-17 19:20:13 +01:00
|
|
|
|
|
|
|
class CefFileDialogRunner {
|
|
|
|
public:
|
2021-12-06 21:40:25 +01:00
|
|
|
CefFileDialogRunner(const CefFileDialogRunner&) = delete;
|
|
|
|
CefFileDialogRunner& operator=(const CefFileDialogRunner&) = delete;
|
|
|
|
|
2018-10-02 14:14:11 +02:00
|
|
|
// Extend blink::mojom::FileChooserParams with some options unique to CEF.
|
|
|
|
struct FileChooserParams : public blink::mojom::FileChooserParams {
|
2015-11-17 19:20:13 +01:00
|
|
|
// 0-based index of the selected value in |accept_types|.
|
|
|
|
int selected_accept_filter = 0;
|
|
|
|
|
|
|
|
// True if the Save dialog should prompt before overwriting files.
|
|
|
|
bool overwriteprompt = true;
|
|
|
|
|
|
|
|
// True if read-only files should be hidden.
|
|
|
|
bool hidereadonly = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
// The argument vector will be empty if the dialog was canceled.
|
2021-12-06 21:40:25 +01:00
|
|
|
using RunFileChooserCallback =
|
|
|
|
base::OnceCallback<void(int, const std::vector<base::FilePath>&)>;
|
2015-11-17 19:20:13 +01:00
|
|
|
|
|
|
|
// Display the file chooser dialog. Execute |callback| on completion.
|
2020-09-22 21:54:02 +02:00
|
|
|
virtual void Run(AlloyBrowserHostImpl* browser,
|
2015-11-17 19:20:13 +01:00
|
|
|
const FileChooserParams& params,
|
|
|
|
RunFileChooserCallback callback) = 0;
|
|
|
|
|
|
|
|
protected:
|
2021-06-17 22:08:01 +02:00
|
|
|
// Allow deletion via std::unique_ptr only.
|
2015-12-09 17:10:16 +01:00
|
|
|
friend std::default_delete<CefFileDialogRunner>;
|
2015-11-17 19:20:13 +01:00
|
|
|
|
2021-12-06 21:40:25 +01:00
|
|
|
CefFileDialogRunner() = default;
|
|
|
|
virtual ~CefFileDialogRunner() = default;
|
2015-11-17 19:20:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_FILE_DIALOG_RUNNER_H_
|