diff options
7 files changed, 37 insertions, 5 deletions
diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc b/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc index 2d5368c..92175a9 100644 --- a/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc +++ b/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc @@ -273,11 +273,6 @@ bool FileManagerPrivateRequestFileSystemFunction:: ChildProcessSecurityPolicy::GetInstance()->GrantCreateReadWriteFile( child_id, mount_path); - // Grant permission to request externalfile scheme. The permission is needed - // to start drag for external file URL. - ChildProcessSecurityPolicy::GetInstance()->GrantScheme( - child_id, content::kExternalFileScheme); - return true; } @@ -360,6 +355,13 @@ void FileManagerPrivateRequestFileSystemFunction::OnEntryDefinition( SendResponse(true); } +ExtensionFunction::ResponseAction +FileManagerPrivateEnableExternalFileSchemeFunction::Run() { + ChildProcessSecurityPolicy::GetInstance()->GrantScheme( + render_view_host()->GetProcess()->GetID(), content::kExternalFileScheme); + return RespondNow(NoArguments()); +} + FileManagerPrivateGrantAccessFunction::FileManagerPrivateGrantAccessFunction() : chrome_details_(this) { } diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.h b/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.h index 255e6ce..31da7b9 100644 --- a/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.h +++ b/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.h @@ -80,6 +80,21 @@ class FileManagerPrivateRequestFileSystemFunction const file_manager::util::EntryDefinition& entry_definition); }; +// Grant permission to request externalfile scheme. The permission is needed to +// start drag for external file URL. +class FileManagerPrivateEnableExternalFileSchemeFunction + : public UIThreadExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.enableExternalFileScheme", + FILEMANAGERPRIVATE_ENABLEEXTERNALFILESCHEME); + + protected: + ~FileManagerPrivateEnableExternalFileSchemeFunction() override {} + + private: + ExtensionFunction::ResponseAction Run() override; +}; + // Grants R/W permissions to profile-specific directories (Drive, Downloads) // from other profiles. class FileManagerPrivateGrantAccessFunction : public UIThreadExtensionFunction { diff --git a/chrome/common/extensions/api/file_manager_private.idl b/chrome/common/extensions/api/file_manager_private.idl index f8affee..2431652 100644 --- a/chrome/common/extensions/api/file_manager_private.idl +++ b/chrome/common/extensions/api/file_manager_private.idl @@ -659,6 +659,10 @@ interface Functions { static void requestFileSystem(DOMString volumeId, RequestFileSystemCallback callback); + // Enables the extenal file scheme necessary to initiate drags to the browser + // window for files on the external backend. + static void enableExternalFileScheme(); + // Requests granting R/W permissions for the passed entries. It's a best // effort operation. Some files may not be granted access if the url is // invalid or not backed by the external file system. diff --git a/extensions/browser/extension_function_histogram_value.h b/extensions/browser/extension_function_histogram_value.h index d40ec0d..3e9fbf9 100644 --- a/extensions/browser/extension_function_histogram_value.h +++ b/extensions/browser/extension_function_histogram_value.h @@ -1038,6 +1038,7 @@ enum HistogramValue { FILEMANAGERPRIVATE_GRANTACCESS, DEVELOPERPRIVATE_GETEXTENSIONSINFO, DEVELOPERPRIVATE_GETEXTENSIONINFO, + FILEMANAGERPRIVATE_ENABLEEXTERNALFILESCHEME, // Last entry: Add new entries above and ensure to update // tools/metrics/histograms/histograms.xml. ENUM_BOUNDARY diff --git a/third_party/closure_compiler/externs/file_manager_private.js b/third_party/closure_compiler/externs/file_manager_private.js index ba0263a..10a57a7 100644 --- a/third_party/closure_compiler/externs/file_manager_private.js +++ b/third_party/closure_compiler/externs/file_manager_private.js @@ -281,6 +281,12 @@ chrome.fileManagerPrivate.removeFileWatch = function(fileUrl, callback) {}; chrome.fileManagerPrivate.requestFileSystem = function(volumeId, callback) {}; /** + * Enables the extenal file scheme necessary to initiate drags to the browser + * window for files on the external backend. + */ +chrome.fileManagerPrivate.enableExternalFileScheme = function() {}; + +/** * Requests R/W access to the specified entries as |entryUrls|. Note, that only * files backed by external file system backend will be granted the access. * @param {!Array<string>} entryUrls diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 8b3cacf..9fe0bf0 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -48906,6 +48906,7 @@ Therefore, the affected-histogram name has to have at least one dot in it. <int value="977" label="FILEMANAGERPRIVATE_GRANTACCESS"/> <int value="978" label="DEVELOPERPRIVATE_GETEXTENSIONSINFO"/> <int value="979" label="DEVELOPERPRIVATE_GETEXTENSIONINFO"/> + <int value="980" label="FILEMANAGERPRIVATE_ENABLEEXTERNALFILESCHEME"/> </enum> <enum name="ExtensionInstallCause" type="int"> diff --git a/ui/file_manager/file_manager/foreground/js/file_transfer_controller.js b/ui/file_manager/file_manager/foreground/js/file_transfer_controller.js index 1e8e755..f5e1792 100644 --- a/ui/file_manager/file_manager/foreground/js/file_transfer_controller.js +++ b/ui/file_manager/file_manager/foreground/js/file_transfer_controller.js @@ -199,6 +199,9 @@ function FileTransferController(doc, this.attachFileListDropTarget_(listContainer.grid); this.attachTreeDropTarget_(directoryTree); this.attachCopyPasteHandlers_(); + + // Allow to drag external files to the browser window. + chrome.fileManagerPrivate.enableExternalFileScheme(); } /** |