mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-04 13:07:52 +00:00
Bug 1340333 - Eagerly compute whether a frame is really a browser. r=smaug
MozReview-Commit-ID: Gm0oYaSKpUY
This commit is contained in:
parent
d05a45802c
commit
ebddba2ae4
@ -372,6 +372,17 @@ nsGenericHTMLFrameElement::MapScrollingAttribute(const nsAttrValue* aValue)
|
||||
return mappedValue;
|
||||
}
|
||||
|
||||
static bool
|
||||
PrincipalAllowsBrowserFrame(nsIPrincipal* aPrincipal)
|
||||
{
|
||||
nsCOMPtr<nsIPermissionManager> permMgr = mozilla::services::GetPermissionManager();
|
||||
NS_ENSURE_TRUE(permMgr, false);
|
||||
uint32_t permission = nsIPermissionManager::DENY_ACTION;
|
||||
nsresult rv = permMgr->TestPermissionFromPrincipal(aPrincipal, "browser", &permission);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
return permission == nsIPermissionManager::ALLOW_ACTION;
|
||||
}
|
||||
|
||||
/* virtual */ nsresult
|
||||
nsGenericHTMLFrameElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
const nsAttrValue* aValue,
|
||||
@ -401,6 +412,11 @@ nsGenericHTMLFrameElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
}
|
||||
}
|
||||
|
||||
if (aName == nsGkAtoms::mozbrowser && aNameSpaceID == kNameSpaceID_None) {
|
||||
mReallyIsBrowser = !!aValue && BrowserFramesEnabled() &&
|
||||
PrincipalAllowsBrowserFrame(NodePrincipal());
|
||||
}
|
||||
|
||||
return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue,
|
||||
aNotify);
|
||||
}
|
||||
@ -486,28 +502,7 @@ nsGenericHTMLFrameElement::BrowserFramesEnabled()
|
||||
/* [infallible] */ nsresult
|
||||
nsGenericHTMLFrameElement::GetReallyIsBrowser(bool *aOut)
|
||||
{
|
||||
*aOut = false;
|
||||
|
||||
// Fail if browser frames are globally disabled.
|
||||
if (!nsGenericHTMLFrameElement::BrowserFramesEnabled()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Fail if this frame doesn't have the mozbrowser attribute.
|
||||
if (!GetBoolAttr(nsGkAtoms::mozbrowser)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Fail if the node principal isn't trusted.
|
||||
nsIPrincipal *principal = NodePrincipal();
|
||||
nsCOMPtr<nsIPermissionManager> permMgr =
|
||||
services::GetPermissionManager();
|
||||
NS_ENSURE_TRUE(permMgr, NS_OK);
|
||||
|
||||
uint32_t permission = nsIPermissionManager::DENY_ACTION;
|
||||
nsresult rv = permMgr->TestPermissionFromPrincipal(principal, "browser", &permission);
|
||||
NS_ENSURE_SUCCESS(rv, NS_OK);
|
||||
*aOut = permission == nsIPermissionManager::ALLOW_ACTION;
|
||||
*aOut = mReallyIsBrowser;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
, mIsPrerendered(false)
|
||||
, mBrowserFrameListenersRegistered(false)
|
||||
, mFrameLoaderCreationDisallowed(false)
|
||||
, mReallyIsBrowser(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -125,6 +126,7 @@ protected:
|
||||
bool mIsPrerendered;
|
||||
bool mBrowserFrameListenersRegistered;
|
||||
bool mFrameLoaderCreationDisallowed;
|
||||
bool mReallyIsBrowser;
|
||||
|
||||
// This flag is only used by <iframe>. See HTMLIFrameElement::
|
||||
// FullscreenFlag() for details. It is placed here so that we
|
||||
|
Loading…
x
Reference in New Issue
Block a user