Bug 769589 - Remove deprecated GetOriginatingURI from nsICookiePermission. r=mconnor sr=cbiesinger

This commit is contained in:
Mounir Lamouri 2012-08-30 17:07:03 -03:00
parent d881e202dd
commit 2d1e1ea4ca
2 changed files with 1 additions and 117 deletions

View File

@ -358,104 +358,6 @@ nsCookiePermission::CanSetCookie(nsIURI *aURI,
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsCookiePermission::GetOriginatingURI(nsIChannel *aChannel,
nsIURI **aURI)
{
/* to find the originating URI, we use the loadgroup of the channel to obtain
* the window owning the load, and from there, we find the top same-type
* window and its URI. there are several possible cases:
*
* 1) no channel.
*
* 2) a channel with the "force allow third party cookies" option set.
* since we may not have a window, we return the channel URI in this case.
*
* 3) a channel, but no window. this can occur when the consumer kicking
* off the load doesn't provide one to the channel, and should be limited
* to loads of certain types of resources.
*
* 4) a window equal to the top window of same type, with the channel its
* document channel. this covers the case of a freshly kicked-off load
* (e.g. the user typing something in the location bar, or clicking on a
* bookmark), where the window's URI hasn't yet been set, and will be
* bogus. we return the channel URI in this case.
*
* 5) Anything else. this covers most cases for an ordinary page load from
* the location bar, and will catch nested frames within a page, image
* loads, etc. we return the URI of the root window's document's principal
* in this case.
*/
*aURI = nullptr;
// case 1)
if (!aChannel)
return NS_ERROR_NULL_POINTER;
// case 2)
nsCOMPtr<nsIHttpChannelInternal> httpChannelInternal = do_QueryInterface(aChannel);
if (httpChannelInternal)
{
bool doForce = false;
if (NS_SUCCEEDED(httpChannelInternal->GetForceAllowThirdPartyCookie(&doForce)) && doForce)
{
// return the channel's URI (we may not have a window)
aChannel->GetURI(aURI);
if (!*aURI)
return NS_ERROR_NULL_POINTER;
return NS_OK;
}
}
// find the associated window and its top window
nsCOMPtr<nsILoadContext> ctx;
NS_QueryNotificationCallbacks(aChannel, ctx);
nsCOMPtr<nsIDOMWindow> topWin, ourWin;
if (ctx) {
ctx->GetTopWindow(getter_AddRefs(topWin));
ctx->GetAssociatedWindow(getter_AddRefs(ourWin));
}
// case 3)
if (!topWin)
return NS_ERROR_INVALID_ARG;
// case 4)
if (ourWin == topWin) {
// Check whether this is the document channel for this window (representing
// a load of a new page). This is a bit of a nasty hack, but we will
// hopefully flag these channels better later.
nsLoadFlags flags;
aChannel->GetLoadFlags(&flags);
if (flags & nsIChannel::LOAD_DOCUMENT_URI) {
// get the channel URI - the window's will be bogus
aChannel->GetURI(aURI);
if (!*aURI)
return NS_ERROR_NULL_POINTER;
return NS_OK;
}
}
// case 5) - get the originating URI from the top window's principal
nsCOMPtr<nsIScriptObjectPrincipal> scriptObjPrin = do_QueryInterface(topWin);
NS_ENSURE_TRUE(scriptObjPrin, NS_ERROR_UNEXPECTED);
nsIPrincipal* prin = scriptObjPrin->GetPrincipal();
NS_ENSURE_TRUE(prin, NS_ERROR_UNEXPECTED);
prin->GetURI(aURI);
if (!*aURI)
return NS_ERROR_NULL_POINTER;
// all done!
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsCookiePermission::Observe(nsISupports *aSubject, nsCookiePermission::Observe(nsISupports *aSubject,
const char *aTopic, const char *aTopic,

View File

@ -13,7 +13,7 @@ typedef long nsCookieAccess;
/** /**
* An interface to test for cookie permissions * An interface to test for cookie permissions
*/ */
[scriptable, uuid(4b1a775d-f6d3-4389-be2e-9dfbaf2ab47b)] [scriptable, uuid(11ddd4ed-8f5b-40b3-b2a0-27c20ea1c88d)]
interface nsICookiePermission : nsISupports interface nsICookiePermission : nsISupports
{ {
/** /**
@ -95,24 +95,6 @@ interface nsICookiePermission : nsISupports
in nsICookie2 aCookie, in nsICookie2 aCookie,
inout boolean aIsSession, inout boolean aIsSession,
inout int64_t aExpiry); inout int64_t aExpiry);
/**
* getOriginatingURI
*
* determines the originating URI for a load given a channel, for third-party
* cookie blocking. this is done by leveraging the loadgroup of the channel to
* find the root content docshell, and the URI associated with its principal.
* if the root content docshell or its principal's URI cannot be obtained,
* this method will throw.
*
* @param aChannel
* the channel for the load trying to get or set cookies
*
* @return the originating URI.
*
* @status DEPRECATED -- use mozIThirdPartyUtil instead.
*/
nsIURI getOriginatingURI(in nsIChannel aChannel);
}; };
%{ C++ %{ C++