diff options
author | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-04 07:55:03 +0000 |
---|---|---|
committer | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-04 07:55:03 +0000 |
commit | 21e0cbf6bf480671aef2b3e07502bf665627f4ab (patch) | |
tree | 0c30a09d2f25c7a24d1407bb7bf9092ecc6104d9 | |
parent | bf96f533df6515f9ddea3278515a77ab81c00263 (diff) | |
download | chromium_src-21e0cbf6bf480671aef2b3e07502bf665627f4ab.zip chromium_src-21e0cbf6bf480671aef2b3e07502bf665627f4ab.tar.gz chromium_src-21e0cbf6bf480671aef2b3e07502bf665627f4ab.tar.bz2 |
Enable speech input by default and remove unused code.
This CL is the same as what I submitted for M10 in http://codereview.chromium.org/6133006/, but rolled back then. We are now enabling the feature for M11.
BUG=61677
TEST=browser_tests --gtest_filter="SpeechInputBrowserTest.*"
Review URL: http://codereview.chromium.org/6610022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76893 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/renderer_host/browser_render_process_host.cc | 7 | ||||
-rw-r--r-- | chrome/browser/renderer_host/browser_render_process_host.h | 4 | ||||
-rw-r--r-- | chrome/browser/speech/speech_input_manager.cc | 21 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 3 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 | ||||
-rw-r--r-- | chrome/common/render_messages_internal.h | 4 | ||||
-rw-r--r-- | chrome/renderer/render_thread.cc | 11 | ||||
-rw-r--r-- | chrome/renderer/render_thread.h | 6 | ||||
-rw-r--r-- | content/browser/speech/speech_input_browsertest.cc | 4 | ||||
-rw-r--r-- | content/browser/speech/speech_input_dispatcher_host.cc | 36 | ||||
-rw-r--r-- | content/browser/speech/speech_input_manager.h | 4 |
11 files changed, 18 insertions, 83 deletions
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index 2648751..374d5c3 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -89,7 +89,6 @@ #include "content/browser/renderer_host/resource_message_filter.h" #include "content/browser/renderer_host/socket_stream_dispatcher_host.h" #include "content/browser/speech/speech_input_dispatcher_host.h" -#include "content/browser/speech/speech_input_manager.h" #include "content/browser/worker_host/worker_message_filter.h" #include "grit/generated_resources.h" #include "ipc/ipc_logging.h" @@ -824,11 +823,6 @@ void BrowserRenderProcessHost::InitExtensions() { } } -void BrowserRenderProcessHost::InitSpeechInput() { - Send(new ViewMsg_SpeechInput_SetFeatureEnabled( - speech_input::SpeechInputManager::IsFeatureEnabled())); -} - void BrowserRenderProcessHost::SendUserScriptsUpdate( base::SharedMemory *shared_memory) { // Process is being started asynchronously. We'll end up calling @@ -1162,7 +1156,6 @@ void BrowserRenderProcessHost::OnProcessLaunched() { Send(new ViewMsg_SetIsIncognitoProcess(profile()->IsOffTheRecord())); - InitSpeechInput(); InitVisitedLinks(); InitUserScripts(); InitExtensions(); diff --git a/chrome/browser/renderer_host/browser_render_process_host.h b/chrome/browser/renderer_host/browser_render_process_host.h index 6ef691d..e70263e 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.h +++ b/chrome/browser/renderer_host/browser_render_process_host.h @@ -116,10 +116,6 @@ class BrowserRenderProcessHost : public RenderProcessHost, // functions to thre renderer process. void InitExtensions(); - // Initialize support for speech input API. Informs the renderer if the API - // is enabled or not. - void InitSpeechInput(); - // Sends the renderer process a new set of user scripts. void SendUserScriptsUpdate(base::SharedMemory* shared_memory); diff --git a/chrome/browser/speech/speech_input_manager.cc b/chrome/browser/speech/speech_input_manager.cc index cbc6f12..5f65e02 100644 --- a/chrome/browser/speech/speech_input_manager.cc +++ b/chrome/browser/speech/speech_input_manager.cc @@ -7,7 +7,6 @@ #include <map> #include <string> -#include "base/command_line.h" #include "base/lazy_instance.h" #include "base/ref_counted.h" #include "base/synchronization/lock.h" @@ -163,26 +162,6 @@ SpeechInputManager* SpeechInputManager::Get() { return g_speech_input_manager_impl.Pointer(); } -bool SpeechInputManager::IsFeatureEnabled() { - bool enabled = true; - const CommandLine& command_line = *CommandLine::ForCurrentProcess(); - - if (command_line.HasSwitch(switches::kDisableSpeechInput)) { - enabled = false; -#if defined(GOOGLE_CHROME_BUILD) - } else if (!command_line.HasSwitch(switches::kEnableSpeechInput)) { - // We need to evaluate whether IO is OK here. http://crbug.com/63335. - base::ThreadRestrictions::ScopedAllowIO allow_io; - // Official Chrome builds have speech input enabled by default only in the - // dev channel. - std::string channel = platform_util::GetVersionStringModifier(); - enabled = (channel == "dev"); -#endif - } - - return enabled; -} - void SpeechInputManager::ShowAudioInputSettings() { // Since AudioManager::ShowAudioInputSettings can potentially launch external // processes, do that in the FILE thread to not block the calling threads. diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index c6febe0..079335a 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -543,9 +543,6 @@ const char kEnableSearchProviderApiV2[] = "enable-search-provider-api-v2"; // Enables 0-RTT HTTPS handshakes. const char kEnableSnapStart[] = "enable-snap-start"; -// Enables speech input. -const char kEnableSpeechInput[] = "enable-speech-input"; - // Enable syncing browser data to a Google Account. const char kEnableSync[] = "enable-sync"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 5eafff2..1fd8a08 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -161,7 +161,6 @@ extern const char kEnableRemoting[]; extern const char kEnableResourceContentSettings[]; extern const char kEnableSearchProviderApiV2[]; extern const char kEnableSnapStart[]; -extern const char kEnableSpeechInput[]; extern const char kEnableSync[]; extern const char kEnableSyncAutofill[]; extern const char kEnableSyncPreferences[]; diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 47b2f6e..cd13198 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -1068,10 +1068,6 @@ IPC_MESSAGE_ROUTED1(ViewMsg_StartPhishingDetection, GURL) IPC_MESSAGE_ROUTED1(ViewMsg_SelectPopupMenuItem, int /* selected index, -1 means no selection */) -// Indicate whether speech input API is enabled or not. -IPC_MESSAGE_CONTROL1(ViewMsg_SpeechInput_SetFeatureEnabled, - bool /* enabled */) - // Sent in response to a ViewHostMsg_ContextMenu to let the renderer know that // the menu has been closed. IPC_MESSAGE_ROUTED1(ViewMsg_ContextMenuClosed, diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index 49da6e2..d1eeaf1 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -246,7 +246,6 @@ void RenderThread::Init() { 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; @@ -645,18 +644,11 @@ bool RenderThread::OnControlMessageReceived(const IPC::Message& msg) { OnSpellCheckEnableAutoSpellCorrect) IPC_MESSAGE_HANDLER(ViewMsg_GpuChannelEstablished, OnGpuChannelEstablished) IPC_MESSAGE_HANDLER(ViewMsg_SetPhishingModel, OnSetPhishingModel) - IPC_MESSAGE_HANDLER(ViewMsg_SpeechInput_SetFeatureEnabled, - OnSetSpeechInputEnabled) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; } -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. @@ -959,7 +951,8 @@ void RenderThread::EnsureWebKitInitialized() { WebRuntimeFeatures::enableDeviceOrientation( !command_line.HasSwitch(switches::kDisableDeviceOrientation)); - WebRuntimeFeatures::enableSpeechInput(is_speech_input_enabled_); + WebRuntimeFeatures::enableSpeechInput( + !command_line.HasSwitch(switches::kDisableSpeechInput)); WebRuntimeFeatures::enableFileSystem( !command_line.HasSwitch(switches::kDisableFileSystem)); diff --git a/chrome/renderer/render_thread.h b/chrome/renderer/render_thread.h index d4bcbaf..02a2fa1 100644 --- a/chrome/renderer/render_thread.h +++ b/chrome/renderer/render_thread.h @@ -324,8 +324,6 @@ class RenderThread : public RenderThreadBase, void OnGetAccessibilityTree(); - void OnSetSpeechInputEnabled(bool enabled); - // Gather usage statistics from the in-memory cache and inform our host. // These functions should be call periodically so that the host can make // decisions about how to allocation resources using current information. @@ -391,10 +389,6 @@ class RenderThread : public RenderThreadBase, bool suspend_webkit_shared_timer_; bool notify_webkit_of_modal_loop_; - // True if this renderer has speech input enabled, set once during thread - // initialization. - bool is_speech_input_enabled_; - // Timer that periodically calls IdleHandler. base::RepeatingTimer<RenderThread> idle_timer_; diff --git a/content/browser/speech/speech_input_browsertest.cc b/content/browser/speech/speech_input_browsertest.cc index 8231f3d..e28d5bd 100644 --- a/content/browser/speech/speech_input_browsertest.cc +++ b/content/browser/speech/speech_input_browsertest.cc @@ -98,6 +98,10 @@ class FakeSpeechInputManager : public SpeechInputManager { class SpeechInputBrowserTest : public InProcessBrowserTest { public: // InProcessBrowserTest methods + virtual void SetUpCommandLine(CommandLine* command_line) { + EXPECT_TRUE(!command_line->HasSwitch(switches::kDisableSpeechInput)); + } + GURL testUrl(const FilePath::CharType* filename) { const FilePath kTestDir(FILE_PATH_LITERAL("speech")); return ui_test_utils::GetTestUrl(kTestDir, FilePath(filename)); diff --git a/content/browser/speech/speech_input_dispatcher_host.cc b/content/browser/speech/speech_input_dispatcher_host.cc index 84e2a95..d721fee 100644 --- a/content/browser/speech/speech_input_dispatcher_host.cc +++ b/content/browser/speech/speech_input_dispatcher_host.cc @@ -129,30 +129,18 @@ SpeechInputManager* SpeechInputDispatcherHost::manager() { bool SpeechInputDispatcherHost::OnMessageReceived( const IPC::Message& message, bool* message_was_ok) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - - uint32 message_type = message.type(); - if (message_type == SpeechInputHostMsg_StartRecognition::ID || - message_type == SpeechInputHostMsg_CancelRecognition::ID || - message_type == SpeechInputHostMsg_StopRecording::ID) { - if (!SpeechInputManager::IsFeatureEnabled()) { - *message_was_ok = false; - return true; - } - - may_have_pending_requests_ = true; - IPC_BEGIN_MESSAGE_MAP_EX(SpeechInputDispatcherHost, message, - *message_was_ok) - IPC_MESSAGE_HANDLER(SpeechInputHostMsg_StartRecognition, - OnStartRecognition) - IPC_MESSAGE_HANDLER(SpeechInputHostMsg_CancelRecognition, - OnCancelRecognition) - IPC_MESSAGE_HANDLER(SpeechInputHostMsg_StopRecording, - OnStopRecording) - IPC_END_MESSAGE_MAP() - return true; - } - - return false; + bool handled = true; + IPC_BEGIN_MESSAGE_MAP_EX(SpeechInputDispatcherHost, message, + *message_was_ok) + IPC_MESSAGE_HANDLER(SpeechInputHostMsg_StartRecognition, + OnStartRecognition) + IPC_MESSAGE_HANDLER(SpeechInputHostMsg_CancelRecognition, + OnCancelRecognition) + IPC_MESSAGE_HANDLER(SpeechInputHostMsg_StopRecording, + OnStopRecording) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; } void SpeechInputDispatcherHost::OnStartRecognition( diff --git a/content/browser/speech/speech_input_manager.h b/content/browser/speech/speech_input_manager.h index 951def9..c990e8c 100644 --- a/content/browser/speech/speech_input_manager.h +++ b/content/browser/speech/speech_input_manager.h @@ -31,10 +31,6 @@ class SpeechInputManager { virtual ~Delegate() {} }; - // Whether the speech input feature is enabled, based on the browser channel - // information and command line flags. - static bool IsFeatureEnabled(); - // Invokes the platform provided microphone settings UI in a non-blocking way, // via the BrowserThread::FILE thread. static void ShowAudioInputSettings(); |