зеркало из https://github.com/mozilla/pjs.git
Bug 580576 - Clicking 'Share your location' in Fennec fails with an error in GeolocationPrompt.js [r=mfinkle]
This commit is contained in:
Родитель
033385d8dd
Коммит
dac27aaeeb
|
@ -14,41 +14,41 @@ GeolocationPrompt.prototype = {
|
|||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIGeolocationPrompt]),
|
||||
|
||||
prompt: function(request) {
|
||||
var result = Services.perms.testExactPermission(request.requestingURI, "geo");
|
||||
prompt: function(aRequest) {
|
||||
let pm = Services.perms;
|
||||
let result = pm.testExactPermission(aRequest.requestingURI, "geo");
|
||||
|
||||
if (result == Ci.nsIPermissionManager.ALLOW_ACTION) {
|
||||
request.allow();
|
||||
aRequest.allow();
|
||||
return;
|
||||
}
|
||||
if (result == Ci.nsIPermissionManager.DENY_ACTION) {
|
||||
request.cancel();
|
||||
} else if (result == Ci.nsIPermissionManager.DENY_ACTION) {
|
||||
aRequest.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
function setPagePermission(uri, allow) {
|
||||
var prefService = Services.prefs;
|
||||
function setPagePermission(aUri, aAllow) {
|
||||
let contentPrefs = Services.contentPrefs;
|
||||
|
||||
if (! prefService.hasPref(request.requestingURI, "geo.request.remember"))
|
||||
prefService.setPref(request.requestingURI, "geo.request.remember", 0);
|
||||
if (!contentPrefs.hasPref(aRequest.requestingURI, "geo.request.remember"))
|
||||
contentPrefs.setPref(aRequest.requestingURI, "geo.request.remember", 0);
|
||||
|
||||
var count = prefService.getPref(request.requestingURI, "geo.request.remember");
|
||||
let count = contentPrefs.getPref(aRequest.requestingURI, "geo.request.remember");
|
||||
|
||||
if (allow == false)
|
||||
if (aAllow == false)
|
||||
count--;
|
||||
else
|
||||
count++;
|
||||
|
||||
prefService.setPref(request.requestingURI, "geo.request.remember", count);
|
||||
contentPrefs.setPref(aRequest.requestingURI, "geo.request.remember", count);
|
||||
|
||||
if (count == kCountBeforeWeRemember)
|
||||
pm.add(uri, "geo", Ci.nsIPermissionManager.ALLOW_ACTION);
|
||||
pm.add(aUri, "geo", Ci.nsIPermissionManager.ALLOW_ACTION);
|
||||
else if (count == -kCountBeforeWeRemember)
|
||||
pm.add(uri, "geo", Ci.nsIPermissionManager.DENY_ACTION);
|
||||
pm.add(aUri, "geo", Ci.nsIPermissionManager.DENY_ACTION);
|
||||
}
|
||||
|
||||
function getChromeWindow(aWindow) {
|
||||
var chromeWin = aWindow
|
||||
let chromeWin = aWindow
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShellTreeItem)
|
||||
|
@ -59,36 +59,41 @@ GeolocationPrompt.prototype = {
|
|||
return chromeWin;
|
||||
}
|
||||
|
||||
var requestingWindow = request.requestingWindow.top;
|
||||
var chromeWin = getChromeWindow(requestingWindow).wrappedJSObject;
|
||||
let notificationBox = null;
|
||||
if (aRequest.requestingWindow) {
|
||||
let requestingWindow = aRequest.requestingWindow.top;
|
||||
let chromeWin = getChromeWindow(requestingWindow).wrappedJSObject;
|
||||
notificationBox = chromeWin.getNotificationBox(requestingWindow);
|
||||
} else {
|
||||
let chromeWin = aRequest.requestingElement.ownerDocument.defaultView;
|
||||
notificationBox = chromeWin.Browser.getNotificationBox();
|
||||
}
|
||||
|
||||
var notificationBox = chromeWin.getNotificationBox(requestingWindow);
|
||||
|
||||
var notification = notificationBox.getNotificationWithValue("geolocation");
|
||||
let notification = notificationBox.getNotificationWithValue("geolocation");
|
||||
if (!notification) {
|
||||
var browserBundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
|
||||
let browserBundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
|
||||
|
||||
var buttons = [{
|
||||
let buttons = [{
|
||||
label: browserBundle.GetStringFromName("geolocation.share"),
|
||||
accessKey: null,
|
||||
callback: function(notification) {
|
||||
setPagePermission(request.requestingURI, true);
|
||||
request.allow();
|
||||
setPagePermission(aRequest.requestingURI, true);
|
||||
aRequest.allow();
|
||||
},
|
||||
},
|
||||
{
|
||||
label: browserBundle.GetStringFromName("geolocation.dontShare"),
|
||||
accessKey: null,
|
||||
callback: function(notification) {
|
||||
setPagePermission(request.requestingURI, false);
|
||||
request.cancel();
|
||||
setPagePermission(aRequest.requestingURI, false);
|
||||
aRequest.cancel();
|
||||
},
|
||||
}];
|
||||
|
||||
var message = browserBundle.formatStringFromName("geolocation.siteWantsToKnow",
|
||||
[request.requestingURI.host], 1);
|
||||
let message = browserBundle.formatStringFromName("geolocation.siteWantsToKnow",
|
||||
[aRequest.requestingURI.host], 1);
|
||||
|
||||
var newBar = notificationBox.appendNotification(message,
|
||||
let newBar = notificationBox.appendNotification(message,
|
||||
"geolocation",
|
||||
"chrome://browser/skin/images/geo-16.png",
|
||||
notificationBox.PRIORITY_WARNING_MEDIUM,
|
||||
|
|
Загрузка…
Ссылка в новой задаче