Bug 1322748 add ability to get registered channelwrappers, r=kmag

MozReview-Commit-ID: SphwWjzQuo
This commit is contained in:
Shane Caraveo
2018-05-22 14:19:57 -04:00
parent 1a915c3b96
commit d29291d445
3 changed files with 27 additions and 1 deletions

View File

@@ -79,6 +79,24 @@ ChannelWrapper::Get(const GlobalObject& global, nsIChannel* channel)
return wrapper.forget();
}
already_AddRefed<ChannelWrapper>
ChannelWrapper::GetRegisteredChannel(const GlobalObject& global, uint64_t aChannelId, const WebExtensionPolicy& aAddon, nsITabParent* aTabParent)
{
nsIContentParent* contentParent = nullptr;
if (TabParent* parent = static_cast<TabParent*>(aTabParent)) {
contentParent = static_cast<nsIContentParent*>(parent->Manager());
}
auto& webreq = WebRequestService::GetSingleton();
nsCOMPtr<nsITraceableChannel> channel = webreq.GetTraceableChannel(aChannelId, aAddon.Id(), contentParent);
if (!channel) {
return nullptr;
}
nsCOMPtr<nsIChannel> chan(do_QueryInterface(channel));
return ChannelWrapper::Get(global, chan);
}
void
ChannelWrapper::SetChannel(nsIChannel* aChannel)
{