Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6242)

Unified Diff: chrome/browser/resources/chromeos/user_images_grid.js

Issue 10986046: Merge 158045 - [cros] Avatar picker: various fixes for web camera problems. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1271/src/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/chromeos/user_images_grid.js
===================================================================
--- chrome/browser/resources/chromeos/user_images_grid.js (revision 158765)
+++ chrome/browser/resources/chromeos/user_images_grid.js (working copy)
@@ -20,7 +20,7 @@
* Interval between consecutive camera liveness checks in msec.
* @const
*/
- var CAMERA_LIVENESS_CHECK_MS = 1000;
+ var CAMERA_LIVENESS_CHECK_MS = 3000;
/**
* Number of frames recorded by takeVideo().
@@ -170,6 +170,8 @@
if (this.selectedItem === null)
return;
+ var oldSelectionType = this.selectionType;
+
// Update current selection type.
this.selectionType = this.selectedItem.type;
@@ -179,7 +181,9 @@
this.updatePreview_();
- cr.dispatchSimpleEvent(this, 'select');
+ var e = new cr.Event('select', false, false);
+ e.oldSelectionType = oldSelectionType;
+ this.dispatchEvent(e);
},
/**
@@ -241,6 +245,7 @@
}
if (!this.cameraVideo_)
return;
+ this.cameraCheckInProgress_ = true;
navigator.webkitGetUserMedia(
{video: true},
this.handleCameraAvailable_.bind(this, onAvailable),
@@ -255,6 +260,8 @@
this.cameraOnline = false;
if (this.cameraVideo_)
this.cameraVideo_.src = '';
+ // Cancel any pending getUserMedia() checks.
+ this.cameraCheckInProgress_ = false;
},
/**
@@ -266,8 +273,9 @@
*/
handleCameraAvailable_: function(onAvailable, stream) {
this.cameraPresent = true;
- if (onAvailable())
+ if (this.cameraCheckInProgress_ && onAvailable())
this.cameraVideo_.src = window.webkitURL.createObjectURL(stream);
+ this.cameraCheckInProgress_ = false;
},
/**
@@ -289,6 +297,7 @@
this.checkCameraPresence.bind(this, onAvailable, onAbsent),
CAMERA_CHECK_INTERVAL_MS);
}
+ this.cameraCheckInProgress_ = false;
},
/**
@@ -452,6 +461,13 @@
this.cameraVideo_.addEventListener('timeupdate',
this.handleVideoUpdate_.bind(this));
this.updatePreview_();
+ this.checkCameraPresence(
+ function() {
+ return false; // Don't start streaming if camera is present.
+ },
+ function() {
+ return false; // Don't retry if camera is absent.
+ });
},
/**

Powered by Google App Engine
This is Rietveld 408576698