Commit 1ea9ded1 authored by Mike Perry's avatar Mike Perry
Browse files

Emit observer event to filter the Drag+Drop url list

This patch creates an "on-modify-drag-list" observer that addons can listen
to. For us, it supports Torbutton code that filters out Drag+Drop mime types
that the OS Desktop sniffs and attempts to load without Tor.

Such proxy bypass behavior is immediate on Mac and Ubuntu: you don't even have
to release the object for it to get sniffed and cause the OS to load it
without Tor. In fact, accidentally clicking for too long on an image is enough
to cause proxy bypass on those systems.
parent 8c02184d
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
#include "nsXULPopupManager.h"
#include "nsMenuPopupFrame.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"

#include "gfxContext.h"
#include "gfxPlatform.h"
@@ -50,6 +51,7 @@ nsBaseDragService::nsBaseDragService()
    mImageX(0), mImageY(0), mScreenX(-1), mScreenY(-1), mSuppressLevel(0),
    mInputSource(nsIDOMMouseEvent::MOZ_SOURCE_MOUSE)
{
    mObserverService = mozilla::services::GetObserverService();
}

nsBaseDragService::~nsBaseDragService()
@@ -204,6 +206,12 @@ nsBaseDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
  NS_ENSURE_TRUE(aDOMNode, NS_ERROR_INVALID_ARG);
  NS_ENSURE_TRUE(mSuppressLevel == 0, NS_ERROR_FAILURE);

  // Emit observer event to allow addons to modify the transfer array.
  if (mObserverService)
    mObserverService->NotifyObservers(aTransferableArray,
                                      "on-modify-drag-list",
                                      nullptr);

  // stash the document of the dom node
  aDOMNode->GetOwnerDocument(getter_AddRefs(mSourceDocument));
  mSourceNode = aDOMNode;
+2 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@
#ifndef nsBaseDragService_h__
#define nsBaseDragService_h__

#include "nsIObserverService.h"
#include "nsIDragService.h"
#include "nsIDragSession.h"
#include "nsITransferable.h"
@@ -113,6 +114,7 @@ protected:

  uint32_t mDragAction;
  nsSize mTargetSize;
  nsCOMPtr<nsIObserverService> mObserverService;
  nsCOMPtr<nsIDOMNode> mSourceNode;
  nsCOMPtr<nsIDOMDocument> mSourceDocument;       // the document at the drag source. will be null
                                                  //  if it came from outside the app.