Bug 1317720. Use NeedsCallerType instead of NeedsSubjectPrincipal for DataTransfer.types. r=mystor

This commit is contained in:
Boris Zbarsky 2016-11-15 12:46:32 -05:00
Родитель dda84c3ef8
Коммит 784a52fd02
5 изменённых файлов: 6 добавлений и 8 удалений

Просмотреть файл

@ -311,8 +311,7 @@ DataTransfer::GetFiles(nsIDOMFileList** aFileList)
}
void
DataTransfer::GetTypes(nsTArray<nsString>& aTypes,
nsIPrincipal& aSubjectPrincipal) const
DataTransfer::GetTypes(nsTArray<nsString>& aTypes, CallerType aCallerType) const
{
// When called from bindings, aTypes will be empty, but since we might have
// Gecko-internal callers too, clear it to be safe.
@ -327,7 +326,7 @@ DataTransfer::GetTypes(nsTArray<nsString>& aTypes,
DataTransferItem* item = items->ElementAt(i);
MOZ_ASSERT(item);
if (item->ChromeOnly() && !nsContentUtils::IsSystemPrincipal(&aSubjectPrincipal)) {
if (item->ChromeOnly() && aCallerType != CallerType::System) {
continue;
}

Просмотреть файл

@ -136,8 +136,7 @@ public:
void SetDragImage(Element& aElement, int32_t aX, int32_t aY,
ErrorResult& aRv);
void GetTypes(nsTArray<nsString>& aTypes,
nsIPrincipal& aSubjectPrincipal) const;
void GetTypes(nsTArray<nsString>& aTypes, CallerType aCallerType) const;
void GetData(const nsAString& aFormat, nsAString& aData,
nsIPrincipal& aSubjectPrincipal,

Просмотреть файл

@ -19,7 +19,7 @@ interface DataTransfer {
// ReturnValueNeedsContainsHack on .types because lots of extension
// code was expecting .contains() back when it was a DOMStringList.
[Pure, Cached, Frozen, NeedsSubjectPrincipal, ReturnValueNeedsContainsHack]
[Pure, Cached, Frozen, NeedsCallerType, ReturnValueNeedsContainsHack]
readonly attribute sequence<DOMString> types;
[Throws, NeedsSubjectPrincipal]
DOMString getData(DOMString format);

Просмотреть файл

@ -935,7 +935,7 @@ EditorEventListener::CanDrop(nsIDOMDragEvent* aEvent)
NS_ENSURE_TRUE(dataTransfer, false);
nsTArray<nsString> types;
dataTransfer->GetTypes(types, *nsContentUtils::GetSystemPrincipal());
dataTransfer->GetTypes(types, CallerType::System);
// Plaintext editors only support dropping text. Otherwise, HTML and files
// can be dropped as well.

Просмотреть файл

@ -380,7 +380,7 @@ nsFileControlFrame::DnDListener::IsValidDropData(nsIDOMDataTransfer* aDOMDataTra
// We only support dropping files onto a file upload control
nsTArray<nsString> types;
dataTransfer->GetTypes(types, *nsContentUtils::GetSystemPrincipal());
dataTransfer->GetTypes(types, CallerType::System);
return types.Contains(NS_LITERAL_STRING("Files"));
}