Bug 1406253 - Part 2: Implement nsIImageLoadingContent.currentRequestFinalURI. r=bz

ImageLoadingContent.currentURI returns the "URI" of currentRequest, which is
the URI used to start that request.  Some consumers need to know the final URI
of that request instead.

If the image request gets redirected on loading (e.g. an add-on intercepts the
request), currentRequestFinalURI will be the redirected URI, while currentURI
would be the original URI before redirect.

MozReview-Commit-ID: 9lX063uAIp1

--HG--
extra : rebase_source : 91451128abc5c3f29c11d3cabfc98cde6c440ea6
This commit is contained in:
Samael Wang 2017-11-14 18:20:03 +08:00
Родитель 326d642792
Коммит 9d2c8ac38e
3 изменённых файлов: 16 добавлений и 0 удалений

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

@ -757,6 +757,17 @@ nsImageLoadingContent::GetCurrentURI(nsIURI** aURI)
return result.StealNSResult();
}
already_AddRefed<nsIURI>
nsImageLoadingContent::GetCurrentRequestFinalURI()
{
nsCOMPtr<nsIURI> uri;
if (mCurrentRequest) {
mCurrentRequest->GetFinalURI(getter_AddRefs(uri));
}
return uri.forget();
}
NS_IMETHODIMP
nsImageLoadingContent::LoadImageWithChannel(nsIChannel* aChannel,
nsIStreamListener** aListener)

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

@ -70,6 +70,7 @@ public:
int32_t
GetRequestType(imgIRequest* aRequest, mozilla::ErrorResult& aError);
already_AddRefed<nsIURI> GetCurrentURI(mozilla::ErrorResult& aError);
already_AddRefed<nsIURI> GetCurrentRequestFinalURI();
void ForceReload(const mozilla::dom::Optional<bool>& aNotify,
mozilla::ErrorResult& aError);

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

@ -102,6 +102,10 @@ interface MozImageLoadingContent {
long getRequestType(imgIRequest aRequest);
[ChromeOnly,Throws]
readonly attribute URI? currentURI;
// Gets the final URI of the current request, if available.
// Otherwise, returns null.
[ChromeOnly]
readonly attribute URI? currentRequestFinalURI;
[ChromeOnly,Throws]
void forceReload(optional boolean aNotify);
[ChromeOnly]