Added guard against non-SSL access

upd4.1
Bernat Romagosa 2017-04-12 10:31:44 +02:00
rodzic c9885ad5b1
commit 075d9c2d3a
1 zmienionych plików z 22 dodań i 2 usunięć

Wyświetl plik

@ -8758,6 +8758,20 @@ CamSnapshotDialogMorph.prototype.buildContents = function () {
this.drawNew();
};
CamSnapshotDialogMorph.prototype.popUp = function (world) {
CamSnapshotDialogMorph.uber.popUp.call(this, world);
if (location.protocol === 'http:') {
this.ide.inform(
'SSL Error',
'Due to browser security policies, you need to\n' +
'access Snap! through HTTPS to use the camera.\n\n' +
'Plase replace the "http://" part of the address\n' +
'in your browser by "https://" and try again.');
this.destroy();
}
};
CamSnapshotDialogMorph.prototype.ok = function () {
var stage = this.ide.stage,
canvas = newCanvas(stage.dimensions);
@ -8775,11 +8789,17 @@ CamSnapshotDialogMorph.prototype.ok = function () {
);
this.accept(new Costume(canvas), this.sprite.newCostumeName('camera'));
CamSnapshotDialogMorph.uber.destroy.call(this);
this.close();
};
CamSnapshotDialogMorph.prototype.destroy = function () {
this.videoElement.remove();
this.oncancel.call(this);
this.close();
};
CamSnapshotDialogMorph.prototype.close = function () {
if (this.videoElement) {
this.videoElement.remove();
}
CamSnapshotDialogMorph.uber.destroy.call(this);
};