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 ad94315f060d5dd0ea227f7ca5ce672eec2a9ff7..cde2fc7a527b5af6f5e04dfa107551ee3aa74a72 100644 |
--- a/chrome/browser/resources/chromeos/user_images_grid.js |
+++ b/chrome/browser/resources/chromeos/user_images_grid.js |
@@ -188,7 +188,8 @@ cr.define('options', function() { |
}, |
/** |
- * @param {boolean} present Whether a camera is present or not. |
+ * Whether a camera is present or not. |
+ * @type {boolean} |
*/ |
get cameraPresent() { |
return this.cameraPresent_; |
@@ -200,6 +201,15 @@ cr.define('options', function() { |
}, |
/** |
+ * Whether camera is actually streaming video. May be |false| even when |
+ * camera is present and shown but still initializing. |
+ * @type {boolean} |
+ */ |
+ get cameraOnline() { |
+ return this.previewElement.classList.contains('online'); |
+ }, |
+ |
+ /** |
* Start camera presence check. |
* @param {boolean} autoplay Whether to start capture immediately. |
* @param {boolean} preselect Whether to select camera automatically. |
@@ -439,8 +449,11 @@ cr.define('options', function() { |
* Performs photo capture from the live camera stream. |
* @param {function=} opt_callback Callback that receives taken photo as |
* data URL. |
+ * @return {boolean} Whether photo capture was successful. |
*/ |
takePhoto: function(opt_callback) { |
+ if (!this.cameraOnline) |
+ return false; |
var canvas = document.createElement('canvas'); |
canvas.width = CAPTURE_SIZE.width; |
canvas.height = CAPTURE_SIZE.height; |
@@ -456,6 +469,7 @@ cr.define('options', function() { |
self.cameraImage = this.src; |
}); |
previewImg.src = photoURL; |
+ return true; |
}, |
/** |