Bug 1444686 part 6. Get rid of nsIDOMDataTransfer::GetFiles. r=mystor

MozReview-Commit-ID: 3gAWLI2DyyU
This commit is contained in:
Boris Zbarsky 2018-03-13 16:24:00 -04:00
parent acad63d428
commit d4bb233636
5 changed files with 12 additions and 35 deletions

View File

@ -297,31 +297,11 @@ DataTransfer::GetMozUserCancelled(bool* aUserCancelled)
}
already_AddRefed<FileList>
DataTransfer::GetFiles(nsIPrincipal& aSubjectPrincipal,
ErrorResult& aRv)
DataTransfer::GetFiles(nsIPrincipal& aSubjectPrincipal)
{
return mItems->Files(&aSubjectPrincipal);
}
NS_IMETHODIMP
DataTransfer::GetFiles(nsIDOMFileList** aFileList)
{
if (!aFileList) {
return NS_ERROR_FAILURE;
}
// The XPCOM interface is only avaliable to system code, and thus we can
// assume the system principal. This is consistent with the previous behavour
// of this function, which also assumed the system principal.
//
// This code is also called from C++ code, which expects it to have a System
// Principal, and thus the SubjectPrincipal cannot be used.
RefPtr<FileList> files = mItems->Files(nsContentUtils::GetSystemPrincipal());
files.forget(aFileList);
return NS_OK;
}
void
DataTransfer::GetTypes(nsTArray<nsString>& aTypes, CallerType aCallerType) const
{

View File

@ -189,9 +189,13 @@ public:
nsIPrincipal& aSubjectPrincipal,
mozilla::ErrorResult& aRv);
/**
* Holds a list of all the local files available on this data transfer.
* A dataTransfer containing no files will return an empty list, and an
* invalid index access on the resulting file list will return null.
*/
already_AddRefed<FileList>
GetFiles(nsIPrincipal& aSubjectPrincipal,
mozilla::ErrorResult& aRv);
GetFiles(nsIPrincipal& aSubjectPrincipal);
already_AddRefed<Promise>
GetFilesAndDirectories(nsIPrincipal& aSubjectPrincipal,

View File

@ -30,13 +30,6 @@ interface nsIDOMDataTransfer : nsISupports
*/
attribute DOMString effectAllowed;
/**
* Holds a list of all the local files available on this data transfer.
* A dataTransfer containing no files will return an empty list, and an
* invalid index access on the resulting file list will return null.
*/
readonly attribute nsIDOMFileList files;
/**
* Set the image to be used for dragging if a custom one is desired. Most of
* the time, this would not be set, as a default image is created from the

View File

@ -26,7 +26,7 @@ interface DataTransfer {
void setData(DOMString format, DOMString data);
[Throws, NeedsSubjectPrincipal]
void clearData(optional DOMString format);
[Throws, NeedsSubjectPrincipal]
[NeedsSubjectPrincipal]
readonly attribute FileList? files;
};

View File

@ -276,8 +276,8 @@ nsFileControlFrame::DnDListener::HandleEvent(nsIDOMEvent* aEvent)
aEvent->StopPropagation();
aEvent->PreventDefault();
nsCOMPtr<nsIDOMFileList> fileList;
dataTransfer->GetFiles(getter_AddRefs(fileList));
RefPtr<FileList> fileList =
dataTransfer->GetFiles(*nsContentUtils::GetSystemPrincipal());
RefPtr<BlobImpl> webkitDir;
nsresult rv =
@ -399,8 +399,8 @@ nsFileControlFrame::DnDListener::CanDropTheseFiles(nsIDOMDataTransfer* aDOMDataT
nsCOMPtr<DataTransfer> dataTransfer = do_QueryInterface(aDOMDataTransfer);
NS_ENSURE_TRUE(dataTransfer, false);
nsCOMPtr<nsIDOMFileList> fileList;
dataTransfer->GetFiles(getter_AddRefs(fileList));
RefPtr<FileList> fileList =
dataTransfer->GetFiles(*nsContentUtils::GetSystemPrincipal());
RefPtr<BlobImpl> webkitDir;
nsresult rv =