diff options
author | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-19 13:37:45 +0000 |
---|---|---|
committer | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-19 13:37:45 +0000 |
commit | 1a9e58fa3e530590ace31beb23482a6b5bd55f23 (patch) | |
tree | d3c2e1202fc7e57ee0824650512d251766e5215e /chrome/browser/speech | |
parent | 650852ed08cdaa188acdae532caf31438ea18358 (diff) | |
download | chromium_src-1a9e58fa3e530590ace31beb23482a6b5bd55f23.zip chromium_src-1a9e58fa3e530590ace31beb23482a6b5bd55f23.tar.gz chromium_src-1a9e58fa3e530590ace31beb23482a6b5bd55f23.tar.bz2 |
Revert http://src.chromium.org/viewvc/chrome?view=rev&revision=70896 to move speech input back behind a flag.
We have more work to do and the feature isn't ready for M10 so moving it back behind a flag.
BUG=61677
TEST=browser_tests --gtest_filter="SpeechInputBrowserTest.*"
Review URL: http://codereview.chromium.org/6353005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71789 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/speech')
-rw-r--r-- | chrome/browser/speech/speech_input_browsertest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/speech/speech_input_dispatcher_host.cc | 35 | ||||
-rw-r--r-- | chrome/browser/speech/speech_input_manager.cc | 21 | ||||
-rw-r--r-- | chrome/browser/speech/speech_input_manager.h | 4 |
4 files changed, 48 insertions, 16 deletions
diff --git a/chrome/browser/speech/speech_input_browsertest.cc b/chrome/browser/speech/speech_input_browsertest.cc index 80e3daf..5563fe9 100644 --- a/chrome/browser/speech/speech_input_browsertest.cc +++ b/chrome/browser/speech/speech_input_browsertest.cc @@ -94,10 +94,6 @@ 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/chrome/browser/speech/speech_input_dispatcher_host.cc b/chrome/browser/speech/speech_input_dispatcher_host.cc index 5e1daab..50b9aec 100644 --- a/chrome/browser/speech/speech_input_dispatcher_host.cc +++ b/chrome/browser/speech/speech_input_dispatcher_host.cc @@ -121,18 +121,29 @@ SpeechInputManager* SpeechInputDispatcherHost::manager() { bool SpeechInputDispatcherHost::OnMessageReceived( const IPC::Message& message, bool* message_was_ok) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - bool handled = true; - IPC_BEGIN_MESSAGE_MAP_EX(SpeechInputDispatcherHost, message, - *message_was_ok) - IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_StartRecognition, - OnStartRecognition) - IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_CancelRecognition, - OnCancelRecognition) - IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_StopRecording, - OnStopRecording) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; + + uint32 message_type = message.type(); + if (message_type == ViewHostMsg_SpeechInput_StartRecognition::ID || + message_type == ViewHostMsg_SpeechInput_CancelRecognition::ID || + message_type == ViewHostMsg_SpeechInput_StopRecording::ID) { + if (!SpeechInputManager::IsFeatureEnabled()) { + *message_was_ok = false; + return true; + } + + IPC_BEGIN_MESSAGE_MAP_EX(SpeechInputDispatcherHost, message, + *message_was_ok) + IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_StartRecognition, + OnStartRecognition) + IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_CancelRecognition, + OnCancelRecognition) + IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_StopRecording, + OnStopRecording) + IPC_END_MESSAGE_MAP() + return true; + } + + return false; } void SpeechInputDispatcherHost::OnStartRecognition( diff --git a/chrome/browser/speech/speech_input_manager.cc b/chrome/browser/speech/speech_input_manager.cc index 284a166..25f0550 100644 --- a/chrome/browser/speech/speech_input_manager.cc +++ b/chrome/browser/speech/speech_input_manager.cc @@ -8,6 +8,7 @@ #include <string> #include "app/l10n_util.h" +#include "base/command_line.h" #include "base/lazy_instance.h" #include "base/lock.h" #include "base/ref_counted.h" @@ -152,6 +153,26 @@ 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; +} + SpeechInputManagerImpl::SpeechInputManagerImpl() : recording_caller_id_(0), bubble_controller_(new SpeechInputBubbleController( diff --git a/chrome/browser/speech/speech_input_manager.h b/chrome/browser/speech/speech_input_manager.h index be9779f..ffeaba0 100644 --- a/chrome/browser/speech/speech_input_manager.h +++ b/chrome/browser/speech/speech_input_manager.h @@ -32,6 +32,10 @@ class SpeechInputManager { virtual ~Delegate() {} }; + // Whether the speech input feature is enabled, based on the browser channel + // information and command line flags. + static bool IsFeatureEnabled(); + // Factory method to access the singleton. We have this method here instead of // using Singleton<> directly in the calling code to aid tests in injection // mocks. |