Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #29437 from jryans/qr-size-prod-2
Browse files Browse the repository at this point in the history
Bug 1145772 - Improve WiFi auth image capture
  • Loading branch information
jryans committed Apr 15, 2015
2 parents 2dd89fe + aac1bf5 commit 4f71285
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions apps/system/js/devtools/devtools_auth.js
Expand Up @@ -71,7 +71,13 @@
var getUserMedia = navigator.getUserMedia || navigator.mozGetUserMedia;
getUserMedia = getUserMedia.bind(navigator);

getUserMedia({ video: true, audio: false }, function(stream) {
getUserMedia({
video: {
width: { min: 480 },
height: { min: 480 }
},
audio: false
}, function(stream) {
var video = this.dialog.video;

video.addEventListener('loadedmetadata', function onMetadata() {
Expand All @@ -92,18 +98,12 @@
* @memberof DevToolsAuth.prototype
*/
capture: function() {
if (this._inflightURL) {
URL.revokeObjectURL(this._inflightURL);
this._inflightURL = null;
}
var video = this.dialog.video;
var canvas = this.canvas;
var context = canvas.getContext('2d');
context.drawImage(video, 0, 0, canvas.width, canvas.height);
canvas.toBlob(function(blob) {
this._inflightURL = URL.createObjectURL(blob);
this._checkImage(this._inflightURL);
}.bind(this), 'image/jpeg');
var url = canvas.toDataURL('image/jpeg');
this._checkImage(url);
},

/**
Expand All @@ -126,10 +126,6 @@
video.mozSrcObject = null;
}
this._canvas = null;
if (this._inflightURL) {
URL.revokeObjectURL(this._inflightURL);
this._inflightURL = null;
}
if (reason !== 'complete') {
this.abort();
}
Expand Down

0 comments on commit 4f71285

Please sign in to comment.