Chromium Code Reviews| Index: chrome/browser/resources/chromeos/user_images_grid.js |
| diff --git a/chrome/browser/resources/chromeos/user_images_grid.js b/chrome/browser/resources/chromeos/user_images_grid.js |
| index 0f47f1f1deaf3bc86cb5838923cbbe00b92c4d1f..f30000024acab999740cbc499bc22d4a1cf58950 100644 |
| --- a/chrome/browser/resources/chromeos/user_images_grid.js |
| +++ b/chrome/browser/resources/chromeos/user_images_grid.js |
| @@ -20,7 +20,7 @@ cr.define('options', function() { |
| * 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 @@ cr.define('options', function() { |
| if (this.selectedItem === null) |
| return; |
| + var oldSelectionType = this.selectionType; |
| + |
| // Update current selection type. |
| this.selectionType = this.selectedItem.type; |
| @@ -179,7 +181,9 @@ cr.define('options', function() { |
| this.updatePreview_(); |
| - cr.dispatchSimpleEvent(this, 'select'); |
| + var e = new cr.Event('select', false, false); |
| + e.oldSelectionType = oldSelectionType; |
| + this.dispatchEvent(e); |
| }, |
| /** |
| @@ -241,6 +245,7 @@ cr.define('options', function() { |
| } |
| if (!this.cameraVideo_) |
| return; |
| + this.cameraCheckInProgress_ = true; |
| navigator.webkitGetUserMedia( |
| {video: true}, |
| this.handleCameraAvailable_.bind(this, onAvailable), |
| @@ -255,6 +260,8 @@ cr.define('options', function() { |
| this.cameraOnline = false; |
| if (this.cameraVideo_) |
| this.cameraVideo_.src = ''; |
| + // Cancel any pending getUserMedia() checks. |
| + this.cameraCheckInProgress_ = false; |
| }, |
| /** |
| @@ -266,8 +273,9 @@ cr.define('options', function() { |
| */ |
| handleCameraAvailable_: function(onAvailable, stream) { |
| this.cameraPresent = true; |
| - if (onAvailable()) |
| + if (this.cameraCheckInProgress_ && onAvailable()) |
| this.cameraVideo_.src = window.webkitURL.createObjectURL(stream); |
| + this.cameraCheckInProgress_ = false; |
| }, |
| /** |
| @@ -452,6 +460,9 @@ cr.define('options', function() { |
| this.cameraVideo_.addEventListener('timeupdate', |
| this.handleVideoUpdate_.bind(this)); |
| this.updatePreview_(); |
| + // Check for camera presence once and without selecting it. |
| + this.checkCameraPresence(function() { return false; }, |
|
Nikita (slow)
2012/09/21 16:52:28
nit: move these comments to functions.
Ivan Korotkov
2012/09/21 16:58:46
Done.
|
| + function() { return false; }); |
| }, |
| /** |