Bug 742092 - Bridge the permission prompt to the content using the homescreen messaging API. r=fabrice

This commit is contained in:
Vivien Nicolas 2012-04-06 03:12:18 -07:00
Родитель eb9a1485a7
Коммит 9865ee1666
2 изменённых файлов: 27 добавлений и 4 удалений

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

@ -437,7 +437,7 @@ Services.obs.addObserver(function onConsoleAPILogEvent(subject, topic, data) {
serverSocket.asyncListen(listener);
})();
CustomEventManager = {
var CustomEventManager = {
init: function custevt_init() {
window.addEventListener("ContentStart", (function(evt) {
content.addEventListener("mozContentEvent", this, false, true);
@ -461,7 +461,7 @@ CustomEventManager = {
}
}
AlertsHelper = {
var AlertsHelper = {
_listeners: {},
_count: 0,
@ -492,7 +492,7 @@ AlertsHelper = {
}
}
WebappsHelper = {
var WebappsHelper = {
_installers: {},
_count: 0,

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

@ -27,12 +27,35 @@ ContentPermissionPrompt.prototype = {
return false;
},
_id: 0,
prompt: function(request) {
// returns true if the request was handled
if (this.handleExistingPermission(request))
return;
// TODO : show UI to grant or deny permission
let browser = Services.wm.getMostRecentWindow("navigator:browser");
let content = browser.content;
if (!content)
return;
let requestId = this._id++;
content.addEventListener("mozContentEvent", function contentEvent(evt) {
if (evt.detail.id != requestId)
return;
content.removeEventListener(evt.type, contentEvent);
if (evt.detail.type == "permission-allow") {
request.allow();
return;
}
request.cancel();
});
browser.shell.sendEvent(browser.content, "mozChromeEvent", {
"type": "permission-prompt", "permission": request.type,
"id": requestId, "url": request.uri.spec
});
},
classID: Components.ID("{8c719f03-afe0-4aac-91ff-6c215895d467}"),