• 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   // Extend blink::mojom::FileChooserParams with some options unique to CEF.
21   struct FileChooserParams : public blink::mojom::FileChooserParams {
22     // 0-based index of the selected value in |accept_types|.
23     int selected_accept_filter = 0;
24 
25     // True if the Save dialog should prompt before overwriting files.
26     bool overwriteprompt = true;
27 
28     // True if read-only files should be hidden.
29     bool hidereadonly = true;
30   };
31 
32   // The argument vector will be empty if the dialog was canceled.
33   typedef base::OnceCallback<void(int, const std::vector<base::FilePath>&)>
34       RunFileChooserCallback;
35 
36   // Display the file chooser dialog. Execute |callback| on completion.
37   virtual void Run(AlloyBrowserHostImpl* browser,
38                    const FileChooserParams& params,
39                    RunFileChooserCallback callback) = 0;
40 
41  protected:
42   // Allow deletion via scoped_ptr only.
43   friend std::default_delete<CefFileDialogRunner>;
44 
CefFileDialogRunner()45   CefFileDialogRunner() {}
~CefFileDialogRunner()46   virtual ~CefFileDialogRunner() {}
47 
48  private:
49   DISALLOW_COPY_AND_ASSIGN(CefFileDialogRunner);
50 };
51 
52 #endif  // CEF_LIBCEF_BROWSER_FILE_DIALOG_RUNNER_H_
53