mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-01 13:57:32 +00:00
Bug 1509047 - Part 4: Add support for PermissionPromptPrototype.onBeforeShow() cancelling a prompt; r=johannh
Differential Revision: https://phabricator.services.mozilla.com/D12865
This commit is contained in:
parent
66952eb338
commit
1a3a93b61f
@ -253,8 +253,12 @@ var PermissionPromptPrototype = {
|
||||
* be called just before. Subclasses may want to override this
|
||||
* in order to, for example, bump a counter Telemetry probe for
|
||||
* how often a particular permission request is seen.
|
||||
*
|
||||
* If this returns false, it cancels the process of showing the prompt. In
|
||||
* that case, it is the responsibility of the onBeforeShow() implementation
|
||||
* to ensure that allow() or cancel() are called on the object appropriately.
|
||||
*/
|
||||
onBeforeShow() {},
|
||||
onBeforeShow() { return true; },
|
||||
|
||||
/**
|
||||
* If the prompt was shown to the user, this callback will be called just
|
||||
@ -440,14 +444,15 @@ var PermissionPromptPrototype = {
|
||||
return false;
|
||||
};
|
||||
|
||||
this.onBeforeShow();
|
||||
chromeWin.PopupNotifications.show(this.browser,
|
||||
this.notificationID,
|
||||
this.message,
|
||||
this.anchorID,
|
||||
mainAction,
|
||||
secondaryActions,
|
||||
options);
|
||||
if (this.onBeforeShow() !== false) {
|
||||
chromeWin.PopupNotifications.show(this.browser,
|
||||
this.notificationID,
|
||||
this.message,
|
||||
this.anchorID,
|
||||
mainAction,
|
||||
secondaryActions,
|
||||
options);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@ -590,6 +595,7 @@ GeolocationPermissionPrompt.prototype = {
|
||||
let secHistogram = Services.telemetry.getHistogramById("SECURITY_UI");
|
||||
const SHOW_REQUEST = Ci.nsISecurityUITelemetry.WARNING_GEOLOCATION_REQUEST;
|
||||
secHistogram.add(SHOW_REQUEST);
|
||||
return true;
|
||||
},
|
||||
};
|
||||
|
||||
@ -826,9 +832,6 @@ MIDIPermissionPrompt.prototype = {
|
||||
action: Ci.nsIPermissionManager.DENY_ACTION,
|
||||
}];
|
||||
},
|
||||
|
||||
onBeforeShow() {
|
||||
},
|
||||
};
|
||||
|
||||
PermissionUI.MIDIPermissionPrompt = MIDIPermissionPrompt;
|
||||
@ -911,6 +914,7 @@ AutoplayPermissionPrompt.prototype = {
|
||||
};
|
||||
this.browser.addEventListener(
|
||||
"DOMAudioPlaybackStarted", this.handlePlaybackStart);
|
||||
return true;
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -294,6 +294,7 @@ add_task(async function test_on_before_show() {
|
||||
promptActions: [mainAction],
|
||||
onBeforeShow() {
|
||||
beforeShown = true;
|
||||
return true;
|
||||
},
|
||||
};
|
||||
|
||||
@ -353,6 +354,7 @@ add_task(async function test_no_request() {
|
||||
promptActions: [mainAction, secondaryAction],
|
||||
onBeforeShow() {
|
||||
beforeShown = true;
|
||||
return true;
|
||||
},
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user