nsIDroppedLinkHandler.idl (3298B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 #include "nsISupports.idl" 6 #include "nsIPrincipal.idl" 7 #include "nsIPolicyContainer.idl" 8 9 webidl DragEvent; 10 webidl DataTransfer; 11 12 [scriptable, uuid(69E14F91-2E09-4CA6-A511-A715C99A2804)] 13 interface nsIDroppedLinkItem : nsISupports 14 { 15 /** 16 * Returns the URL of the link. 17 */ 18 readonly attribute AString url; 19 20 /** 21 * Returns the link name. 22 */ 23 readonly attribute AString name; 24 25 /** 26 * Returns the MIME-Type. 27 */ 28 readonly attribute AString type; 29 }; 30 31 [scriptable, uuid(21B5C25A-28A9-47BD-8431-FA9116305DED)] 32 interface nsIDroppedLinkHandler : nsISupports 33 { 34 /** 35 * Determines if a link being dragged can be dropped and returns true if so. 36 * aEvent should be a dragenter or dragover event. 37 * 38 * If aAllowSameDocument is false, drops are only allowed if the document 39 * of the source of the drag is different from the destination. This check 40 * includes any parent, sibling and child frames in the same content tree. 41 * If true, the source is not checked. 42 */ 43 boolean canDropLink(in DragEvent aEvent, in boolean aAllowSameDocument); 44 45 /** 46 * Given a drop event aEvent, determines links being dragged and returns 47 * them. If links are returned the caller can, for instance, load them. If 48 * the returned array is empty, there is no valid link to be dropped. 49 * 50 * A NS_ERROR_DOM_SECURITY_ERR error will be thrown and the event cancelled if 51 * the receiving target should not load the uri for security reasons. This 52 * will occur if any of the following conditions are true: 53 * - the source of the drag initiated a link for dragging that 54 * it itself cannot access. This prevents a source document from tricking 55 * the user into a dragging a chrome url, for example. 56 * - aDisallowInherit is true, and the URI being dropped would inherit the 57 * current document's security context (URI_INHERITS_SECURITY_CONTEXT). 58 */ 59 Array<nsIDroppedLinkItem> dropLinks(in DragEvent aEvent, 60 [optional] in boolean aDisallowInherit); 61 62 /** 63 * Given a drop event aEvent, validate the extra URIs for the event, 64 * this is used when the caller extracts yet another URIs from the dropped 65 * text, like home button that splits the text with "|". 66 */ 67 void validateURIsForDrop(in DragEvent aEvent, 68 in Array<AString> aURIs, 69 [optional] in boolean aDisallowInherit); 70 71 /** 72 * Given a dataTransfer, allows caller to determine and verify links being 73 * dragged. Since drag/drop performs a roundtrip of parent, child, parent, 74 * it allows the parent to verify that the child did not modify links 75 * being dropped. 76 */ 77 Array<nsIDroppedLinkItem> queryLinks(in DataTransfer aDataTransfer); 78 79 /** 80 * Given a drop event aEvent, determines the triggering principal for the 81 * event and returns it. 82 */ 83 nsIPrincipal getTriggeringPrincipal(in DragEvent aEvent); 84 85 /** 86 * Given a drop event aEvent, determines the policyContainer for the event and returns it. 87 */ 88 nsIPolicyContainer getPolicyContainer(in DragEvent aEvent); 89 };