mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1192945 - Use channel->asyncOpen2 in widget/windows/nsDataObj.cpp. r=ckerschb
MozReview-Commit-ID: 5whNAj5KAjf --HG-- extra : transplant_source : H%B0%2A%D0%90W%DEQn%9ET%92%273%B4%FB%E9S%D2%FA
This commit is contained in:
parent
083b9ba519
commit
4512426a78
@ -302,7 +302,9 @@ NS_IMETHODIMP
|
||||
nsDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
|
||||
nsISupportsArray * aArrayTransferables,
|
||||
nsIScriptableRegion * aRegion,
|
||||
uint32_t aActionType)
|
||||
uint32_t aActionType,
|
||||
nsContentPolicyType aContentPolicyType =
|
||||
nsIContentPolicy::TYPE_OTHER)
|
||||
{
|
||||
MOZ_LOG(sDragLm, LogLevel::Debug, ("nsDragService::InvokeDragSession"));
|
||||
|
||||
@ -314,7 +316,8 @@ nsDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
return nsBaseDragService::InvokeDragSession(aDOMNode, aArrayTransferables,
|
||||
aRegion, aActionType);
|
||||
aRegion, aActionType,
|
||||
aContentPolicyType);
|
||||
}
|
||||
|
||||
// nsBaseDragService
|
||||
|
@ -66,7 +66,8 @@ public:
|
||||
NS_IMETHOD InvokeDragSession (nsIDOMNode *aDOMNode,
|
||||
nsISupportsArray * anArrayTransferables,
|
||||
nsIScriptableRegion * aRegion,
|
||||
uint32_t aActionType) override;
|
||||
uint32_t aActionType,
|
||||
nsContentPolicyType aContentPolicyType) override;
|
||||
NS_IMETHOD StartDragSession() override;
|
||||
NS_IMETHOD EndDragSession(bool aDoneDrag) override;
|
||||
|
||||
|
@ -57,6 +57,7 @@ nsBaseDragService::nsBaseDragService()
|
||||
mDragEventDispatchedToChildProcess(false),
|
||||
mDragAction(DRAGDROP_ACTION_NONE),
|
||||
mDragActionFromChildProcess(DRAGDROP_ACTION_UNINITIALIZED), mTargetSize(0,0),
|
||||
mContentPolicyType(nsIContentPolicy::TYPE_OTHER),
|
||||
mScreenX(-1), mScreenY(-1), mSuppressLevel(0),
|
||||
mInputSource(nsIDOMMouseEvent::MOZ_SOURCE_MOUSE)
|
||||
{
|
||||
@ -209,7 +210,9 @@ NS_IMETHODIMP
|
||||
nsBaseDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
|
||||
nsISupportsArray* aTransferableArray,
|
||||
nsIScriptableRegion* aDragRgn,
|
||||
uint32_t aActionType)
|
||||
uint32_t aActionType,
|
||||
nsContentPolicyType aContentPolicyType =
|
||||
nsIContentPolicy::TYPE_OTHER)
|
||||
{
|
||||
PROFILER_LABEL_FUNC(js::ProfileEntry::Category::OTHER);
|
||||
|
||||
@ -219,6 +222,7 @@ nsBaseDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
|
||||
// stash the document of the dom node
|
||||
aDOMNode->GetOwnerDocument(getter_AddRefs(mSourceDocument));
|
||||
mSourceNode = aDOMNode;
|
||||
mContentPolicyType = aContentPolicyType;
|
||||
mEndDragPoint = LayoutDeviceIntPoint(0, 0);
|
||||
|
||||
// When the mouse goes down, the selection code starts a mouse
|
||||
@ -264,7 +268,8 @@ nsBaseDragService::InvokeDragSessionWithImage(nsIDOMNode* aDOMNode,
|
||||
aDragEvent->GetMozInputSource(&mInputSource);
|
||||
|
||||
nsresult rv = InvokeDragSession(aDOMNode, aTransferableArray,
|
||||
aRegion, aActionType);
|
||||
aRegion, aActionType,
|
||||
nsIContentPolicy::TYPE_INTERNAL_IMAGE);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
mImage = nullptr;
|
||||
@ -304,7 +309,8 @@ nsBaseDragService::InvokeDragSessionWithSelection(nsISelection* aSelection,
|
||||
aSelection->GetFocusNode(getter_AddRefs(node));
|
||||
|
||||
nsresult rv = InvokeDragSession(node, aTransferableArray,
|
||||
nullptr, aActionType);
|
||||
nullptr, aActionType,
|
||||
nsIContentPolicy::TYPE_OTHER);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
mHasImage = false;
|
||||
|
@ -156,6 +156,8 @@ protected:
|
||||
nsCOMPtr<nsIDOMNode> mSourceNode;
|
||||
nsCOMPtr<nsIDOMDocument> mSourceDocument; // the document at the drag source. will be null
|
||||
// if it came from outside the app.
|
||||
nsContentPolicyType mContentPolicyType; // the contentpolicy type passed to the channel
|
||||
// when initiating the drag session
|
||||
nsCOMPtr<nsIDOMDataTransfer> mDataTransfer;
|
||||
|
||||
// used to determine the image to appear on the cursor while dragging
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "nsISupportsArray.idl"
|
||||
#include "nsIDragSession.idl"
|
||||
#include "nsIScriptableRegion.idl"
|
||||
|
||||
#include "nsIContentPolicyBase.idl"
|
||||
|
||||
interface nsIDOMNode;
|
||||
interface nsIDOMDragEvent;
|
||||
@ -44,9 +44,15 @@ interface nsIDragService : nsISupports
|
||||
* @param aRegion - a region containing rectangles for cursor feedback,
|
||||
* in window coordinates.
|
||||
* @param aActionType - specified which of copy/move/link are allowed
|
||||
* @param aContentPolicyType - the contentPolicyType that will be
|
||||
* passed to the loadInfo when creating a new channel
|
||||
* (defaults to TYPE_OTHER)
|
||||
*/
|
||||
void invokeDragSession ( in nsIDOMNode aDOMNode, in nsISupportsArray aTransferables,
|
||||
in nsIScriptableRegion aRegion, in unsigned long aActionType );
|
||||
void invokeDragSession (in nsIDOMNode aDOMNode,
|
||||
in nsISupportsArray aTransferables,
|
||||
in nsIScriptableRegion aRegion,
|
||||
in unsigned long aActionType,
|
||||
[optional] in nsContentPolicyType aContentPolicyType);
|
||||
|
||||
/**
|
||||
* Starts a modal drag session using an image. The first four arguments are
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "nsISupports.idl"
|
||||
#include "nsISupportsArray.idl"
|
||||
#include "nsIFormatConverter.idl"
|
||||
#include "nsIContentPolicyBase.idl"
|
||||
|
||||
interface nsIDOMNode;
|
||||
|
||||
@ -199,11 +200,13 @@ interface nsITransferable : nsISupports
|
||||
[noscript] attribute boolean isPrivateData;
|
||||
|
||||
/**
|
||||
* The source dom node this transferable was created from.
|
||||
* Note, currently only in use on Windows for network principal
|
||||
* information in drag operations.
|
||||
* The source dom node this transferable was created from and
|
||||
* the contentPolicyType for the transferable.
|
||||
* Note, currently only used on Windows for network principal and
|
||||
* contentPolicyType information in drag operations.
|
||||
*/
|
||||
[noscript] attribute nsIDOMNode requestingNode;
|
||||
[noscript] attribute nsContentPolicyType contentPolicyType;
|
||||
|
||||
};
|
||||
|
||||
|
@ -18,6 +18,7 @@ Notes to self:
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsIFormatConverter.h"
|
||||
#include "nsIContentPolicy.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsXPCOM.h"
|
||||
@ -218,6 +219,7 @@ DataStruct::ReadCache(nsISupports** aData, uint32_t* aDataLen)
|
||||
//-------------------------------------------------------------------------
|
||||
nsTransferable::nsTransferable()
|
||||
: mPrivateData(false)
|
||||
, mContentPolicyType(nsIContentPolicy::TYPE_OTHER)
|
||||
#ifdef DEBUG
|
||||
, mInitialized(false)
|
||||
#endif
|
||||
@ -643,3 +645,18 @@ nsTransferable::SetRequestingNode(nsIDOMNode* aRequestingNode)
|
||||
mRequestingNode = do_GetWeakReference(aRequestingNode);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTransferable::GetContentPolicyType(nsContentPolicyType* outContentPolicyType)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(outContentPolicyType);
|
||||
*outContentPolicyType = mContentPolicyType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTransferable::SetContentPolicyType(nsContentPolicyType aContentPolicyType)
|
||||
{
|
||||
mContentPolicyType = aContentPolicyType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
#ifndef nsTransferable_h__
|
||||
#define nsTransferable_h__
|
||||
|
||||
#include "nsIContentPolicyBase.h"
|
||||
#include "nsIFormatConverter.h"
|
||||
#include "nsITransferable.h"
|
||||
#include "nsCOMPtr.h"
|
||||
@ -74,6 +75,7 @@ protected:
|
||||
nsCOMPtr<nsIFormatConverter> mFormatConv;
|
||||
bool mPrivateData;
|
||||
nsWeakPtr mRequestingNode;
|
||||
nsContentPolicyType mContentPolicyType;
|
||||
#if DEBUG
|
||||
bool mInitialized;
|
||||
#endif
|
||||
|
@ -64,6 +64,7 @@ nsDataObj::CStream::~CStream()
|
||||
//-----------------------------------------------------------------------------
|
||||
// helper - initializes the stream
|
||||
nsresult nsDataObj::CStream::Init(nsIURI *pSourceURI,
|
||||
uint32_t aContentPolicyType,
|
||||
nsINode* aRequestingNode)
|
||||
{
|
||||
// we can not create a channel without a requestingNode
|
||||
@ -74,14 +75,14 @@ nsresult nsDataObj::CStream::Init(nsIURI *pSourceURI,
|
||||
rv = NS_NewChannel(getter_AddRefs(mChannel),
|
||||
pSourceURI,
|
||||
aRequestingNode,
|
||||
nsILoadInfo::SEC_NORMAL,
|
||||
nsIContentPolicy::TYPE_OTHER,
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS,
|
||||
aContentPolicyType,
|
||||
nullptr, // loadGroup
|
||||
nullptr, // aCallbacks
|
||||
nsIRequest::LOAD_FROM_CACHE);
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = mChannel->AsyncOpen(this, nullptr);
|
||||
rv = mChannel->AsyncOpen2(this);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -345,8 +346,10 @@ HRESULT nsDataObj::CreateStream(IStream **outStream)
|
||||
mTransferable->GetRequestingNode(getter_AddRefs(requestingDomNode));
|
||||
nsCOMPtr<nsINode> requestingNode = do_QueryInterface(requestingDomNode);
|
||||
MOZ_ASSERT(requestingNode, "can not create channel without a node");
|
||||
|
||||
rv = pStream->Init(sourceURI, requestingNode);
|
||||
// default transferable content policy is nsIContentPolicy::TYPE_OTHER
|
||||
uint32_t contentPolicyType = nsIContentPolicy::TYPE_OTHER;
|
||||
mTransferable->GetContentPolicyType(&contentPolicyType);
|
||||
rv = pStream->Init(sourceURI, contentPolicyType, requestingNode);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
pStream->Release();
|
||||
|
@ -249,7 +249,9 @@ protected:
|
||||
|
||||
public:
|
||||
CStream();
|
||||
nsresult Init(nsIURI *pSourceURI, nsINode* aRequestingNode);
|
||||
nsresult Init(nsIURI *pSourceURI,
|
||||
uint32_t aContentPolicyType,
|
||||
nsINode* aRequestingNode);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
|
@ -207,6 +207,7 @@ nsDragService::InvokeDragSessionImpl(nsISupportsArray* anArrayTransferables,
|
||||
if (trans) {
|
||||
// set the requestingNode on the transferable
|
||||
trans->SetRequestingNode(mSourceNode);
|
||||
trans->SetContentPolicyType(mContentPolicyType);
|
||||
RefPtr<IDataObject> dataObj;
|
||||
rv = nsClipboard::CreateNativeDataObject(trans,
|
||||
getter_AddRefs(dataObj), uri);
|
||||
@ -226,6 +227,7 @@ nsDragService::InvokeDragSessionImpl(nsISupportsArray* anArrayTransferables,
|
||||
if (trans) {
|
||||
// set the requestingNode on the transferable
|
||||
trans->SetRequestingNode(mSourceNode);
|
||||
trans->SetContentPolicyType(mContentPolicyType);
|
||||
rv = nsClipboard::CreateNativeDataObject(trans,
|
||||
getter_AddRefs(itemToDrag),
|
||||
uri);
|
||||
|
Loading…
Reference in New Issue
Block a user