Add command line switch to enable speech input and disable for beta/stable channels.
The browser process now determines if the API should be enabled and sets the
'speech input enabled' flag in the render thread as part of the initialization routine.

BUG=61677
TEST=none

Review URL: http://codereview.chromium.org/4644004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66266 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc
index b871bbe8..e387ee1 100644
--- a/chrome/renderer/render_thread.cc
+++ b/chrome/renderer/render_thread.cc
@@ -215,9 +215,6 @@
   DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer);
 };
 
-bool IsSpeechInputEnabled(const CommandLine& command_line) {
-  return !command_line.HasSwitch(switches::kDisableSpeechInput);
-}
 }  // namespace
 
 // When we run plugins in process, we actually run them on the render thread,
@@ -248,6 +245,7 @@
   is_extension_process_ = type_str == switches::kExtensionProcess ||
       CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess);
   is_incognito_process_ = false;
+  is_speech_input_enabled_ = false;
   suspend_webkit_shared_timer_ = true;
   notify_webkit_of_modal_loop_ = true;
   plugin_refresh_allowed_ = true;
@@ -626,9 +624,16 @@
                         OnSpellCheckEnableAutoSpellCorrect)
     IPC_MESSAGE_HANDLER(ViewMsg_GpuChannelEstablished, OnGpuChannelEstablished)
     IPC_MESSAGE_HANDLER(ViewMsg_SetPhishingModel, OnSetPhishingModel)
+    IPC_MESSAGE_HANDLER(ViewMsg_SpeechInput_SetFeatureEnabled,
+                        OnSetSpeechInputEnabled)
   IPC_END_MESSAGE_MAP()
 }
 
+void RenderThread::OnSetSpeechInputEnabled(bool enabled) {
+  DCHECK(!webkit_client_.get());
+  is_speech_input_enabled_ = enabled;
+}
+
 void RenderThread::OnSetNextPageID(int32 next_page_id) {
   // This should only be called at process initialization time, so we shouldn't
   // have to worry about thread-safety.
@@ -925,7 +930,7 @@
   WebRuntimeFeatures::enableDeviceOrientation(
       !command_line.HasSwitch(switches::kDisableDeviceOrientation));
 
-  WebRuntimeFeatures::enableSpeechInput(IsSpeechInputEnabled(command_line));
+  WebRuntimeFeatures::enableSpeechInput(is_speech_input_enabled_);
 
   WebRuntimeFeatures::enableFileSystem(
       !command_line.HasSwitch(switches::kDisableFileSystem));