Bug 1337056 - Part 12: Send down permissions when calling createAboutBlankContentViewer, r=baku

MozReview-Commit-ID: LigZnHM34CC
This commit is contained in:
Michael Layzell 2017-03-17 17:04:44 -04:00
Родитель bd18aec002
Коммит 838290fd27
5 изменённых файлов: 42 добавлений и 1 удалений

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

@ -5,6 +5,8 @@
#include "domstubs.idl"
interface nsIPrincipal;
[builtinclass, scriptable, uuid(8e49f7b0-1f98-4939-bf91-e9c39cd56434)]
interface nsITabParent : nsISupports
{
@ -61,4 +63,10 @@ interface nsITabParent : nsISupports
* it.
*/
readonly attribute boolean hasPresented;
/**
* Ensures that the content process which has this tab parent has all of the
* permissions required to load a document with the given principal.
*/
void transmitPermissionsForPrincipal(in nsIPrincipal aPrincipal);
};

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

@ -5095,9 +5095,20 @@ ContentParent::TransmitPermissionsFor(nsIChannel* aChannel)
rv = ssm->GetChannelResultPrincipal(aChannel, getter_AddRefs(principal));
NS_ENSURE_SUCCESS(rv, rv);
rv = TransmitPermissionsForPrincipal(principal);
NS_ENSURE_SUCCESS(rv, rv);
#endif
return NS_OK;
}
nsresult
ContentParent::TransmitPermissionsForPrincipal(nsIPrincipal* aPrincipal)
{
#ifdef MOZ_PERMISSIONS
// Create the key, and send it down to the content process.
nsTArray<nsCString> keys =
nsPermissionManager::GetAllKeysForPrincipal(principal);
nsPermissionManager::GetAllKeysForPrincipal(aPrincipal);
MOZ_ASSERT(keys.Length() >= 1);
for (auto& key : keys) {
EnsurePermissionsByKey(key);

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

@ -639,6 +639,8 @@ public:
nsresult TransmitPermissionsFor(nsIChannel* aChannel);
nsresult TransmitPermissionsForPrincipal(nsIPrincipal* aPrincipal);
protected:
void OnChannelConnected(int32_t pid) override;

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

@ -2806,6 +2806,18 @@ TabParent::NavigateByKey(bool aForward, bool aForDocumentNavigation)
return NS_OK;
}
NS_IMETHODIMP
TabParent::TransmitPermissionsForPrincipal(nsIPrincipal* aPrincipal)
{
nsCOMPtr<nsIContentParent> manager = Manager();
if (!manager->IsContentParent()) {
return NS_ERROR_UNEXPECTED;
}
return manager->AsContentParent()
->TransmitPermissionsForPrincipal(aPrincipal);
}
class LayerTreeUpdateRunnable final
: public mozilla::Runnable
{

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

@ -568,6 +568,14 @@
<parameter name="aPrincipal"/>
<body>
<![CDATA[
// Ensure that the content process has the permissions which are
// needed to create a document with the given principal.
let permissionPrincipal =
BrowserUtils.principalWithMatchingOA(aPrincipal, this.contentPrincipal);
let {frameLoader} = this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner);
frameLoader.tabParent.transmitPermissionsForPrincipal(permissionPrincipal);
// Create the about blank content viewer in the content process
this.messageManager.sendAsyncMessage("Browser:CreateAboutBlank", aPrincipal);
]]>
</body>