Remove timer and mic toggles for video recording.

BUG=chromium:253813
TEST=Tested manually on elm.

Change-Id: I1a1688987fba258a857abb13d34baf88463e79f0
Reviewed-on: https://chromium-review.googlesource.com/915783
Reviewed-by: Sheng-hao Tsao <shenghao@google.com>
Tested-by: yuli <yuli@chromium.org>
diff --git a/Makefile b/Makefile
index db67a90..1b6aaf7 100644
--- a/Makefile
+++ b/Makefile
@@ -64,7 +64,6 @@
 	src/images/2x/browser_button_print.png \
 	src/images/2x/camera_button_album.png \
 	src/images/2x/camera_button_filters.png \
-        src/images/2x/camera_button_mic.png \
 	src/images/2x/camera_button_mirror.png \
 	src/images/2x/camera_button_multi.png \
 	src/images/2x/camera_button_picture.png \
@@ -88,7 +87,6 @@
 	src/images/camera_app_icons_favicon_32.png \
 	src/images/camera_button_album.png \
 	src/images/camera_button_filters.png \
-        src/images/camera_button_mic.png \
 	src/images/camera_button_mirror.png \
 	src/images/camera_button_multi.png \
 	src/images/camera_button_picture.png \
diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json
index 45c0a7f..89c255b 100644
--- a/src/_locales/en/messages.json
+++ b/src/_locales/en/messages.json
@@ -185,10 +185,6 @@
     "message": "Toggle multi-shot",
     "description": "Label for the button to toggle the multi-shot feature."
   },
-  "toggleMicButton": {
-    "message": "Toggle microphone",
-    "description": "Label for the button to toggle the microphone for video recording."
-  },
   "toggleCameraButton": {
     "message": "Toggle camera",
     "description": "Label for the button to switch between multiple cameras. Eg. switching from front facing to back facing, or a camera connected via USB. The button is shown only when more than one camera is connected."
@@ -237,14 +233,6 @@
     "message": "Mirroring inactive",
     "description": "Message shown when inactivating the preview mirroring."
   },
-  "toggleMicActiveMessage": {
-    "message": "Microphone active",
-    "description": "Message shown when unmuting the microphone for video recording."
-  },
-  "toggleMicInactiveMessage": {
-    "message": "Microphone inactive",
-    "description": "Message shown when muting the microphone for video recording."
-  },
   "dialogYesButton": {
     "message": "Yes",
     "description": "Label for the accepting button in the confirmation dialog."
diff --git a/src/css/main.css b/src/css/main.css
index f96953e..02ed835 100644
--- a/src/css/main.css
+++ b/src/css/main.css
@@ -511,15 +511,6 @@
   width: 32px;
 }
 
-.buttons #toggle-mic {
-  -webkit-appearance: none;
-  background-image: -webkit-image-set(
-      url(../images/camera_button_mic.png) 1x,
-      url(../images/2x/camera_button_mic.png) 2x);
-  height: 32px;
-  width: 32px;
-}
-
 .buttons #toggle-camera {
   background-image: -webkit-image-set(
       url(../images/camera_button_toggle.png) 1x,
@@ -550,8 +541,7 @@
 .buttons #toggle-record.toggle-off,
 .buttons #toggle-timer:not(:checked),
 .buttons #toggle-multi:not(:checked),
-.buttons #toggle-mirror:not(:checked),
-.buttons #toggle-mic:not(:checked) {
+.buttons #toggle-mirror:not(:checked) {
   background-position: 0 -32px;
 }
 
diff --git a/src/images/2x/camera_button_mic.png b/src/images/2x/camera_button_mic.png
deleted file mode 100644
index 3b792878..0000000
--- a/src/images/2x/camera_button_mic.png
+++ /dev/null
Binary files differ
diff --git a/src/images/camera_button_mic.png b/src/images/camera_button_mic.png
deleted file mode 100644
index c41ba4f..0000000
--- a/src/images/camera_button_mic.png
+++ /dev/null
Binary files differ
diff --git a/src/js/views/camera.js b/src/js/views/camera.js
index aade15f2..452ae87 100644
--- a/src/js/views/camera.js
+++ b/src/js/views/camera.js
@@ -565,10 +565,6 @@
       'keypress', this.onToggleMultiKeyPress_.bind(this));
   document.querySelector('#toggle-multi').addEventListener(
       'click', this.onToggleMultiClicked_.bind(this));
-  document.querySelector('#toggle-mic').addEventListener(
-      'keypress', this.onToggleMicKeyPress_.bind(this));
-  document.querySelector('#toggle-mic').addEventListener(
-      'click', this.onToggleMicClicked_.bind(this));
   document.querySelector('#toggle-camera').addEventListener(
       'click', this.onToggleCameraClicked_.bind(this));
   document.querySelector('#toggle-mirror').addEventListener(
@@ -950,18 +946,6 @@
 };
 
 /**
- * Handles pressing a key on the microphone switch for video-recording.
- * @param {Event} event Key press event.
- * @private
- */
-camera.views.Camera.prototype.onToggleMicKeyPress_ = function(event) {
-  if (this.performanceTestTimer_)
-    return;
-  if (camera.util.getShortcutIdentifier(event) == 'Enter')
-    document.querySelector('#toggle-mic').click();
-};
-
-/**
  * Handles pressing a key on the mirror switch.
  * @param {Event} event Key press event.
  * @private
@@ -1004,22 +988,6 @@
 };
 
 /**
- * Handles clicking on the microphone switch for video-recording.
- * @param {Event} event Click event.
- * @private
- */
-camera.views.Camera.prototype.onToggleMicClicked_ = function(event) {
-  if (this.performanceTestTimer_)
-    return;
-
-  var enabled = document.querySelector('#toggle-mic').checked;
-  this.stream_.getAudioTracks()[0].enabled = enabled;
-  this.showToastMessage_(
-      chrome.i18n.getMessage(enabled ? 'toggleMicActiveMessage' :
-                                       'toggleMicInactiveMessage'));
-};
-
-/**
  * Handles clicking on the toggle camera switch.
  * @param {Event} event Click event.
  * @private
@@ -1096,8 +1064,7 @@
   }
 
   document.querySelector('#toggle-multi').hidden = recordEnabled;
-  document.querySelector('#toggle-mic').hidden = !recordEnabled;
-  this.updateMic_(recordEnabled);
+  document.querySelector('#toggle-timer').hidden = recordEnabled;
   this.showToastMessage_(chrome.i18n.getMessage(recordEnabled ?
       'recordVideoActiveMessage' : 'takePictureActiveMessage'));
 };
@@ -1194,22 +1161,15 @@
 };
 
 /**
- * Updates the microphone either set automatically or by user.
+ * Enables the audio track for audio capturing.
  *
- * @param {boolean} active True to set microphone active, false to inactive.
+ * @param {boolean} enabled True to enable audio track, false to disable.
  * @private
  */
-camera.views.Camera.prototype.updateMic_ = function(active) {
-  var toggleMic = document.querySelector('#toggle-mic');
-
-  // Enable the microphone switch only if there is an audio track.
+camera.views.Camera.prototype.enableAudio_ = function(enabled) {
   var track = this.stream_ && this.stream_.getAudioTracks()[0];
-  toggleMic.disabled = (track == null);
-  if (toggleMic.disabled) {
-    toggleMic.checked = false;
-  } else {
-    toggleMic.checked = active;
-    track.enabled = active;
+  if (track) {
+    track.enabled = enabled;
   }
 };
 
@@ -1846,6 +1806,7 @@
         var takePictureButton = document.querySelector('#take-picture');
         this.mediaRecorder_.onstop = function(event) {
           takePictureButton.classList.remove('flash');
+          this.enableAudio_(false);
           // Add the motion picture after the recording is ended.
           // TODO(yuli): Handle insufficient storage.
           var recordedBlob = new Blob(recordedChunks, {type: 'video/webm'});
@@ -1866,6 +1827,7 @@
         }.bind(this);
 
         // Start recording.
+        this.enableAudio_(true);
         this.mediaRecorder_.start();
 
         // Re-enable the take-picture button to stop recording later and flash
@@ -2026,8 +1988,8 @@
       this.mediaRecorder_ = this.createMediaRecorder_(stream);
       document.querySelector('#toggle-record').disabled =
           (this.mediaRecorder_ == null);
-      // Disable audio stream unless it's for video recording.
-      this.updateMic_(false);
+      // Disable audio stream unless it's video recording.
+      this.enableAudio_(false);
       this.capturing_ = true;
       var onAnimationFrame = function() {
         if (!this.running_)
diff --git a/src/views/main.html b/src/views/main.html
index c72a069..09e656b 100644
--- a/src/views/main.html
+++ b/src/views/main.html
@@ -72,8 +72,6 @@
                        i18n-label="toggleTimerButton" checked>
                 <input type="checkbox" id="toggle-multi" tabindex="0"
                        i18n-label="toggleMultiButton" checked>
-                <input type="checkbox" id="toggle-mic" tabindex="0"
-                       i18n-label="toggleMicButton" checked hidden>
               </div>
               <div class="buttons">
                 <button id="album-enter" tabindex="0"