• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 The Chromium Embedded Framework Authors.
2 // Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 
6 #ifndef CEF_LIBCEF_BROWSER_FILE_DIALOG_RUNNER_H_
7 #define CEF_LIBCEF_BROWSER_FILE_DIALOG_RUNNER_H_
8 #pragma once
9 
10 #include <vector>
11 
12 #include "base/callback.h"
13 #include "base/files/file_path.h"
14 #include "third_party/blink/public/mojom/choosers/file_chooser.mojom.h"
15 
16 class AlloyBrowserHostImpl;
17 
18 class CefFileDialogRunner {
19  public:
20   CefFileDialogRunner(const CefFileDialogRunner&) = delete;
21   CefFileDialogRunner& operator=(const CefFileDialogRunner&) = delete;
22 
23   // Extend blink::mojom::FileChooserParams with some options unique to CEF.
24   struct FileChooserParams : public blink::mojom::FileChooserParams {
25     // 0-based index of the selected value in |accept_types|.
26     int selected_accept_filter = 0;
27 
28     // True if the Save dialog should prompt before overwriting files.
29     bool overwriteprompt = true;
30 
31     // True if read-only files should be hidden.
32     bool hidereadonly = true;
33   };
34 
35   // The argument vector will be empty if the dialog was canceled.
36   using RunFileChooserCallback =
37       base::OnceCallback<void(int, const std::vector<base::FilePath>&)>;
38 
39   // Display the file chooser dialog. Execute |callback| on completion.
40   virtual void Run(AlloyBrowserHostImpl* browser,
41                    const FileChooserParams& params,
42                    RunFileChooserCallback callback) = 0;
43 
44  protected:
45   // Allow deletion via std::unique_ptr only.
46   friend std::default_delete<CefFileDialogRunner>;
47 
48   CefFileDialogRunner() = default;
49   virtual ~CefFileDialogRunner() = default;
50 };
51 
52 #endif  // CEF_LIBCEF_BROWSER_FILE_DIALOG_RUNNER_H_
53