зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1243431 - [4.1] Show permission request doorhanger on vibration request. r=margaret
This commit is contained in:
Родитель
1cb3a78441
Коммит
17fe5573bf
|
@ -122,6 +122,8 @@ public class DoorHangerPopup extends AnchoredPopup
|
|||
doorhangerType = DoorHanger.Type.DESKTOPNOTIFICATION2;
|
||||
} else if (DoorHanger.Type.WEBRTC.toString().equals(typeString)) {
|
||||
doorhangerType = DoorHanger.Type.WEBRTC;
|
||||
} else if (DoorHanger.Type.VIBRATION.toString().equals(typeString)) {
|
||||
doorhangerType = DoorHanger.Type.VIBRATION;
|
||||
}
|
||||
|
||||
final DoorhangerConfig config = new DoorhangerConfig(tabId, id, doorhangerType, this);
|
||||
|
|
|
@ -39,7 +39,7 @@ public abstract class DoorHanger extends LinearLayout {
|
|||
}
|
||||
|
||||
// Doorhanger types created from Gecko are checked against enum strings to determine type.
|
||||
public static enum Type { DEFAULT, LOGIN, TRACKING, GEOLOCATION, DESKTOPNOTIFICATION2, WEBRTC }
|
||||
public static enum Type { DEFAULT, LOGIN, TRACKING, GEOLOCATION, DESKTOPNOTIFICATION2, WEBRTC, VIBRATION }
|
||||
|
||||
public interface OnButtonClickListener {
|
||||
public void onButtonClick(JSONObject response, DoorHanger doorhanger);
|
||||
|
|
|
@ -384,6 +384,7 @@ var BrowserApp = {
|
|||
Services.obs.addObserver(this, "keyword-search", false);
|
||||
Services.obs.addObserver(this, "sessionstore-state-purge-complete", false);
|
||||
Services.obs.addObserver(this, "Fonts:Reload", false);
|
||||
Services.obs.addObserver(this, "Vibration:Request", false);
|
||||
|
||||
Messaging.addListener(this.getHistory.bind(this), "Session:GetHistory");
|
||||
|
||||
|
@ -1950,6 +1951,33 @@ var BrowserApp = {
|
|||
FontEnumerator.updateFontList();
|
||||
break;
|
||||
|
||||
case "Vibration:Request":
|
||||
if (aSubject instanceof Navigator) {
|
||||
let navigator = aSubject;
|
||||
let buttons = [
|
||||
{
|
||||
label: Strings.browser.GetStringFromName("vibrationRequest.denyButton"),
|
||||
callback: function() {
|
||||
navigator.setVibrationPermission(false);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: Strings.browser.GetStringFromName("vibrationRequest.allowButton"),
|
||||
callback: function() {
|
||||
navigator.setVibrationPermission(true);
|
||||
},
|
||||
positive: true
|
||||
}
|
||||
];
|
||||
let message = Strings.browser.GetStringFromName("vibrationRequest.message");
|
||||
let options = {};
|
||||
// Workaround for bug 1268471.
|
||||
NativeWindow.doorhanger.hide("vibration-request", BrowserApp.selectedTab.id);
|
||||
NativeWindow.doorhanger.show(message, "vibration-request", buttons,
|
||||
BrowserApp.selectedTab.id, options, "VIBRATION");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
dump('BrowserApp.observe: unexpected topic "' + aTopic + '"\n');
|
||||
break;
|
||||
|
|
Загрузка…
Ссылка в новой задаче