Bug 753546 Part 1 - Make nsDocument listen for 'fullscreen-approved' notification rather than 'perm-changed' to signal fullscreen approved. r=smaug

This commit is contained in:
Chris Pearce 2012-05-22 08:43:36 +12:00
parent 1c10357a1d
commit f0483c44f2
2 changed files with 9 additions and 5 deletions

View File

@ -9257,7 +9257,7 @@ nsDocument::ClearPendingPointerLockRequest(bool aDispatchErrorEvents)
NS_WARNING("Document must implement nsIObserver");
return;
}
os->RemoveObserver(obs, "perm-changed");
os->RemoveObserver(obs, "fullscreen-approved");
if (aDispatchErrorEvents) {
DispatchPointerLockError(doc);
@ -9291,7 +9291,7 @@ nsDocument::SetPendingPointerLockRequest(Element* aElement)
nsCOMPtr<nsIObserver> obs(do_QueryInterface(aElement->OwnerDoc()));
NS_ENSURE_TRUE(obs != nsnull, NS_ERROR_FAILURE);
nsresult res = os->AddObserver(obs, "perm-changed", true);
nsresult res = os->AddObserver(obs, "fullscreen-approved", true);
NS_ENSURE_SUCCESS(res, res);
sPendingPointerLockDoc = do_GetWeakReference(aElement->OwnerDoc());
@ -9309,9 +9309,10 @@ nsDocument::Observe(nsISupports *aSubject,
const char *aTopic,
const PRUnichar *aData)
{
if (strcmp("perm-changed", aTopic) == 0) {
if (strcmp("fullscreen-approved", aTopic) == 0) {
nsCOMPtr<nsIDocument> subject(do_QueryInterface(aSubject));
nsCOMPtr<nsIDocument> doc(do_QueryReferent(sPendingPointerLockDoc));
if (nsContentUtils::IsSitePermAllow(doc->NodePrincipal(), "fullscreen")) {
if (subject == doc) {
nsCOMPtr<Element> element(do_QueryReferent(sPendingPointerLockElement));
nsDocument::ClearPendingPointerLockRequest(false);
nsAsyncPointerLockRequest::Request(element, doc);
@ -9337,7 +9338,7 @@ nsDocument::RequestPointerLock(Element* aElement)
DispatchPointerLockError(this);
return;
}
if (!nsContentUtils::IsSitePermAllow(NodePrincipal(), "fullscreen")) {
// Domain isn't yet approved for fullscreen, so we must wait until
// it's been approved.

View File

@ -1041,6 +1041,9 @@ SpecialPowersAPI.prototype = {
var pm = Cc["@mozilla.org/permissionmanager;1"].getService(Ci.nsIPermissionManager);
var uri = this.getDocumentURIObject(document);
pm.add(uri, "fullscreen", Ci.nsIPermissionManager.ALLOW_ACTION);
var obsvc = Cc['@mozilla.org/observer-service;1']
.getService(Ci.nsIObserverService);
obsvc.notifyObservers(document, "fullscreen-approved", null);
},
removeFullscreenAllowed: function(document) {