OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef EXTENSIONS_BROWSER_API_FILE_SYSTEM_FILE_SYSTEM_DELEGATE_H_ |
| 6 #define EXTENSIONS_BROWSER_API_FILE_SYSTEM_FILE_SYSTEM_DELEGATE_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/callback_forward.h" |
| 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" |
| 15 #include "build/build_config.h" |
| 16 #include "extensions/browser/api/file_system/saved_files_service_delegate.h" |
| 17 #include "extensions/common/api/file_system.h" |
| 18 #include "ui/shell_dialogs/select_file_dialog.h" |
| 19 |
| 20 #if defined(OS_CHROMEOS) |
| 21 class UIThreadExtensionFunction; |
| 22 #endif |
| 23 |
| 24 namespace base { |
| 25 class FilePath; |
| 26 } // namespace base |
| 27 |
| 28 namespace content { |
| 29 class BrowserContext; |
| 30 class RenderFrameHost; |
| 31 class WebContents; |
| 32 } // namespace content |
| 33 |
| 34 namespace ui { |
| 35 class SelectFilePolicy; |
| 36 } // namespace ui |
| 37 |
| 38 namespace extensions { |
| 39 |
| 40 class Extension; |
| 41 |
| 42 // Delegate class for embedder-specific file system access. |
| 43 class FileSystemDelegate { |
| 44 public: |
| 45 using ErrorCallback = base::Callback<void(const std::string&)>; |
| 46 using FileSystemCallback = |
| 47 base::Callback<void(const std::string& id, const std::string& path)>; |
| 48 using VolumeListCallback = |
| 49 base::Callback<void(const std::vector<api::file_system::Volume>&)>; |
| 50 |
| 51 FileSystemDelegate(); |
| 52 virtual ~FileSystemDelegate(); |
| 53 |
| 54 virtual base::FilePath GetDefaultDirectory(); |
| 55 |
| 56 virtual std::unique_ptr<ui::SelectFilePolicy> CreateSelectFilePolicy( |
| 57 content::WebContents* web_contents); |
| 58 |
| 59 virtual scoped_refptr<ui::SelectFileDialog> CreateSelectFileDialog( |
| 60 ui::SelectFileDialog::Listener* listener, |
| 61 std::unique_ptr<ui::SelectFilePolicy> policy); |
| 62 |
| 63 virtual void ShowSelectFileDialogForWebContents( |
| 64 scoped_refptr<ui::SelectFileDialog> dialog, |
| 65 content::WebContents* web_contents, |
| 66 ui::SelectFileDialog::Type type, |
| 67 const base::FilePath& default_path, |
| 68 const ui::SelectFileDialog::FileTypeInfo* file_types); |
| 69 |
| 70 virtual void ConfirmSensitiveDirectoryAccess( |
| 71 bool writable, |
| 72 const base::string16& app_name, |
| 73 content::WebContents* web_contents, |
| 74 const base::Closure& on_accept, |
| 75 const base::Closure& on_cancel); |
| 76 |
| 77 // Finds a string describing the accept type. On success, returns true and |
| 78 // populates |description_id|. |
| 79 virtual bool GetDescriptionIdForAcceptType(const std::string& accept_type, |
| 80 int* description_id); |
| 81 |
| 82 #if defined(OS_CHROMEOS) |
| 83 virtual bool IsGrantable(content::BrowserContext* browser_context, |
| 84 content::RenderFrameHost* render_frame_host, |
| 85 const Extension& extension); |
| 86 |
| 87 // Grants or denies an extension's request for access to the named file |
| 88 // system. May prompt the user for consent. |
| 89 virtual void RequestFileSystem( |
| 90 content::BrowserContext* browser_context, |
| 91 scoped_refptr<UIThreadExtensionFunction> requester, |
| 92 const Extension& extension, |
| 93 std::string volume_id, |
| 94 bool writable, |
| 95 const FileSystemCallback& success_callback, |
| 96 const ErrorCallback& error_callback); |
| 97 |
| 98 // Immediately calls VolumeListCallback or ErrorCallback. |
| 99 virtual void GetVolumeList(content::BrowserContext* browser_context, |
| 100 const VolumeListCallback& success_callback, |
| 101 const ErrorCallback& error_callback); |
| 102 #endif |
| 103 |
| 104 virtual std::unique_ptr<file_system_api::SavedFilesServiceDelegate> |
| 105 CreateSavedFilesServiceDelegate(content::BrowserContext* browser_context); |
| 106 |
| 107 private: |
| 108 DISALLOW_COPY_AND_ASSIGN(FileSystemDelegate); |
| 109 }; |
| 110 |
| 111 } // namespace extensions |
| 112 |
| 113 #endif // EXTENSIONS_BROWSER_API_FILE_SYSTEM_FILE_SYSTEM_DELEGATE_H_ |
OLD | NEW |