diff options
author | primiano@chromium.org <primiano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-07 11:01:02 +0000 |
---|---|---|
committer | primiano@chromium.org <primiano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-07 11:01:02 +0000 |
commit | c52b28964090204b87634b396823c3709855079c (patch) | |
tree | 1e8e20c58dd735baa7f8312dc115fff224e4e5cd | |
parent | 9104f7e80f0bd0c2353254ec5c354199d965f44d (diff) | |
download | chromium_src-c52b28964090204b87634b396823c3709855079c.zip chromium_src-c52b28964090204b87634b396823c3709855079c.tar.gz chromium_src-c52b28964090204b87634b396823c3709855079c.tar.bz2 |
Renamed speech recognition code in preparation for introducing a new speech implementation.
- The general-purpose speech recognition classes (that will be needed also by future code) have been renamed to SpeechRecognition*;
- The IPC Messages and dispatcher(host) classes that are only related to the current input tag (x-webkit-speech) support have been renamed to InputTagSpeech*;
- The namespace has been renamed from speech_input to speech;
BUG=116954
TEST=
Review URL: https://chromiumcodereview.appspot.com/9568002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125378 0039d316-1c4b-4281-b951-d872f2087c98
89 files changed, 1243 insertions, 1183 deletions
diff --git a/chrome/app/nibs/SpeechInputBubble.xib b/chrome/app/nibs/SpeechRecognitionBubble.xib index 8999b4f..8cc0dc2 100644 --- a/chrome/app/nibs/SpeechInputBubble.xib +++ b/chrome/app/nibs/SpeechRecognitionBubble.xib @@ -30,7 +30,7 @@ <object class="NSMutableArray" key="IBDocument.RootObjects" id="1048"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSCustomObject" id="1021"> - <string key="NSClassName">SpeechInputWindowController</string> + <string key="NSClassName">SpeechRecognitionWindowController</string> </object> <object class="NSCustomObject" id="1014"> <string key="NSClassName">FirstResponder</string> @@ -674,7 +674,7 @@ </object> </object> <object class="IBPartialClassDescription"> - <string key="className">SpeechInputWindowController</string> + <string key="className">SpeechRecognitionWindowController</string> <string key="superclassName">BaseBubbleController</string> <object class="NSMutableDictionary" key="actions"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -716,7 +716,7 @@ </object> </object> <object class="IBPartialClassDescription"> - <string key="className">SpeechInputWindowController</string> + <string key="className">SpeechRecognitionWindowController</string> <string key="superclassName">BaseBubbleController</string> <object class="NSMutableDictionary" key="outlets"> <string key="NS.key.0">myOutlet1</string> diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 6697d68..901f43e 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -53,7 +53,7 @@ #include "chrome/browser/renderer_host/chrome_render_view_host_observer.h" #include "chrome/browser/renderer_host/plugin_info_message_filter.h" #include "chrome/browser/search_engines/search_provider_install_state_message_filter.h" -#include "chrome/browser/speech/chrome_speech_input_manager_delegate.h" +#include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h" #include "chrome/browser/spellchecker/spellcheck_message_filter.h" #include "chrome/browser/ssl/ssl_add_cert_handler.h" #include "chrome/browser/ssl/ssl_blocking_page.h" @@ -1275,9 +1275,9 @@ void ChromeContentBrowserClient::ResourceDispatcherHostCreated() { return g_browser_process->ResourceDispatcherHostCreated(); } -content::SpeechInputManagerDelegate* - ChromeContentBrowserClient::GetSpeechInputManagerDelegate() { - return new speech_input::ChromeSpeechInputManagerDelegate(); +content::SpeechRecognitionManagerDelegate* + ChromeContentBrowserClient::GetSpeechRecognitionManagerDelegate() { + return new speech::ChromeSpeechRecognitionManagerDelegate(); } ui::Clipboard* ChromeContentBrowserClient::GetClipboard() { diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h index 12553d3..a38b6bb 100644 --- a/chrome/browser/chrome_content_browser_client.h +++ b/chrome/browser/chrome_content_browser_client.h @@ -144,8 +144,8 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient { virtual std::string GetWorkerProcessTitle( const GURL& url, content::ResourceContext* context) OVERRIDE; virtual void ResourceDispatcherHostCreated() OVERRIDE; - virtual content::SpeechInputManagerDelegate* - GetSpeechInputManagerDelegate() OVERRIDE; + virtual content::SpeechRecognitionManagerDelegate* + GetSpeechRecognitionManagerDelegate() OVERRIDE; virtual ui::Clipboard* GetClipboard() OVERRIDE; virtual net::NetLog* GetNetLog() OVERRIDE; virtual content::AccessTokenStore* CreateAccessTokenStore() OVERRIDE; diff --git a/chrome/browser/profiles/off_the_record_profile_impl.cc b/chrome/browser/profiles/off_the_record_profile_impl.cc index 480eb1b..5323f90 100644 --- a/chrome/browser/profiles/off_the_record_profile_impl.cc +++ b/chrome/browser/profiles/off_the_record_profile_impl.cc @@ -362,9 +362,9 @@ content::GeolocationPermissionContext* return profile_->GetGeolocationPermissionContext(); } -content::SpeechInputPreferences* - OffTheRecordProfileImpl::GetSpeechInputPreferences() { - return profile_->GetSpeechInputPreferences(); +content::SpeechRecognitionPreferences* + OffTheRecordProfileImpl::GetSpeechRecognitionPreferences() { + return profile_->GetSpeechRecognitionPreferences(); } UserStyleSheetWatcher* OffTheRecordProfileImpl::GetUserStyleSheetWatcher() { diff --git a/chrome/browser/profiles/off_the_record_profile_impl.h b/chrome/browser/profiles/off_the_record_profile_impl.h index 1a65d56..cd7a9a2 100644 --- a/chrome/browser/profiles/off_the_record_profile_impl.h +++ b/chrome/browser/profiles/off_the_record_profile_impl.h @@ -116,7 +116,8 @@ class OffTheRecordProfileImpl : public Profile, virtual content::ResourceContext* GetResourceContext() OVERRIDE; virtual content::GeolocationPermissionContext* GetGeolocationPermissionContext() OVERRIDE; - virtual content::SpeechInputPreferences* GetSpeechInputPreferences() OVERRIDE; + virtual content::SpeechRecognitionPreferences* + GetSpeechRecognitionPreferences() OVERRIDE; virtual bool DidLastSessionExitCleanly() OVERRIDE; virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc index fffeb89..eea0472 100644 --- a/chrome/browser/profiles/profile.cc +++ b/chrome/browser/profiles/profile.cc @@ -96,10 +96,10 @@ void Profile::RegisterUserPrefs(PrefService* prefs) { prefs->RegisterBooleanPref(prefs::kSafeBrowsingReportingEnabled, false, PrefService::UNSYNCABLE_PREF); - // TODO(erg): kSpeechInputFilterProfanities should also be moved to + // TODO(erg): kSpeechRecognitionFilterProfanities should also be moved to // speech_input_extension_manager.cc, but is more involved because of // BrowserContext/Profile confusion because of ChromeSpeechInputPreferences. - prefs->RegisterBooleanPref(prefs::kSpeechInputFilterProfanities, + prefs->RegisterBooleanPref(prefs::kSpeechRecognitionFilterProfanities, true, PrefService::UNSYNCABLE_PREF); prefs->RegisterBooleanPref(prefs::kDisableExtensions, diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h index 7407853..845e27f 100644 --- a/chrome/browser/profiles/profile.h +++ b/chrome/browser/profiles/profile.h @@ -60,7 +60,7 @@ class Predictor; } namespace content { -class SpeechInputPreferences; +class SpeechRecognitionPreferences; class WebUI; } diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc index 9500473c..307344a 100644 --- a/chrome/browser/profiles/profile_impl.cc +++ b/chrome/browser/profiles/profile_impl.cc @@ -71,7 +71,7 @@ #include "chrome/browser/search_engines/template_url_service.h" #include "chrome/browser/sessions/session_service_factory.h" #include "chrome/browser/signin/token_service.h" -#include "chrome/browser/speech/chrome_speech_input_preferences.h" +#include "chrome/browser/speech/chrome_speech_recognition_preferences.h" #include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/transport_security_persister.h" #include "chrome/browser/ui/browser_init.h" @@ -283,7 +283,7 @@ ProfileImpl::ProfileImpl(const FilePath& path, void ProfileImpl::DoFinalInit() { PrefService* prefs = GetPrefs(); pref_change_registrar_.Init(prefs); - pref_change_registrar_.Add(prefs::kSpeechInputFilterProfanities, this); + pref_change_registrar_.Add(prefs::kSpeechRecognitionFilterProfanities, this); pref_change_registrar_.Add(prefs::kClearSiteDataOnExit, this); pref_change_registrar_.Add(prefs::kGoogleServicesUsername, this); pref_change_registrar_.Add(prefs::kDefaultZoomLevel, this); @@ -891,12 +891,14 @@ content::GeolocationPermissionContext* return geolocation_permission_context_.get(); } -content::SpeechInputPreferences* ProfileImpl::GetSpeechInputPreferences() { +content::SpeechRecognitionPreferences* + ProfileImpl::GetSpeechRecognitionPreferences() { #if defined(ENABLE_INPUT_SPEECH) - if (!speech_input_preferences_.get()) { - speech_input_preferences_ = new ChromeSpeechInputPreferences(GetPrefs()); + if (!speech_recognition_preferences_.get()) { + speech_recognition_preferences_ = + new ChromeSpeechRecognitionPreferences(GetPrefs()); } - return speech_input_preferences_.get(); + return speech_recognition_preferences_.get(); #else return NULL; #endif @@ -1184,12 +1186,12 @@ void ProfileImpl::Observe(int type, std::string* pref_name_in = content::Details<std::string>(details).ptr(); PrefService* prefs = content::Source<PrefService>(source).ptr(); DCHECK(pref_name_in && prefs); - if (*pref_name_in == prefs::kSpeechInputFilterProfanities) { - content::SpeechInputPreferences* speech_prefs = - GetSpeechInputPreferences(); + if (*pref_name_in == prefs::kSpeechRecognitionFilterProfanities) { + content::SpeechRecognitionPreferences* speech_prefs = + GetSpeechRecognitionPreferences(); if (speech_prefs) { speech_prefs->SetFilterProfanities(prefs->GetBoolean( - prefs::kSpeechInputFilterProfanities)); + prefs::kSpeechRecognitionFilterProfanities)); } } else if (*pref_name_in == prefs::kClearSiteDataOnExit) { clear_local_state_on_exit_ = diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h index a7b9b6f..816e112 100644 --- a/chrome/browser/profiles/profile_impl.h +++ b/chrome/browser/profiles/profile_impl.h @@ -39,7 +39,7 @@ class Preferences; #endif namespace content { -class SpeechInputPreferences; +class SpeechRecognitionPreferences; } // The default profile implementation. @@ -60,7 +60,8 @@ class ProfileImpl : public Profile, virtual content::ResourceContext* GetResourceContext() OVERRIDE; virtual content::GeolocationPermissionContext* GetGeolocationPermissionContext() OVERRIDE; - virtual content::SpeechInputPreferences* GetSpeechInputPreferences() OVERRIDE; + virtual content::SpeechRecognitionPreferences* + GetSpeechRecognitionPreferences() OVERRIDE; virtual bool DidLastSessionExitCleanly() OVERRIDE; virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; @@ -236,7 +237,8 @@ class ProfileImpl : public Profile, scoped_refptr<HostContentSettingsMap> host_content_settings_map_; scoped_refptr<content::GeolocationPermissionContext> geolocation_permission_context_; - scoped_refptr<content::SpeechInputPreferences> speech_input_preferences_; + scoped_refptr<content::SpeechRecognitionPreferences> + speech_recognition_preferences_; scoped_refptr<UserStyleSheetWatcher> user_style_sheet_watcher_; scoped_ptr<GAIAInfoUpdateService> gaia_info_update_service_; scoped_refptr<HistoryService> history_service_; diff --git a/chrome/browser/speech/chrome_speech_input_manager_delegate.h b/chrome/browser/speech/chrome_speech_input_manager_delegate.h deleted file mode 100644 index d133a51..0000000 --- a/chrome/browser/speech/chrome_speech_input_manager_delegate.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_SPEECH_CHROME_SPEECH_INPUT_MANAGER_DELEGATE_H_ -#define CHROME_BROWSER_SPEECH_CHROME_SPEECH_INPUT_MANAGER_DELEGATE_H_ - -#include "base/compiler_specific.h" -#include "base/memory/ref_counted.h" -#include "chrome/browser/speech/speech_input_bubble_controller.h" -#include "content/public/browser/speech_input_manager_delegate.h" - -namespace speech_input { - -// This is Chrome's implementation of the SpeechInputManager interface. This -// class is a singleton and accessed via the Get method. -class ChromeSpeechInputManagerDelegate - : NON_EXPORTED_BASE(public content::SpeechInputManagerDelegate), - public SpeechInputBubbleControllerDelegate { - public: - ChromeSpeechInputManagerDelegate(); - virtual ~ChromeSpeechInputManagerDelegate(); - - // SpeechInputBubbleControllerDelegate methods. - virtual void InfoBubbleButtonClicked( - int caller_id, SpeechInputBubble::Button button) OVERRIDE; - virtual void InfoBubbleFocusChanged(int caller_id) OVERRIDE; - - protected: - // SpeechInputManagerDelegate methods. - virtual void GetRequestInfo(bool* can_report_metrics, - std::string* request_info) OVERRIDE; - virtual void ShowRecognitionRequested(int caller_id, - int render_process_id, - int render_view_id, - const gfx::Rect& element_rect) OVERRIDE; - virtual void ShowWarmUp(int caller_id) OVERRIDE; - virtual void ShowRecognizing(int caller_id) OVERRIDE; - virtual void ShowRecording(int caller_id) OVERRIDE; - virtual void ShowInputVolume(int caller_id, - float volume, - float noise_volume) OVERRIDE; - virtual void ShowMicError(int caller_id, - MicError error) OVERRIDE; - virtual void ShowRecognizerError(int caller_id, - content::SpeechInputError error) OVERRIDE; - virtual void DoClose(int caller_id) OVERRIDE; - - private: - class OptionalRequestInfo; - - scoped_refptr<SpeechInputBubbleController> bubble_controller_; - scoped_refptr<OptionalRequestInfo> optional_request_info_; - - DISALLOW_COPY_AND_ASSIGN(ChromeSpeechInputManagerDelegate); -}; - -} // namespace speech_input - -#endif // CHROME_BROWSER_SPEECH_CHROME_SPEECH_INPUT_MANAGER_DELEGATE_H_ diff --git a/chrome/browser/speech/chrome_speech_input_preferences.h b/chrome/browser/speech/chrome_speech_input_preferences.h deleted file mode 100644 index b253e31..0000000 --- a/chrome/browser/speech/chrome_speech_input_preferences.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_SPEECH_CHROME_SPEECH_INPUT_PREFERENCES_H_ -#define CHROME_BROWSER_SPEECH_CHROME_SPEECH_INPUT_PREFERENCES_H_ -#pragma once - -#include "base/basictypes.h" -#include "content/public/browser/speech_input_preferences.h" - -class PrefService; - -class ChromeSpeechInputPreferences : public content::SpeechInputPreferences { - public: - explicit ChromeSpeechInputPreferences(PrefService* pref_service); - - // Overridden from content::SpeechInputPreferences: - virtual bool FilterProfanities() const OVERRIDE; - virtual void SetFilterProfanities(bool filter_profanities) OVERRIDE; - - private: - virtual ~ChromeSpeechInputPreferences(); - - // Only to be accessed and modified on the IO thread. - bool filter_profanities_; - - DISALLOW_COPY_AND_ASSIGN(ChromeSpeechInputPreferences); -}; - -#endif // CHROME_BROWSER_SPEECH_CHROME_SPEECH_INPUT_PREFERENCES_H_ diff --git a/chrome/browser/speech/chrome_speech_input_manager_delegate.cc b/chrome/browser/speech/chrome_speech_recognition_manager_delegate.cc index 48a95da..bdf5f58 100644 --- a/chrome/browser/speech/chrome_speech_input_manager_delegate.cc +++ b/chrome/browser/speech/chrome_speech_recognition_manager_delegate.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/speech/chrome_speech_input_manager_delegate.h" +#include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h" #include <string> @@ -17,8 +17,8 @@ #include "chrome/common/pref_names.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/resource_context.h" -#include "content/public/browser/speech_input_manager.h" -#include "content/public/common/speech_input_result.h" +#include "content/public/browser/speech_recognition_manager.h" +#include "content/public/common/speech_recognition_result.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -27,15 +27,15 @@ #endif using content::BrowserThread; -using content::SpeechInputManager; +using content::SpeechRecognitionManager; -namespace speech_input { +namespace speech { // Asynchronously fetches the PC and audio hardware/driver info if // the user has opted into UMA. This information is sent with speech input // requests to the server for identifying and improving quality issues with // specific device configurations. -class ChromeSpeechInputManagerDelegate::OptionalRequestInfo +class ChromeSpeechRecognitionManagerDelegate::OptionalRequestInfo : public base::RefCountedThreadSafe<OptionalRequestInfo> { public: OptionalRequestInfo() : can_report_metrics_(false) { @@ -63,7 +63,7 @@ class ChromeSpeechInputManagerDelegate::OptionalRequestInfo base::AutoLock lock(lock_); can_report_metrics_ = true; string16 device_model = - SpeechInputManager::GetInstance()->GetAudioInputDeviceModel(); + SpeechRecognitionManager::GetInstance()->GetAudioInputDeviceModel(); #if defined(OS_WIN) value_ = UTF16ToUTF8( installer::WMIComputerSystem::GetModel() + L"|" + device_model); @@ -94,15 +94,16 @@ class ChromeSpeechInputManagerDelegate::OptionalRequestInfo DISALLOW_COPY_AND_ASSIGN(OptionalRequestInfo); }; -ChromeSpeechInputManagerDelegate::ChromeSpeechInputManagerDelegate() - : bubble_controller_(new SpeechInputBubbleController( +ChromeSpeechRecognitionManagerDelegate::ChromeSpeechRecognitionManagerDelegate() + : bubble_controller_(new SpeechRecognitionBubbleController( ALLOW_THIS_IN_INITIALIZER_LIST(this))) { } -ChromeSpeechInputManagerDelegate::~ChromeSpeechInputManagerDelegate() { +ChromeSpeechRecognitionManagerDelegate:: + ~ChromeSpeechRecognitionManagerDelegate() { } -void ChromeSpeechInputManagerDelegate::ShowRecognitionRequested( +void ChromeSpeechRecognitionManagerDelegate::ShowRecognitionRequested( int caller_id, int render_process_id, int render_view_id, @@ -111,7 +112,7 @@ void ChromeSpeechInputManagerDelegate::ShowRecognitionRequested( render_view_id, element_rect); } -void ChromeSpeechInputManagerDelegate::GetRequestInfo( +void ChromeSpeechRecognitionManagerDelegate::GetRequestInfo( bool* can_report_metrics, std::string* request_info) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); @@ -130,24 +131,24 @@ void ChromeSpeechInputManagerDelegate::GetRequestInfo( *request_info = optional_request_info_->value(); } -void ChromeSpeechInputManagerDelegate::ShowWarmUp(int caller_id) { +void ChromeSpeechRecognitionManagerDelegate::ShowWarmUp(int caller_id) { bubble_controller_->SetBubbleWarmUpMode(caller_id); } -void ChromeSpeechInputManagerDelegate::ShowRecognizing(int caller_id) { +void ChromeSpeechRecognitionManagerDelegate::ShowRecognizing(int caller_id) { bubble_controller_->SetBubbleRecognizingMode(caller_id); } -void ChromeSpeechInputManagerDelegate::ShowRecording(int caller_id) { +void ChromeSpeechRecognitionManagerDelegate::ShowRecording(int caller_id) { bubble_controller_->SetBubbleRecordingMode(caller_id); } -void ChromeSpeechInputManagerDelegate::ShowInputVolume( +void ChromeSpeechRecognitionManagerDelegate::ShowInputVolume( int caller_id, float volume, float noise_volume) { bubble_controller_->SetBubbleInputVolume(caller_id, volume, noise_volume); } -void ChromeSpeechInputManagerDelegate::ShowMicError(int caller_id, +void ChromeSpeechRecognitionManagerDelegate::ShowMicError(int caller_id, MicError error) { switch (error) { case MIC_ERROR_NO_DEVICE_AVAILABLE: @@ -165,21 +166,21 @@ void ChromeSpeechInputManagerDelegate::ShowMicError(int caller_id, } } -void ChromeSpeechInputManagerDelegate::ShowRecognizerError( - int caller_id, content::SpeechInputError error) { +void ChromeSpeechRecognitionManagerDelegate::ShowRecognizerError( + int caller_id, content::SpeechRecognitionErrorCode error) { struct ErrorMessageMapEntry { - content::SpeechInputError error; + content::SpeechRecognitionErrorCode error; int message_id; }; ErrorMessageMapEntry error_message_map[] = { { - content::SPEECH_INPUT_ERROR_AUDIO, IDS_SPEECH_INPUT_MIC_ERROR + content::SPEECH_RECOGNITION_ERROR_AUDIO, IDS_SPEECH_INPUT_MIC_ERROR }, { - content::SPEECH_INPUT_ERROR_NO_SPEECH, IDS_SPEECH_INPUT_NO_SPEECH + content::SPEECH_RECOGNITION_ERROR_NO_SPEECH, IDS_SPEECH_INPUT_NO_SPEECH }, { - content::SPEECH_INPUT_ERROR_NO_MATCH, IDS_SPEECH_INPUT_NO_RESULTS + content::SPEECH_RECOGNITION_ERROR_NO_MATCH, IDS_SPEECH_INPUT_NO_RESULTS }, { - content::SPEECH_INPUT_ERROR_NETWORK, IDS_SPEECH_INPUT_NET_ERROR + content::SPEECH_RECOGNITION_ERROR_NETWORK, IDS_SPEECH_INPUT_NET_ERROR } }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(error_message_map); ++i) { @@ -194,25 +195,27 @@ void ChromeSpeechInputManagerDelegate::ShowRecognizerError( NOTREACHED() << "unknown error " << error; } -void ChromeSpeechInputManagerDelegate::DoClose(int caller_id) { +void ChromeSpeechRecognitionManagerDelegate::DoClose(int caller_id) { bubble_controller_->CloseBubble(caller_id); } -void ChromeSpeechInputManagerDelegate::InfoBubbleButtonClicked( - int caller_id, SpeechInputBubble::Button button) { +void ChromeSpeechRecognitionManagerDelegate::InfoBubbleButtonClicked( + int caller_id, SpeechRecognitionBubble::Button button) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (button == SpeechInputBubble::BUTTON_CANCEL) { - SpeechInputManager::GetInstance()->CancelRecognitionForRequest(caller_id); - } else if (button == SpeechInputBubble::BUTTON_TRY_AGAIN) { - SpeechInputManager::GetInstance()->StartRecognitionForRequest(caller_id); + if (button == SpeechRecognitionBubble::BUTTON_CANCEL) { + SpeechRecognitionManager::GetInstance()->CancelRecognitionForRequest( + caller_id); + } else if (button == SpeechRecognitionBubble::BUTTON_TRY_AGAIN) { + SpeechRecognitionManager::GetInstance()->StartRecognitionForRequest( + caller_id); } } -void ChromeSpeechInputManagerDelegate::InfoBubbleFocusChanged(int caller_id) { +void ChromeSpeechRecognitionManagerDelegate::InfoBubbleFocusChanged( + int caller_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - - SpeechInputManager::GetInstance()->FocusLostForRequest(caller_id); + SpeechRecognitionManager::GetInstance()->FocusLostForRequest(caller_id); } -} // namespace speech_input +} // namespace speech diff --git a/chrome/browser/speech/chrome_speech_recognition_manager_delegate.h b/chrome/browser/speech/chrome_speech_recognition_manager_delegate.h new file mode 100644 index 0000000..cf4e7db --- /dev/null +++ b/chrome/browser/speech/chrome_speech_recognition_manager_delegate.h @@ -0,0 +1,60 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_ +#define CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_ + +#include "base/compiler_specific.h" +#include "base/memory/ref_counted.h" +#include "chrome/browser/speech/speech_recognition_bubble_controller.h" +#include "content/public/browser/speech_recognition_manager_delegate.h" + +namespace speech { + +// This is Chrome's implementation of the SpeechRecognitionManager interface. +// This class is a singleton and accessed via the Get method. +class ChromeSpeechRecognitionManagerDelegate + : NON_EXPORTED_BASE(public content::SpeechRecognitionManagerDelegate), + public SpeechRecognitionBubbleControllerDelegate { + public: + ChromeSpeechRecognitionManagerDelegate(); + virtual ~ChromeSpeechRecognitionManagerDelegate(); + + // SpeechRecognitionBubbleControllerDelegate methods. + virtual void InfoBubbleButtonClicked( + int caller_id, SpeechRecognitionBubble::Button button) OVERRIDE; + virtual void InfoBubbleFocusChanged(int caller_id) OVERRIDE; + + protected: + // SpeechRecognitionManagerDelegate methods. + virtual void GetRequestInfo(bool* can_report_metrics, + std::string* request_info) OVERRIDE; + virtual void ShowRecognitionRequested(int caller_id, + int render_process_id, + int render_view_id, + const gfx::Rect& element_rect) OVERRIDE; + virtual void ShowWarmUp(int caller_id) OVERRIDE; + virtual void ShowRecognizing(int caller_id) OVERRIDE; + virtual void ShowRecording(int caller_id) OVERRIDE; + virtual void ShowInputVolume(int caller_id, + float volume, + float noise_volume) OVERRIDE; + virtual void ShowMicError(int caller_id, + MicError error) OVERRIDE; + virtual void ShowRecognizerError( + int caller_id, content::SpeechRecognitionErrorCode error) OVERRIDE; + virtual void DoClose(int caller_id) OVERRIDE; + + private: + class OptionalRequestInfo; + + scoped_refptr<SpeechRecognitionBubbleController> bubble_controller_; + scoped_refptr<OptionalRequestInfo> optional_request_info_; + + DISALLOW_COPY_AND_ASSIGN(ChromeSpeechRecognitionManagerDelegate); +}; + +} // namespace speech + +#endif // CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_ diff --git a/chrome/browser/speech/chrome_speech_input_preferences.cc b/chrome/browser/speech/chrome_speech_recognition_preferences.cc index bce8ee6..04a20d9 100644 --- a/chrome/browser/speech/chrome_speech_input_preferences.cc +++ b/chrome/browser/speech/chrome_speech_recognition_preferences.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/speech/chrome_speech_input_preferences.h" +#include "chrome/browser/speech/chrome_speech_recognition_preferences.h" #include "base/bind.h" #include "chrome/browser/prefs/pref_service.h" @@ -11,26 +11,26 @@ using content::BrowserThread; -ChromeSpeechInputPreferences::ChromeSpeechInputPreferences( +ChromeSpeechRecognitionPreferences::ChromeSpeechRecognitionPreferences( PrefService* pref_service) : filter_profanities_( - pref_service->GetBoolean(prefs::kSpeechInputFilterProfanities)) { + pref_service->GetBoolean(prefs::kSpeechRecognitionFilterProfanities)){ } -ChromeSpeechInputPreferences::~ChromeSpeechInputPreferences() { +ChromeSpeechRecognitionPreferences::~ChromeSpeechRecognitionPreferences() { } -bool ChromeSpeechInputPreferences::FilterProfanities() const { +bool ChromeSpeechRecognitionPreferences::FilterProfanities() const { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); return filter_profanities_; } -void ChromeSpeechInputPreferences::SetFilterProfanities( +void ChromeSpeechRecognitionPreferences::SetFilterProfanities( bool filter_profanities) { if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind(&ChromeSpeechInputPreferences::SetFilterProfanities, + base::Bind(&ChromeSpeechRecognitionPreferences::SetFilterProfanities, this, filter_profanities)); return; } diff --git a/chrome/browser/speech/chrome_speech_recognition_preferences.h b/chrome/browser/speech/chrome_speech_recognition_preferences.h new file mode 100644 index 0000000..0a6310e1 --- /dev/null +++ b/chrome/browser/speech/chrome_speech_recognition_preferences.h @@ -0,0 +1,32 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_PREFERENCES_H_ +#define CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_PREFERENCES_H_ +#pragma once + +#include "base/basictypes.h" +#include "content/public/browser/speech_recognition_preferences.h" + +class PrefService; + +class ChromeSpeechRecognitionPreferences + : public content::SpeechRecognitionPreferences { + public: + explicit ChromeSpeechRecognitionPreferences(PrefService* pref_service); + + // Overridden from content::SpeechRecognitionPreferences: + virtual bool FilterProfanities() const OVERRIDE; + virtual void SetFilterProfanities(bool filter_profanities) OVERRIDE; + + private: + virtual ~ChromeSpeechRecognitionPreferences(); + + // Only to be accessed and modified on the IO thread. + bool filter_profanities_; + + DISALLOW_COPY_AND_ASSIGN(ChromeSpeechRecognitionPreferences); +}; + +#endif // CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_PREFERENCES_H_ diff --git a/chrome/browser/speech/speech_input_extension_apitest.cc b/chrome/browser/speech/speech_input_extension_apitest.cc index 6d3c489..905ac33 100644 --- a/chrome/browser/speech/speech_input_extension_apitest.cc +++ b/chrome/browser/speech/speech_input_extension_apitest.cc @@ -13,7 +13,7 @@ #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_switches.h" #include "content/public/browser/speech_recognizer_delegate.h" -#include "content/public/common/speech_input_result.h" +#include "content/public/common/speech_recognition_result.h" #include "testing/gtest/include/gtest/gtest.h" using content::BrowserThread; @@ -33,11 +33,11 @@ class SpeechInputExtensionApiTest : public ExtensionApiTest, recording_devices_available_ = available; } - void SetRecognitionError(content::SpeechInputError error) { + void SetRecognitionError(content::SpeechRecognitionErrorCode error) { next_error_ = error; } - void SetRecognitionResult(const content::SpeechInputResult& result) { + void SetRecognitionResult(const content::SpeechRecognitionResult& result) { next_result_ = result; } @@ -59,7 +59,7 @@ class SpeechInputExtensionApiTest : public ExtensionApiTest, return recording_devices_available_; } - virtual bool IsRecordingInProcess() OVERRIDE { + virtual bool IsCapturingAudio() OVERRIDE { // Only the mock recognizer is supposed to be recording during testing. return HasValidRecognizer(); } @@ -105,15 +105,15 @@ class SpeechInputExtensionApiTest : public ExtensionApiTest, bool recording_devices_available_; bool recognizer_is_valid_; - content::SpeechInputError next_error_; - content::SpeechInputResult next_result_; + content::SpeechRecognitionErrorCode next_error_; + content::SpeechRecognitionResult next_result_; int result_delay_ms_; }; SpeechInputExtensionApiTest::SpeechInputExtensionApiTest() : recording_devices_available_(true), recognizer_is_valid_(false), - next_error_(content::SPEECH_INPUT_ERROR_NONE), + next_error_(content::SPEECH_RECOGNITION_ERROR_NONE), result_delay_ms_(0) { } @@ -165,7 +165,7 @@ void SpeechInputExtensionApiTest::StopRecording(bool recognition_failed) { void SpeechInputExtensionApiTest::ProvideResults(int caller_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (next_error_ != content::SPEECH_INPUT_ERROR_NONE) { + if (next_error_ != content::SPEECH_RECOGNITION_ERROR_NONE) { GetManager()->OnRecognizerError(caller_id, next_error_); return; } @@ -192,9 +192,10 @@ IN_PROC_BROWSER_TEST_F(SpeechInputExtensionApiTest, NoDevicesAvailable) { IN_PROC_BROWSER_TEST_F(SpeechInputExtensionApiTest, RecognitionSuccessful) { AutoManagerHook hook(this); - content::SpeechInputResult result; + content::SpeechRecognitionResult result; result.hypotheses.push_back( - content::SpeechInputHypothesis(UTF8ToUTF16("this is a test"), 0.99)); + content::SpeechRecognitionHypothesis( + UTF8ToUTF16("this is a test"), 0.99)); SetRecognitionResult(result); ASSERT_TRUE(RunExtensionTest("speech_input/recognition")) << message_; } @@ -202,6 +203,6 @@ IN_PROC_BROWSER_TEST_F(SpeechInputExtensionApiTest, RecognitionSuccessful) { IN_PROC_BROWSER_TEST_F(SpeechInputExtensionApiTest, RecognitionError) { AutoManagerHook hook(this); - SetRecognitionError(content::SPEECH_INPUT_ERROR_NETWORK); + SetRecognitionError(content::SPEECH_RECOGNITION_ERROR_NETWORK); ASSERT_TRUE(RunExtensionTest("speech_input/recognition_error")) << message_; } diff --git a/chrome/browser/speech/speech_input_extension_manager.cc b/chrome/browser/speech/speech_input_extension_manager.cc index 86ebae27..cbaf7ed 100644 --- a/chrome/browser/speech/speech_input_extension_manager.cc +++ b/chrome/browser/speech/speech_input_extension_manager.cc @@ -22,12 +22,13 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_service.h" -#include "content/public/browser/speech_input_manager.h" +#include "content/public/browser/speech_recognition_manager.h" #include "content/public/browser/speech_recognizer.h" -#include "content/public/common/speech_input_result.h" +#include "content/public/common/speech_recognition_result.h" using content::BrowserThread; -using content::SpeechInputManager; +using content::SpeechRecognitionHypothesis; +using content::SpeechRecognitionManager; namespace { @@ -238,7 +239,7 @@ void SpeechInputExtensionManager::ResetToIdleState() { void SpeechInputExtensionManager::SetRecognitionResult( int caller_id, - const content::SpeechInputResult& result) { + const content::SpeechRecognitionResult& result) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK_EQ(caller_id, kSpeechCallerId); @@ -253,7 +254,7 @@ void SpeechInputExtensionManager::SetRecognitionResult( } void SpeechInputExtensionManager::SetRecognitionResultOnUIThread( - const content::SpeechInputResult& result, + const content::SpeechRecognitionResult& result, const std::string& extension_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -265,7 +266,7 @@ void SpeechInputExtensionManager::SetRecognitionResultOnUIThread( js_event->Set(kHypothesesKey, js_hypothesis_array); for (size_t i = 0; i < result.hypotheses.size(); ++i) { - const content::SpeechInputHypothesis& hypothesis = result.hypotheses[i]; + const SpeechRecognitionHypothesis& hypothesis = result.hypotheses[i]; DictionaryValue* js_hypothesis_object = new DictionaryValue(); js_hypothesis_array->Append(js_hypothesis_object); @@ -335,7 +336,7 @@ void SpeechInputExtensionManager::DidStartReceivingAudioOnUIThread() { } void SpeechInputExtensionManager::OnRecognizerError( - int caller_id, content::SpeechInputError error) { + int caller_id, content::SpeechRecognitionErrorCode error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK_EQ(caller_id, kSpeechCallerId); VLOG(1) << "OnRecognizerError: " << error; @@ -351,10 +352,10 @@ void SpeechInputExtensionManager::OnRecognizerError( bool report_to_event = true; switch (error) { - case content::SPEECH_INPUT_ERROR_NONE: + case content::SPEECH_RECOGNITION_ERROR_NONE: break; - case content::SPEECH_INPUT_ERROR_AUDIO: + case content::SPEECH_RECOGNITION_ERROR_AUDIO: if (state_ == kStarting) { event_error_code = kErrorUnableToStart; report_to_event = false; @@ -363,22 +364,22 @@ void SpeechInputExtensionManager::OnRecognizerError( } break; - case content::SPEECH_INPUT_ERROR_NETWORK: + case content::SPEECH_RECOGNITION_ERROR_NETWORK: event_error_code = kErrorNetworkError; break; - case content::SPEECH_INPUT_ERROR_BAD_GRAMMAR: + case content::SPEECH_RECOGNITION_ERROR_BAD_GRAMMAR: // No error is returned on invalid language, for example. // To avoid confusion about when this is would be fired, the invalid // params error is not being exposed to the onError event. event_error_code = kErrorUnableToStart; break; - case content::SPEECH_INPUT_ERROR_NO_SPEECH: + case content::SPEECH_RECOGNITION_ERROR_NO_SPEECH: event_error_code = kErrorNoSpeechHeard; break; - case content::SPEECH_INPUT_ERROR_NO_MATCH: + case content::SPEECH_RECOGNITION_ERROR_NO_MATCH: event_error_code = kErrorNoResults; break; @@ -551,7 +552,7 @@ void SpeechInputExtensionManager::StartOnIOThread( return; } - if (GetSpeechInputExtensionInterface()->IsRecordingInProcess()) { + if (GetSpeechInputExtensionInterface()->IsCapturingAudio()) { BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(&SpeechInputExtensionManager::DispatchError, this, std::string(kErrorRecordingDeviceInUse), false)); @@ -565,12 +566,12 @@ void SpeechInputExtensionManager::StartOnIOThread( bool SpeechInputExtensionManager::HasAudioInputDevices() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - return SpeechInputManager::GetInstance()->HasAudioInputDevices(); + return SpeechRecognitionManager::GetInstance()->HasAudioInputDevices(); } -bool SpeechInputExtensionManager::IsRecordingInProcess() { +bool SpeechInputExtensionManager::IsCapturingAudio() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - return SpeechInputManager::GetInstance()->IsRecordingInProcess(); + return SpeechRecognitionManager::GetInstance()->IsCapturingAudio(); } void SpeechInputExtensionManager::IsRecording( @@ -586,7 +587,7 @@ void SpeechInputExtensionManager::IsRecordingOnIOThread( const IsRecordingCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - bool result = GetSpeechInputExtensionInterface()->IsRecordingInProcess(); + bool result = GetSpeechInputExtensionInterface()->IsCapturingAudio(); BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, base::Bind(&SpeechInputExtensionManager::IsRecordingOnUIThread, diff --git a/chrome/browser/speech/speech_input_extension_manager.h b/chrome/browser/speech/speech_input_extension_manager.h index a6f3b14..aaf612d 100644 --- a/chrome/browser/speech/speech_input_extension_manager.h +++ b/chrome/browser/speech/speech_input_extension_manager.h @@ -45,7 +45,7 @@ class SpeechInputExtensionInterface { virtual void StopRecording(bool recognition_failed) = 0; virtual bool HasAudioInputDevices() = 0; - virtual bool IsRecordingInProcess() = 0; + virtual bool IsCapturingAudio() = 0; // Called from the UI thread. virtual bool HasValidRecognizer() = 0; @@ -117,7 +117,7 @@ class SpeechInputExtensionManager // Methods from SpeechRecognizerDelegate. virtual void SetRecognitionResult( int caller_id, - const content::SpeechInputResult& result) OVERRIDE; + const content::SpeechRecognitionResult& result) OVERRIDE; virtual void DidStartReceivingAudio(int caller_id) OVERRIDE; virtual void DidCompleteRecording(int caller_id) OVERRIDE; @@ -125,7 +125,7 @@ class SpeechInputExtensionManager virtual void DidStartReceivingSpeech(int caller_id) OVERRIDE; virtual void DidStopReceivingSpeech(int caller_id) OVERRIDE; virtual void OnRecognizerError(int caller_id, - content::SpeechInputError error) + content::SpeechRecognitionErrorCode error) OVERRIDE; virtual void DidCompleteEnvironmentEstimation(int caller_id) OVERRIDE; virtual void SetInputVolume(int caller_id, float volume, @@ -138,7 +138,7 @@ class SpeechInputExtensionManager private: // SpeechInputExtensionInterface methods: - virtual bool IsRecordingInProcess() OVERRIDE; + virtual bool IsCapturingAudio() OVERRIDE; virtual bool HasAudioInputDevices() OVERRIDE; virtual bool HasValidRecognizer() OVERRIDE; virtual void StartRecording( @@ -161,7 +161,7 @@ class SpeechInputExtensionManager void IsRecordingOnIOThread(const IsRecordingCallback& callback); void SetRecognitionResultOnUIThread( - const content::SpeechInputResult& result, + const content::SpeechRecognitionResult& result, const std::string& extension_id); void DidStartReceivingAudioOnUIThread(); void StopSucceededOnUIThread(); diff --git a/chrome/browser/speech/speech_input_bubble.cc b/chrome/browser/speech/speech_recognition_bubble.cc index 6d5bf8d..d3f4013 100644 --- a/chrome/browser/speech/speech_input_bubble.cc +++ b/chrome/browser/speech/speech_recognition_bubble.cc @@ -5,7 +5,7 @@ #include "base/bind.h" #include "base/lazy_instance.h" #include "base/message_loop.h" -#include "chrome/browser/speech/speech_input_bubble.h" +#include "chrome/browser/speech/speech_recognition_bubble.h" #include "content/public/browser/web_contents.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -24,8 +24,8 @@ const int kWarmingUpAnimationStepMs = 100; const int kRecognizingAnimationStepMs = 100; // A lazily initialized singleton to hold all the image used by the speech -// input bubbles and safely destroy them on exit. -class SpeechInputBubbleImages { +// recognition bubbles and safely destroy them on exit. +class SpeechRecognitionBubbleImages { public: const std::vector<SkBitmap>& spinner() { return spinner_; } const std::vector<SkBitmap>& warm_up() { return warm_up_; } @@ -36,8 +36,8 @@ class SpeechInputBubbleImages { private: // Private constructor to enforce singleton. - friend struct base::DefaultLazyInstanceTraits<SpeechInputBubbleImages>; - SpeechInputBubbleImages(); + friend struct base::DefaultLazyInstanceTraits<SpeechRecognitionBubbleImages>; + SpeechRecognitionBubbleImages(); std::vector<SkBitmap> spinner_; // Frames for the progress spinner. std::vector<SkBitmap> warm_up_; // Frames for the warm up animation. @@ -49,7 +49,7 @@ class SpeechInputBubbleImages { SkBitmap* mic_mask_; // Gradient mask used by the volume indicator. }; -SpeechInputBubbleImages::SpeechInputBubbleImages() { +SpeechRecognitionBubbleImages::SpeechRecognitionBubbleImages() { mic_empty_ = ResourceBundle::GetSharedInstance().GetBitmapNamed( IDR_SPEECH_INPUT_MIC_EMPTY); mic_noise_ = ResourceBundle::GetSharedInstance().GetBitmapNamed( @@ -100,17 +100,17 @@ SpeechInputBubbleImages::SpeechInputBubbleImages() { } } -base::LazyInstance<SpeechInputBubbleImages> g_images = +base::LazyInstance<SpeechRecognitionBubbleImages> g_images = LAZY_INSTANCE_INITIALIZER; } // namespace -SpeechInputBubble::FactoryMethod SpeechInputBubble::factory_ = NULL; -const int SpeechInputBubble::kBubbleTargetOffsetX = 10; +SpeechRecognitionBubble::FactoryMethod SpeechRecognitionBubble::factory_ = NULL; +const int SpeechRecognitionBubble::kBubbleTargetOffsetX = 10; -SpeechInputBubble* SpeechInputBubble::Create(WebContents* web_contents, - Delegate* delegate, - const gfx::Rect& element_rect) { +SpeechRecognitionBubble* SpeechRecognitionBubble::Create( + WebContents* web_contents, Delegate* delegate, + const gfx::Rect& element_rect) { if (factory_) return (*factory_)(web_contents, delegate, element_rect); @@ -121,7 +121,8 @@ SpeechInputBubble* SpeechInputBubble::Create(WebContents* web_contents, return CreateNativeBubble(web_contents, delegate, element_rect); } -SpeechInputBubbleBase::SpeechInputBubbleBase(WebContents* web_contents) +SpeechRecognitionBubbleBase::SpeechRecognitionBubbleBase( + WebContents* web_contents) : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), display_mode_(DISPLAY_MODE_RECORDING), web_contents_(web_contents) { @@ -138,13 +139,13 @@ SpeechInputBubbleBase::SpeechInputBubbleBase(WebContents* web_contents) buffer_image_->allocPixels(); } -SpeechInputBubbleBase::~SpeechInputBubbleBase() { +SpeechRecognitionBubbleBase::~SpeechRecognitionBubbleBase() { // This destructor is added to make sure members such as the scoped_ptr // get destroyed here and the derived classes don't have to care about such // member variables which they don't use. } -void SpeechInputBubbleBase::SetWarmUpMode() { +void SpeechRecognitionBubbleBase::SetWarmUpMode() { weak_factory_.InvalidateWeakPtrs(); display_mode_ = DISPLAY_MODE_WARM_UP; animation_step_ = 0; @@ -152,11 +153,11 @@ void SpeechInputBubbleBase::SetWarmUpMode() { UpdateLayout(); } -void SpeechInputBubbleBase::DoWarmingUpAnimationStep() { +void SpeechRecognitionBubbleBase::DoWarmingUpAnimationStep() { SetImage(g_images.Get().warm_up()[animation_step_]); MessageLoop::current()->PostDelayedTask( FROM_HERE, - base::Bind(&SpeechInputBubbleBase::DoWarmingUpAnimationStep, + base::Bind(&SpeechRecognitionBubbleBase::DoWarmingUpAnimationStep, weak_factory_.GetWeakPtr()), base::TimeDelta::FromMilliseconds( animation_step_ == 0 ? kWarmingUpAnimationStartMs @@ -165,41 +166,41 @@ void SpeechInputBubbleBase::DoWarmingUpAnimationStep() { animation_step_ = 1; // Frame 0 is skipped during the animation. } -void SpeechInputBubbleBase::SetRecordingMode() { +void SpeechRecognitionBubbleBase::SetRecordingMode() { weak_factory_.InvalidateWeakPtrs(); display_mode_ = DISPLAY_MODE_RECORDING; SetInputVolume(0, 0); UpdateLayout(); } -void SpeechInputBubbleBase::SetRecognizingMode() { +void SpeechRecognitionBubbleBase::SetRecognizingMode() { display_mode_ = DISPLAY_MODE_RECOGNIZING; animation_step_ = 0; DoRecognizingAnimationStep(); UpdateLayout(); } -void SpeechInputBubbleBase::DoRecognizingAnimationStep() { +void SpeechRecognitionBubbleBase::DoRecognizingAnimationStep() { SetImage(g_images.Get().spinner()[animation_step_]); if (++animation_step_ >= static_cast<int>(g_images.Get().spinner().size())) animation_step_ = 0; MessageLoop::current()->PostDelayedTask( FROM_HERE, - base::Bind(&SpeechInputBubbleBase::DoRecognizingAnimationStep, + base::Bind(&SpeechRecognitionBubbleBase::DoRecognizingAnimationStep, weak_factory_.GetWeakPtr()), base::TimeDelta::FromMilliseconds(kRecognizingAnimationStepMs)); } -void SpeechInputBubbleBase::SetMessage(const string16& text) { +void SpeechRecognitionBubbleBase::SetMessage(const string16& text) { weak_factory_.InvalidateWeakPtrs(); message_text_ = text; display_mode_ = DISPLAY_MODE_MESSAGE; UpdateLayout(); } -void SpeechInputBubbleBase::DrawVolumeOverlay(SkCanvas* canvas, - const SkBitmap& bitmap, - float volume) { +void SpeechRecognitionBubbleBase::DrawVolumeOverlay(SkCanvas* canvas, + const SkBitmap& bitmap, + float volume) { buffer_image_->eraseARGB(0, 0, 0, 0); int width = mic_image_->width(); @@ -222,7 +223,8 @@ void SpeechInputBubbleBase::DrawVolumeOverlay(SkCanvas* canvas, canvas->drawBitmap(*buffer_image_.get(), 0, 0); } -void SpeechInputBubbleBase::SetInputVolume(float volume, float noise_volume) { +void SpeechRecognitionBubbleBase::SetInputVolume(float volume, + float noise_volume) { mic_image_->eraseARGB(0, 0, 0, 0); SkCanvas canvas(*mic_image_); @@ -235,15 +237,15 @@ void SpeechInputBubbleBase::SetInputVolume(float volume, float noise_volume) { SetImage(*mic_image_.get()); } -WebContents* SpeechInputBubbleBase::web_contents() { +WebContents* SpeechRecognitionBubbleBase::web_contents() { return web_contents_; } -void SpeechInputBubbleBase::SetImage(const SkBitmap& image) { +void SpeechRecognitionBubbleBase::SetImage(const SkBitmap& image) { icon_image_.reset(new SkBitmap(image)); UpdateImage(); } -SkBitmap SpeechInputBubbleBase::icon_image() { +SkBitmap SpeechRecognitionBubbleBase::icon_image() { return (icon_image_ != NULL) ? *icon_image_ : SkBitmap(); } diff --git a/chrome/browser/speech/speech_input_bubble.h b/chrome/browser/speech/speech_recognition_bubble.h index 2ebfe56..f3fef09 100644 --- a/chrome/browser/speech/speech_input_bubble.h +++ b/chrome/browser/speech/speech_recognition_bubble.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_SPEECH_SPEECH_INPUT_BUBBLE_H_ -#define CHROME_BROWSER_SPEECH_SPEECH_INPUT_BUBBLE_H_ +#ifndef CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_H_ +#define CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_H_ #pragma once #include <vector> @@ -24,11 +24,11 @@ class Canvas; class Rect; } -// SpeechInputBubble displays a popup info bubble during speech recognition, -// points to the html element which requested speech input and shows recognition -// progress events. The popup is closed by the user clicking anywhere outside -// the popup window, or by the caller destroying this object. -class SpeechInputBubble { +// SpeechRecognitionBubble displays a popup info bubble during speech +// recognition, points to the html element which requested speech recognition +// and shows progress events. The popup is closed by the user clicking anywhere +// outside the popup window, or by the caller destroying this object. +class SpeechRecognitionBubble { public: // The various buttons which may be part of the bubble. enum Button { @@ -58,31 +58,31 @@ class SpeechInputBubble { // Creates the bubble, call |Show| to display it on screen. // |web_contents| is the WebContents hosting the page. // |element_rect| is the display bounds of the html element requesting speech - // input (in page coordinates). - static SpeechInputBubble* Create(content::WebContents* web_contents, - Delegate* delegate, - const gfx::Rect& element_rect); + // recognition (in page coordinates). + static SpeechRecognitionBubble* Create(content::WebContents* web_contents, + Delegate* delegate, + const gfx::Rect& element_rect); // This is implemented by platform specific code to create the underlying // bubble window. Not to be called directly by users of this class. - static SpeechInputBubble* CreateNativeBubble( + static SpeechRecognitionBubble* CreateNativeBubble( content::WebContents* web_contents, Delegate* delegate, const gfx::Rect& element_rect); // |Create| uses the currently registered FactoryMethod to create the - // SpeechInputBubble instances. FactoryMethod is intended for testing. - typedef SpeechInputBubble* (*FactoryMethod)(content::WebContents*, - Delegate*, - const gfx::Rect&); - // Sets the factory used by the static method Create. SpeechInputBubble does - // not take ownership of |factory|. A value of NULL results in a - // SpeechInputBubble being created directly. + // SpeechRecognitionBubble instances. FactoryMethod is intended for testing. + typedef SpeechRecognitionBubble* (*FactoryMethod)(content::WebContents*, + Delegate*, + const gfx::Rect&); + // Sets the factory used by the static method Create. SpeechRecognitionBubble + // does not take ownership of |factory|. A value of NULL results in a + // SpeechRecognitionBubble being created directly. #if defined(UNIT_TEST) static void set_factory(FactoryMethod factory) { factory_ = factory; } #endif - virtual ~SpeechInputBubble() {} + virtual ~SpeechRecognitionBubble() {} // Indicates to the user that audio hardware is initializing. If the bubble is // hidden, |Show| must be called to make it appear on screen. @@ -122,8 +122,8 @@ class SpeechInputBubble { }; // Base class for the platform specific bubble implementations, this contains -// the platform independent code for SpeechInputBubble. -class SpeechInputBubbleBase : public SpeechInputBubble { +// the platform independent code for SpeechRecognitionBubble. +class SpeechRecognitionBubbleBase : public SpeechRecognitionBubble { public: // The current display mode of the bubble, useful only for the platform // specific implementation. @@ -134,10 +134,10 @@ class SpeechInputBubbleBase : public SpeechInputBubble { DISPLAY_MODE_MESSAGE }; - explicit SpeechInputBubbleBase(content::WebContents* web_contents); - virtual ~SpeechInputBubbleBase(); + explicit SpeechRecognitionBubbleBase(content::WebContents* web_contents); + virtual ~SpeechRecognitionBubbleBase(); - // SpeechInputBubble methods + // SpeechRecognitionBubble methods virtual void SetWarmUpMode() OVERRIDE; virtual void SetRecordingMode() OVERRIDE; virtual void SetRecognizingMode() OVERRIDE; @@ -168,7 +168,7 @@ class SpeechInputBubbleBase : public SpeechInputBubble { float volume); // Task factory used for animation timer. - base::WeakPtrFactory<SpeechInputBubbleBase> weak_factory_; + base::WeakPtrFactory<SpeechRecognitionBubbleBase> weak_factory_; int animation_step_; // Current index/step of the animation. std::vector<SkBitmap> animation_frames_; std::vector<SkBitmap> warming_up_frames_; @@ -189,6 +189,6 @@ class SpeechInputBubbleBase : public SpeechInputBubble { // Visual Studio where it gets confused between multiple Delegate // classes and gives a C2500 error. (I saw this error on the try bots - // the workaround was not needed for my machine). -typedef SpeechInputBubble::Delegate SpeechInputBubbleDelegate; +typedef SpeechRecognitionBubble::Delegate SpeechRecognitionBubbleDelegate; -#endif // CHROME_BROWSER_SPEECH_SPEECH_INPUT_BUBBLE_H_ +#endif // CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_H_ diff --git a/chrome/browser/speech/speech_input_bubble_browsertest.cc b/chrome/browser/speech/speech_recognition_bubble_browsertest.cc index 72fbf3a..7b1bec9 100644 --- a/chrome/browser/speech/speech_input_bubble_browsertest.cc +++ b/chrome/browser/speech/speech_recognition_bubble_browsertest.cc @@ -1,52 +1,53 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/memory/scoped_ptr.h" -#include "chrome/browser/speech/speech_input_bubble.h" +#include "chrome/browser/speech/speech_recognition_bubble.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/test/base/in_process_browser_test.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/gfx/rect.h" -class SpeechInputBubbleTest : public SpeechInputBubbleDelegate, +class SpeechRecognitionBubbleTest : public SpeechRecognitionBubbleDelegate, public InProcessBrowserTest { public: - // SpeechInputBubble::Delegate methods. - virtual void InfoBubbleButtonClicked(SpeechInputBubble::Button button) {} + // SpeechRecognitionBubble::Delegate methods. + virtual void InfoBubbleButtonClicked(SpeechRecognitionBubble::Button button) { + } virtual void InfoBubbleFocusChanged() {} protected: }; -IN_PROC_BROWSER_TEST_F(SpeechInputBubbleTest, CreateAndDestroy) { +IN_PROC_BROWSER_TEST_F(SpeechRecognitionBubbleTest, CreateAndDestroy) { gfx::Rect element_rect(100, 100, 100, 100); - scoped_ptr<SpeechInputBubble> bubble(SpeechInputBubble::Create( + scoped_ptr<SpeechRecognitionBubble> bubble(SpeechRecognitionBubble::Create( browser()->GetSelectedWebContents(), this, element_rect)); EXPECT_TRUE(bubble.get()); } -IN_PROC_BROWSER_TEST_F(SpeechInputBubbleTest, ShowAndDestroy) { +IN_PROC_BROWSER_TEST_F(SpeechRecognitionBubbleTest, ShowAndDestroy) { gfx::Rect element_rect(100, 100, 100, 100); - scoped_ptr<SpeechInputBubble> bubble(SpeechInputBubble::Create( + scoped_ptr<SpeechRecognitionBubble> bubble(SpeechRecognitionBubble::Create( browser()->GetSelectedWebContents(), this, element_rect)); EXPECT_TRUE(bubble.get()); bubble->Show(); } -IN_PROC_BROWSER_TEST_F(SpeechInputBubbleTest, ShowAndHide) { +IN_PROC_BROWSER_TEST_F(SpeechRecognitionBubbleTest, ShowAndHide) { gfx::Rect element_rect(100, 100, 100, 100); - scoped_ptr<SpeechInputBubble> bubble(SpeechInputBubble::Create( + scoped_ptr<SpeechRecognitionBubble> bubble(SpeechRecognitionBubble::Create( browser()->GetSelectedWebContents(), this, element_rect)); EXPECT_TRUE(bubble.get()); bubble->Show(); bubble->Hide(); } -IN_PROC_BROWSER_TEST_F(SpeechInputBubbleTest, ShowAndHideTwice) { +IN_PROC_BROWSER_TEST_F(SpeechRecognitionBubbleTest, ShowAndHideTwice) { gfx::Rect element_rect(100, 100, 100, 100); - scoped_ptr<SpeechInputBubble> bubble(SpeechInputBubble::Create( + scoped_ptr<SpeechRecognitionBubble> bubble(SpeechRecognitionBubble::Create( browser()->GetSelectedWebContents(), this, element_rect)); EXPECT_TRUE(bubble.get()); bubble->Show(); diff --git a/chrome/browser/speech/speech_input_bubble_controller.cc b/chrome/browser/speech/speech_recognition_bubble_controller.cc index 8645e51..656738f 100644 --- a/chrome/browser/speech/speech_input_bubble_controller.cc +++ b/chrome/browser/speech/speech_recognition_bubble_controller.cc @@ -1,8 +1,8 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/speech/speech_input_bubble_controller.h" +#include "chrome/browser/speech/speech_recognition_bubble_controller.h" #include "base/bind.h" #include "chrome/browser/tab_contents/tab_util.h" @@ -16,28 +16,29 @@ using content::BrowserThread; using content::WebContents; -namespace speech_input { +namespace speech { -SpeechInputBubbleController::SpeechInputBubbleController(Delegate* delegate) +SpeechRecognitionBubbleController::SpeechRecognitionBubbleController( + Delegate* delegate) : delegate_(delegate), current_bubble_caller_id_(0), registrar_(new content::NotificationRegistrar) { } -SpeechInputBubbleController::~SpeechInputBubbleController() { +SpeechRecognitionBubbleController::~SpeechRecognitionBubbleController() { DCHECK(bubbles_.empty()); } -void SpeechInputBubbleController::CreateBubble(int caller_id, - int render_process_id, - int render_view_id, - const gfx::Rect& element_rect) { +void SpeechRecognitionBubbleController::CreateBubble( + int caller_id, + int render_process_id, + int render_view_id, + const gfx::Rect& element_rect) { if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(&SpeechInputBubbleController::CreateBubble, this, - caller_id, render_process_id, render_view_id, - element_rect)); + base::Bind(&SpeechRecognitionBubbleController::CreateBubble, this, + caller_id, render_process_id, render_view_id, element_rect)); return; } DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -45,16 +46,16 @@ void SpeechInputBubbleController::CreateBubble(int caller_id, render_view_id); DCHECK_EQ(0u, bubbles_.count(caller_id)); - SpeechInputBubble* bubble = SpeechInputBubble::Create(web_contents, this, - element_rect); + SpeechRecognitionBubble* bubble = SpeechRecognitionBubble::Create( + web_contents, this, element_rect); if (!bubble) { // Could be null if tab or display rect were invalid. // Simulate the cancel button being clicked to inform the delegate. BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind( - &SpeechInputBubbleController::InvokeDelegateButtonClicked, - this, caller_id, SpeechInputBubble::BUTTON_CANCEL)); + &SpeechRecognitionBubbleController::InvokeDelegateButtonClicked, + this, caller_id, SpeechRecognitionBubble::BUTTON_CANCEL)); return; } @@ -63,38 +64,38 @@ void SpeechInputBubbleController::CreateBubble(int caller_id, UpdateTabContentsSubscription(caller_id, BUBBLE_ADDED); } -void SpeechInputBubbleController::CloseBubble(int caller_id) { +void SpeechRecognitionBubbleController::CloseBubble(int caller_id) { ProcessRequestInUiThread(caller_id, REQUEST_CLOSE, string16(), 0, 0); } -void SpeechInputBubbleController::SetBubbleWarmUpMode(int caller_id) { +void SpeechRecognitionBubbleController::SetBubbleWarmUpMode(int caller_id) { ProcessRequestInUiThread(caller_id, REQUEST_SET_WARM_UP_MODE, string16(), 0, 0); } -void SpeechInputBubbleController::SetBubbleRecordingMode(int caller_id) { +void SpeechRecognitionBubbleController::SetBubbleRecordingMode(int caller_id) { ProcessRequestInUiThread(caller_id, REQUEST_SET_RECORDING_MODE, string16(), 0, 0); } -void SpeechInputBubbleController::SetBubbleRecognizingMode(int caller_id) { +void SpeechRecognitionBubbleController::SetBubbleRecognizingMode( + int caller_id) { ProcessRequestInUiThread(caller_id, REQUEST_SET_RECOGNIZING_MODE, string16(), 0, 0); } -void SpeechInputBubbleController::SetBubbleInputVolume(int caller_id, - float volume, - float noise_volume) { +void SpeechRecognitionBubbleController::SetBubbleInputVolume( + int caller_id, float volume, float noise_volume) { ProcessRequestInUiThread(caller_id, REQUEST_SET_INPUT_VOLUME, string16(), volume, noise_volume); } -void SpeechInputBubbleController::SetBubbleMessage(int caller_id, - const string16& text) { +void SpeechRecognitionBubbleController::SetBubbleMessage(int caller_id, + const string16& text) { ProcessRequestInUiThread(caller_id, REQUEST_SET_MESSAGE, text, 0, 0); } -void SpeechInputBubbleController::UpdateTabContentsSubscription( +void SpeechRecognitionBubbleController::UpdateTabContentsSubscription( int caller_id, ManageSubscriptionAction action) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -117,11 +118,11 @@ void SpeechInputBubbleController::UpdateTabContentsSubscription( content::Source<WebContents>(web_contents)); } else { registrar_->Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, - content::Source<WebContents>(web_contents)); + content::Source<WebContents>(web_contents)); } } -void SpeechInputBubbleController::Observe( +void SpeechRecognitionBubbleController::Observe( int type, const content::NotificationSource& source, const content::NotificationDetails& details) { @@ -133,8 +134,8 @@ void SpeechInputBubbleController::Observe( if (iter->second->web_contents() == web_contents) { BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( - &SpeechInputBubbleController::InvokeDelegateButtonClicked, - this, iter->first, SpeechInputBubble::BUTTON_CANCEL)); + &SpeechRecognitionBubbleController::InvokeDelegateButtonClicked, + this, iter->first, SpeechRecognitionBubble::BUTTON_CANCEL)); CloseBubble(iter->first); // We expect to have a very small number of items in this map so // redo-ing from start is ok. @@ -148,12 +149,12 @@ void SpeechInputBubbleController::Observe( } } -void SpeechInputBubbleController::ProcessRequestInUiThread( +void SpeechRecognitionBubbleController::ProcessRequestInUiThread( int caller_id, RequestType type, const string16& text, float volume, float noise_volume) { if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( - &SpeechInputBubbleController::ProcessRequestInUiThread, this, + &SpeechRecognitionBubbleController::ProcessRequestInUiThread, this, caller_id, type, text, volume, noise_volume)); return; } @@ -171,7 +172,7 @@ void SpeechInputBubbleController::ProcessRequestInUiThread( current_bubble_caller_id_ = caller_id; } - SpeechInputBubble* bubble = bubbles_[caller_id]; + SpeechRecognitionBubble* bubble = bubbles_[caller_id]; switch (type) { case REQUEST_SET_WARM_UP_MODE: bubble->SetWarmUpMode(); @@ -204,19 +205,19 @@ void SpeechInputBubbleController::ProcessRequestInUiThread( bubble->Show(); } -void SpeechInputBubbleController::InfoBubbleButtonClicked( - SpeechInputBubble::Button button) { +void SpeechRecognitionBubbleController::InfoBubbleButtonClicked( + SpeechRecognitionBubble::Button button) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(current_bubble_caller_id_); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind( - &SpeechInputBubbleController::InvokeDelegateButtonClicked, + &SpeechRecognitionBubbleController::InvokeDelegateButtonClicked, this, current_bubble_caller_id_, button)); } -void SpeechInputBubbleController::InfoBubbleFocusChanged() { +void SpeechRecognitionBubbleController::InfoBubbleFocusChanged() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(current_bubble_caller_id_); @@ -226,17 +227,18 @@ void SpeechInputBubbleController::InfoBubbleFocusChanged() { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind( - &SpeechInputBubbleController::InvokeDelegateFocusChanged, + &SpeechRecognitionBubbleController::InvokeDelegateFocusChanged, this, old_bubble_caller_id)); } -void SpeechInputBubbleController::InvokeDelegateButtonClicked( - int caller_id, SpeechInputBubble::Button button) { +void SpeechRecognitionBubbleController::InvokeDelegateButtonClicked( + int caller_id, SpeechRecognitionBubble::Button button) { delegate_->InfoBubbleButtonClicked(caller_id, button); } -void SpeechInputBubbleController::InvokeDelegateFocusChanged(int caller_id) { +void SpeechRecognitionBubbleController::InvokeDelegateFocusChanged( + int caller_id) { delegate_->InfoBubbleFocusChanged(caller_id); } -} // namespace speech_input +} // namespace speech diff --git a/chrome/browser/speech/speech_input_bubble_controller.h b/chrome/browser/speech/speech_recognition_bubble_controller.h index 39a0293..735b9dd 100644 --- a/chrome/browser/speech/speech_input_bubble_controller.h +++ b/chrome/browser/speech/speech_recognition_bubble_controller.h @@ -1,16 +1,16 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_SPEECH_SPEECH_INPUT_BUBBLE_CONTROLLER_H_ -#define CHROME_BROWSER_SPEECH_SPEECH_INPUT_BUBBLE_CONTROLLER_H_ +#ifndef CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_CONTROLLER_H_ +#define CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_CONTROLLER_H_ #include <map> #include "base/basictypes.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/speech/speech_input_bubble.h" +#include "chrome/browser/speech/speech_recognition_bubble.h" #include "content/public/browser/notification_observer.h" namespace gfx { @@ -21,38 +21,38 @@ namespace content { class NotificationRegistrar; } -namespace speech_input { +namespace speech { -// This class handles the speech input popup UI on behalf of SpeechInputManager. -// SpeechInputManager invokes methods in the IO thread and this class processes +// This class handles the speech recognition popup UI on behalf of +// SpeechRecognitionManager, which invokes methods in the IO thread, processing // those requests in the UI thread. There could be multiple bubble objects alive // at the same time but only one of them is visible to the user. User actions on // that bubble are reported to the delegate. -class SpeechInputBubbleController - : public base::RefCountedThreadSafe<SpeechInputBubbleController>, - public SpeechInputBubbleDelegate, +class SpeechRecognitionBubbleController + : public base::RefCountedThreadSafe<SpeechRecognitionBubbleController>, + public SpeechRecognitionBubbleDelegate, public content::NotificationObserver { public: // All methods of this delegate are called in the IO thread. class Delegate { public: - // Invoked when the user clicks on a button in the speech input UI. - virtual void InfoBubbleButtonClicked(int caller_id, - SpeechInputBubble::Button button) = 0; + // Invoked when the user clicks on a button in the speech recognition UI. + virtual void InfoBubbleButtonClicked( + int caller_id, SpeechRecognitionBubble::Button button) = 0; - // Invoked when the user clicks outside the speech input info bubble causing - // it to close and input focus to change. + // Invoked when the user clicks outside the speech recognition info bubble + // causing it to close and input focus to change. virtual void InfoBubbleFocusChanged(int caller_id) = 0; protected: virtual ~Delegate() {} }; - explicit SpeechInputBubbleController(Delegate* delegate); - virtual ~SpeechInputBubbleController(); + explicit SpeechRecognitionBubbleController(Delegate* delegate); + virtual ~SpeechRecognitionBubbleController(); - // Creates a new speech input UI bubble. One of the SetXxxx methods below need - // to be called to specify what to display. + // Creates a new speech recognition UI bubble. One of the SetXxxx methods + // below need to be called to specify what to display. void CreateBubble(int caller_id, int render_process_id, int render_view_id, @@ -79,9 +79,9 @@ class SpeechInputBubbleController void CloseBubble(int caller_id); - // SpeechInputBubble::Delegate methods. + // SpeechRecognitionBubble::Delegate methods. virtual void InfoBubbleButtonClicked( - SpeechInputBubble::Button button) OVERRIDE; + SpeechRecognitionBubble::Button button) OVERRIDE; virtual void InfoBubbleFocusChanged() OVERRIDE; // content::NotificationObserver implementation. @@ -106,7 +106,7 @@ class SpeechInputBubbleController }; void InvokeDelegateButtonClicked(int caller_id, - SpeechInputBubble::Button button); + SpeechRecognitionBubble::Button button); void InvokeDelegateFocusChanged(int caller_id); void ProcessRequestInUiThread(int caller_id, RequestType type, @@ -133,7 +133,7 @@ class SpeechInputBubbleController // Map of caller-ids to bubble objects. The bubbles are weak pointers owned by // this object and get destroyed by |CloseBubble|. - typedef std::map<int, SpeechInputBubble*> BubbleCallerIdMap; + typedef std::map<int, SpeechRecognitionBubble*> BubbleCallerIdMap; BubbleCallerIdMap bubbles_; scoped_ptr<content::NotificationRegistrar> registrar_; @@ -143,9 +143,9 @@ class SpeechInputBubbleController // Visual Studio where it gets confused between multiple Delegate // classes and gives a C2500 error. (I saw this error on the try bots - // the workaround was not needed for my machine). -typedef SpeechInputBubbleController::Delegate - SpeechInputBubbleControllerDelegate; +typedef SpeechRecognitionBubbleController::Delegate + SpeechRecognitionBubbleControllerDelegate; -} // namespace speech_input +} // namespace speech -#endif // CHROME_BROWSER_SPEECH_SPEECH_INPUT_BUBBLE_CONTROLLER_H_ +#endif // CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_CONTROLLER_H_ diff --git a/chrome/browser/speech/speech_input_bubble_controller_unittest.cc b/chrome/browser/speech/speech_recognition_bubble_controller_unittest.cc index a935dd3..bf1ad88 100644 --- a/chrome/browser/speech/speech_input_bubble_controller_unittest.cc +++ b/chrome/browser/speech/speech_recognition_bubble_controller_unittest.cc @@ -1,10 +1,10 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/bind.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/speech/speech_input_bubble_controller.h" +#include "chrome/browser/speech/speech_recognition_bubble_controller.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/test/base/browser_with_test_window_test.h" @@ -18,11 +18,11 @@ using content::WebContents; class SkBitmap; -namespace speech_input { +namespace speech { // A mock bubble class which fakes a focus change or recognition cancel by the // user and closing of the info bubble. -class MockSpeechInputBubble : public SpeechInputBubbleBase { +class MockSpeechRecognitionBubble : public SpeechRecognitionBubbleBase { public: enum BubbleType { BUBBLE_TEST_FOCUS_CHANGED, @@ -30,26 +30,29 @@ class MockSpeechInputBubble : public SpeechInputBubbleBase { BUBBLE_TEST_CLICK_TRY_AGAIN, }; - MockSpeechInputBubble(WebContents* web_contents, + MockSpeechRecognitionBubble(WebContents* web_contents, Delegate* delegate, const gfx::Rect&) - : SpeechInputBubbleBase(web_contents) { - VLOG(1) << "MockSpeechInputBubble created"; + : SpeechRecognitionBubbleBase(web_contents) { + VLOG(1) << "MockSpeechRecognitionBubble created"; MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&InvokeDelegate, delegate)); } static void InvokeDelegate(Delegate* delegate) { - VLOG(1) << "MockSpeechInputBubble invoking delegate for type " << type_; + VLOG(1) << "MockSpeechRecognitionBubble invoking delegate for type " + << type_; switch (type_) { case BUBBLE_TEST_FOCUS_CHANGED: delegate->InfoBubbleFocusChanged(); break; case BUBBLE_TEST_CLICK_CANCEL: - delegate->InfoBubbleButtonClicked(SpeechInputBubble::BUTTON_CANCEL); + delegate->InfoBubbleButtonClicked( + SpeechRecognitionBubble::BUTTON_CANCEL); break; case BUBBLE_TEST_CLICK_TRY_AGAIN: - delegate->InfoBubbleButtonClicked(SpeechInputBubble::BUTTON_TRY_AGAIN); + delegate->InfoBubbleButtonClicked( + SpeechRecognitionBubble::BUTTON_TRY_AGAIN); break; } } @@ -71,34 +74,34 @@ class MockSpeechInputBubble : public SpeechInputBubbleBase { }; // The test fixture. -class SpeechInputBubbleControllerTest - : public SpeechInputBubbleControllerDelegate, +class SpeechRecognitionBubbleControllerTest + : public SpeechRecognitionBubbleControllerDelegate, public BrowserWithTestWindowTest { public: - SpeechInputBubbleControllerTest() + SpeechRecognitionBubbleControllerTest() : BrowserWithTestWindowTest(), io_thread_(BrowserThread::IO), // constructs a new thread and loop cancel_clicked_(false), try_again_clicked_(false), focus_changed_(false), controller_(ALLOW_THIS_IN_INITIALIZER_LIST( - new SpeechInputBubbleController(this))) { + new SpeechRecognitionBubbleController(this))) { EXPECT_EQ(NULL, test_fixture_); test_fixture_ = this; } - ~SpeechInputBubbleControllerTest() { + ~SpeechRecognitionBubbleControllerTest() { test_fixture_ = NULL; } - // SpeechInputBubbleControllerDelegate methods. + // SpeechRecognitionBubbleControllerDelegate methods. virtual void InfoBubbleButtonClicked(int caller_id, - SpeechInputBubble::Button button) { + SpeechRecognitionBubble::Button button) { VLOG(1) << "Received InfoBubbleButtonClicked for button " << button; EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (button == SpeechInputBubble::BUTTON_CANCEL) { + if (button == SpeechRecognitionBubble::BUTTON_CANCEL) { cancel_clicked_ = true; - } else if (button == SpeechInputBubble::BUTTON_TRY_AGAIN) { + } else if (button == SpeechRecognitionBubble::BUTTON_TRY_AGAIN) { try_again_clicked_ = true; } message_loop()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); @@ -114,20 +117,20 @@ class SpeechInputBubbleControllerTest // testing::Test methods. virtual void SetUp() { BrowserWithTestWindowTest::SetUp(); - SpeechInputBubble::set_factory( - &SpeechInputBubbleControllerTest::CreateBubble); + SpeechRecognitionBubble::set_factory( + &SpeechRecognitionBubbleControllerTest::CreateBubble); io_thread_.Start(); } virtual void TearDown() { - SpeechInputBubble::set_factory(NULL); + SpeechRecognitionBubble::set_factory(NULL); io_thread_.Stop(); BrowserWithTestWindowTest::TearDown(); } static void ActivateBubble() { - if (MockSpeechInputBubble::type() == - MockSpeechInputBubble::BUBBLE_TEST_FOCUS_CHANGED) { + if (MockSpeechRecognitionBubble::type() == + MockSpeechRecognitionBubble::BUBBLE_TEST_FOCUS_CHANGED) { test_fixture_->controller_->SetBubbleWarmUpMode(kBubbleCallerId); } else { test_fixture_->controller_->SetBubbleMessage(kBubbleCallerId, @@ -135,9 +138,10 @@ class SpeechInputBubbleControllerTest } } - static SpeechInputBubble* CreateBubble(WebContents* web_contents, - SpeechInputBubble::Delegate* delegate, - const gfx::Rect& element_rect) { + static SpeechRecognitionBubble* CreateBubble( + WebContents* web_contents, + SpeechRecognitionBubble::Delegate* delegate, + const gfx::Rect& element_rect) { EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); // Set up to activate the bubble soon after it gets created, since we test // events sent by the bubble and those are handled only when the bubble is @@ -152,9 +156,10 @@ class SpeechInputBubbleControllerTest // a valid WebContents. TabContentsWrapper* wrapper = test_fixture_->browser()->GetSelectedTabContentsWrapper(); - if (wrapper) + if (wrapper) web_contents = wrapper->web_contents(); - return new MockSpeechInputBubble(web_contents, delegate, element_rect); + return new MockSpeechRecognitionBubble(web_contents, delegate, + element_rect); } protected: @@ -164,25 +169,25 @@ class SpeechInputBubbleControllerTest bool cancel_clicked_; bool try_again_clicked_; bool focus_changed_; - scoped_refptr<SpeechInputBubbleController> controller_; + scoped_refptr<SpeechRecognitionBubbleController> controller_; static const int kBubbleCallerId; - static SpeechInputBubbleControllerTest* test_fixture_; + static SpeechRecognitionBubbleControllerTest* test_fixture_; }; -SpeechInputBubbleControllerTest* -SpeechInputBubbleControllerTest::test_fixture_ = NULL; +SpeechRecognitionBubbleControllerTest* +SpeechRecognitionBubbleControllerTest::test_fixture_ = NULL; -const int SpeechInputBubbleControllerTest::kBubbleCallerId = 1; +const int SpeechRecognitionBubbleControllerTest::kBubbleCallerId = 1; -MockSpeechInputBubble::BubbleType MockSpeechInputBubble::type_ = - MockSpeechInputBubble::BUBBLE_TEST_FOCUS_CHANGED; +MockSpeechRecognitionBubble::BubbleType MockSpeechRecognitionBubble::type_ = + MockSpeechRecognitionBubble::BUBBLE_TEST_FOCUS_CHANGED; // Test that the speech bubble UI gets created in the UI thread and that the // focus changed callback comes back in the IO thread. -TEST_F(SpeechInputBubbleControllerTest, TestFocusChanged) { - MockSpeechInputBubble::set_type( - MockSpeechInputBubble::BUBBLE_TEST_FOCUS_CHANGED); +TEST_F(SpeechRecognitionBubbleControllerTest, TestFocusChanged) { + MockSpeechRecognitionBubble::set_type( + MockSpeechRecognitionBubble::BUBBLE_TEST_FOCUS_CHANGED); controller_->CreateBubble(kBubbleCallerId, 1, 1, gfx::Rect(1, 1)); MessageLoop::current()->Run(); @@ -194,9 +199,9 @@ TEST_F(SpeechInputBubbleControllerTest, TestFocusChanged) { // Test that the speech bubble UI gets created in the UI thread and that the // recognition cancelled callback comes back in the IO thread. -TEST_F(SpeechInputBubbleControllerTest, TestRecognitionCancelled) { - MockSpeechInputBubble::set_type( - MockSpeechInputBubble::BUBBLE_TEST_CLICK_CANCEL); +TEST_F(SpeechRecognitionBubbleControllerTest, TestRecognitionCancelled) { + MockSpeechRecognitionBubble::set_type( + MockSpeechRecognitionBubble::BUBBLE_TEST_CLICK_CANCEL); controller_->CreateBubble(kBubbleCallerId, 1, 1, gfx::Rect(1, 1)); MessageLoop::current()->Run(); @@ -208,9 +213,9 @@ TEST_F(SpeechInputBubbleControllerTest, TestRecognitionCancelled) { // Test that the speech bubble UI gets created in the UI thread and that the // try-again button click event comes back in the IO thread. -TEST_F(SpeechInputBubbleControllerTest, TestTryAgainClicked) { - MockSpeechInputBubble::set_type( - MockSpeechInputBubble::BUBBLE_TEST_CLICK_TRY_AGAIN); +TEST_F(SpeechRecognitionBubbleControllerTest, TestTryAgainClicked) { + MockSpeechRecognitionBubble::set_type( + MockSpeechRecognitionBubble::BUBBLE_TEST_CLICK_TRY_AGAIN); controller_->CreateBubble(kBubbleCallerId, 1, 1, gfx::Rect(1, 1)); MessageLoop::current()->Run(); @@ -220,4 +225,4 @@ TEST_F(SpeechInputBubbleControllerTest, TestTryAgainClicked) { controller_->CloseBubble(kBubbleCallerId); } -} // namespace speech_input +} // namespace speech diff --git a/chrome/browser/speech/speech_input_bubble_gtk.cc b/chrome/browser/speech/speech_recognition_bubble_gtk.cc index a548bc1..816aa73 100644 --- a/chrome/browser/speech/speech_input_bubble_gtk.cc +++ b/chrome/browser/speech/speech_recognition_bubble_gtk.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/speech/speech_input_bubble.h" +#include "chrome/browser/speech/speech_recognition_bubble.h" #include "base/utf_string_conversions.h" #include "chrome/browser/profiles/profile.h" @@ -15,7 +15,7 @@ #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" #include "chrome/browser/ui/gtk/theme_service_gtk.h" #include "content/public/browser/resource_context.h" -#include "content/public/browser/speech_input_manager.h" +#include "content/public/browser/speech_recognition_manager.h" #include "content/public/browser/web_contents.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -38,18 +38,18 @@ const int kButtonBarHorizontalSpacing = 10; // Use black for text labels since the bubble has white background. const GdkColor& kLabelTextColor = ui::kGdkBlack; -// Implementation of SpeechInputBubble for GTK. This shows a speech input bubble -// on screen. -class SpeechInputBubbleGtk : public SpeechInputBubbleBase, - public BubbleDelegateGtk { +// Implementation of SpeechRecognitionBubble for GTK. This shows a speech +// recognition bubble on screen. +class SpeechRecognitionBubbleGtk : public SpeechRecognitionBubbleBase, + public BubbleDelegateGtk { public: - SpeechInputBubbleGtk(WebContents* web_contents, - Delegate* delegate, - const gfx::Rect& element_rect); - ~SpeechInputBubbleGtk(); + SpeechRecognitionBubbleGtk(WebContents* web_contents, + Delegate* delegate, + const gfx::Rect& element_rect); + ~SpeechRecognitionBubbleGtk(); private: - // SpeechInputBubbleBase: + // SpeechRecognitionBubbleBase: virtual void Show() OVERRIDE; virtual void Hide() OVERRIDE; virtual void UpdateLayout() OVERRIDE; @@ -58,9 +58,9 @@ class SpeechInputBubbleGtk : public SpeechInputBubbleBase, // BubbleDelegateGtk: virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE; - CHROMEGTK_CALLBACK_0(SpeechInputBubbleGtk, void, OnCancelClicked); - CHROMEGTK_CALLBACK_0(SpeechInputBubbleGtk, void, OnTryAgainClicked); - CHROMEGTK_CALLBACK_0(SpeechInputBubbleGtk, void, OnMicSettingsClicked); + CHROMEGTK_CALLBACK_0(SpeechRecognitionBubbleGtk, void, OnCancelClicked); + CHROMEGTK_CALLBACK_0(SpeechRecognitionBubbleGtk, void, OnTryAgainClicked); + CHROMEGTK_CALLBACK_0(SpeechRecognitionBubbleGtk, void, OnMicSettingsClicked); Delegate* delegate_; BubbleGtk* bubble_; @@ -74,13 +74,13 @@ class SpeechInputBubbleGtk : public SpeechInputBubbleBase, GtkWidget* icon_container_; GtkWidget* mic_settings_; - DISALLOW_COPY_AND_ASSIGN(SpeechInputBubbleGtk); + DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionBubbleGtk); }; -SpeechInputBubbleGtk::SpeechInputBubbleGtk(WebContents* web_contents, - Delegate* delegate, - const gfx::Rect& element_rect) - : SpeechInputBubbleBase(web_contents), +SpeechRecognitionBubbleGtk::SpeechRecognitionBubbleGtk( + WebContents* web_contents, Delegate* delegate, + const gfx::Rect& element_rect) + : SpeechRecognitionBubbleBase(web_contents), delegate_(delegate), bubble_(NULL), element_rect_(element_rect), @@ -93,7 +93,7 @@ SpeechInputBubbleGtk::SpeechInputBubbleGtk(WebContents* web_contents, mic_settings_(NULL) { } -SpeechInputBubbleGtk::~SpeechInputBubbleGtk() { +SpeechRecognitionBubbleGtk::~SpeechRecognitionBubbleGtk() { // The |Close| call below invokes our |BubbleClosing| method. Since we were // destroyed by the caller we don't need to call them back, hence set this // flag here. @@ -101,20 +101,20 @@ SpeechInputBubbleGtk::~SpeechInputBubbleGtk() { Hide(); } -void SpeechInputBubbleGtk::OnCancelClicked(GtkWidget* widget) { +void SpeechRecognitionBubbleGtk::OnCancelClicked(GtkWidget* widget) { delegate_->InfoBubbleButtonClicked(BUTTON_CANCEL); } -void SpeechInputBubbleGtk::OnTryAgainClicked(GtkWidget* widget) { +void SpeechRecognitionBubbleGtk::OnTryAgainClicked(GtkWidget* widget) { delegate_->InfoBubbleButtonClicked(BUTTON_TRY_AGAIN); } -void SpeechInputBubbleGtk::OnMicSettingsClicked(GtkWidget* widget) { - content::SpeechInputManager::GetInstance()->ShowAudioInputSettings(); +void SpeechRecognitionBubbleGtk::OnMicSettingsClicked(GtkWidget* widget) { + content::SpeechRecognitionManager::GetInstance()->ShowAudioInputSettings(); Hide(); } -void SpeechInputBubbleGtk::Show() { +void SpeechRecognitionBubbleGtk::Show() { if (bubble_) return; // Nothing further to do since the bubble is already visible. @@ -206,12 +206,12 @@ void SpeechInputBubbleGtk::Show() { UpdateLayout(); } -void SpeechInputBubbleGtk::Hide() { +void SpeechRecognitionBubbleGtk::Hide() { if (bubble_) bubble_->Close(); } -void SpeechInputBubbleGtk::UpdateLayout() { +void SpeechRecognitionBubbleGtk::UpdateLayout() { if (!bubble_) return; @@ -273,7 +273,7 @@ void SpeechInputBubbleGtk::UpdateLayout() { } } -void SpeechInputBubbleGtk::UpdateImage() { +void SpeechRecognitionBubbleGtk::UpdateImage() { SkBitmap image = icon_image(); if (image.isNull() || !bubble_) return; @@ -283,8 +283,8 @@ void SpeechInputBubbleGtk::UpdateImage() { g_object_unref(pixbuf); } -void SpeechInputBubbleGtk::BubbleClosing(BubbleGtk* bubble, - bool closed_by_escape) { +void SpeechRecognitionBubbleGtk::BubbleClosing(BubbleGtk* bubble, + bool closed_by_escape) { bubble_ = NULL; if (!did_invoke_close_) delegate_->InfoBubbleFocusChanged(); @@ -292,9 +292,9 @@ void SpeechInputBubbleGtk::BubbleClosing(BubbleGtk* bubble, } // namespace -SpeechInputBubble* SpeechInputBubble::CreateNativeBubble( +SpeechRecognitionBubble* SpeechRecognitionBubble::CreateNativeBubble( WebContents* web_contents, Delegate* delegate, const gfx::Rect& element_rect) { - return new SpeechInputBubbleGtk(web_contents, delegate, element_rect); + return new SpeechRecognitionBubbleGtk(web_contents, delegate, element_rect); } diff --git a/chrome/browser/speech/speech_input_bubble_mac.mm b/chrome/browser/speech/speech_recognition_bubble_mac.mm index 53ea4b6..d8a7cbc 100644 --- a/chrome/browser/speech/speech_input_bubble_mac.mm +++ b/chrome/browser/speech/speech_recognition_bubble_mac.mm @@ -4,14 +4,14 @@ #import <Cocoa/Cocoa.h> -#include "chrome/browser/speech/speech_input_bubble.h" +#include "chrome/browser/speech/speech_recognition_bubble.h" #import "base/memory/scoped_nsobject.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" #include "chrome/browser/ui/cocoa/browser_window_controller.h" #include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" -#import "chrome/browser/ui/cocoa/speech_input_window_controller.h" +#import "chrome/browser/ui/cocoa/speech_recognition_window_controller.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_view.h" #include "skia/ext/skia_utils_mac.h" @@ -21,44 +21,45 @@ using content::WebContents; namespace { // A class to bridge between the speech recognition C++ code and the Objective-C -// bubble implementation. See chrome/browser/speech/speech_input_bubble.h for -// more information on how this gets used. -class SpeechInputBubbleImpl : public SpeechInputBubbleBase { +// bubble implementation. See chrome/browser/speech/speech_recognition_bubble.h +// for more information on how this gets used. +class SpeechRecognitionBubbleImpl : public SpeechRecognitionBubbleBase { public: - SpeechInputBubbleImpl(WebContents* web_contents, + SpeechRecognitionBubbleImpl(WebContents* web_contents, Delegate* delegate, const gfx::Rect& element_rect); - virtual ~SpeechInputBubbleImpl(); + virtual ~SpeechRecognitionBubbleImpl(); virtual void Show(); virtual void Hide(); virtual void UpdateLayout(); virtual void UpdateImage(); private: - scoped_nsobject<SpeechInputWindowController> window_; + scoped_nsobject<SpeechRecognitionWindowController> window_; Delegate* delegate_; gfx::Rect element_rect_; }; -SpeechInputBubbleImpl::SpeechInputBubbleImpl(WebContents* web_contents, - Delegate* delegate, - const gfx::Rect& element_rect) - : SpeechInputBubbleBase(web_contents), +SpeechRecognitionBubbleImpl::SpeechRecognitionBubbleImpl( + WebContents* web_contents, + Delegate* delegate, + const gfx::Rect& element_rect) + : SpeechRecognitionBubbleBase(web_contents), delegate_(delegate), element_rect_(element_rect) { } -SpeechInputBubbleImpl::~SpeechInputBubbleImpl() { +SpeechRecognitionBubbleImpl::~SpeechRecognitionBubbleImpl() { if (window_.get()) [window_.get() close]; } -void SpeechInputBubbleImpl::UpdateImage() { +void SpeechRecognitionBubbleImpl::UpdateImage() { if (window_.get()) [window_.get() setImage:gfx::SkBitmapToNSImage(icon_image())]; } -void SpeechInputBubbleImpl::Show() { +void SpeechRecognitionBubbleImpl::Show() { if (window_.get()) { [window_.get() show]; return; @@ -88,7 +89,7 @@ void SpeechInputBubbleImpl::Show() { anchor = [view convertPoint:anchor toView:nil]; anchor = [[view window] convertBaseToScreen:anchor]; - window_.reset([[SpeechInputWindowController alloc] + window_.reset([[SpeechRecognitionWindowController alloc] initWithParentWindow:parentWindow delegate:delegate_ anchoredAt:anchor]); @@ -97,7 +98,7 @@ void SpeechInputBubbleImpl::Show() { [window_.get() show]; } -void SpeechInputBubbleImpl::Hide() { +void SpeechRecognitionBubbleImpl::Hide() { if (!window_.get()) return; @@ -105,7 +106,7 @@ void SpeechInputBubbleImpl::Hide() { window_.reset(); } -void SpeechInputBubbleImpl::UpdateLayout() { +void SpeechRecognitionBubbleImpl::UpdateLayout() { if (!window_.get()) return; @@ -116,10 +117,10 @@ void SpeechInputBubbleImpl::UpdateLayout() { } // namespace -SpeechInputBubble* SpeechInputBubble::CreateNativeBubble( +SpeechRecognitionBubble* SpeechRecognitionBubble::CreateNativeBubble( WebContents* web_contents, Delegate* delegate, const gfx::Rect& element_rect) { - return new SpeechInputBubbleImpl(web_contents, delegate, element_rect); + return new SpeechRecognitionBubbleImpl(web_contents, delegate, element_rect); } diff --git a/chrome/browser/speech/speech_input_bubble_views.cc b/chrome/browser/speech/speech_recognition_bubble_views.cc index aa2a109..cb27738 100644 --- a/chrome/browser/speech/speech_input_bubble_views.cc +++ b/chrome/browser/speech/speech_recognition_bubble_views.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/speech/speech_input_bubble.h" +#include "chrome/browser/speech/speech_recognition_bubble.h" #include <algorithm> @@ -13,7 +13,7 @@ #include "chrome/browser/ui/views/toolbar_view.h" #include "chrome/browser/ui/views/window.h" #include "content/public/browser/resource_context.h" -#include "content/public/browser/speech_input_manager.h" +#include "content/public/browser/speech_recognition_manager.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_view.h" #include "grit/generated_resources.h" @@ -38,18 +38,18 @@ const int kBubbleHeadingVertMargin = 6; const int kIconHorizontalOffset = 27; const int kIconVerticalOffset = -7; -// This is the SpeechInputBubble content and views bubble delegate. -class SpeechInputBubbleView +// This is the SpeechRecognitionBubble content and views bubble delegate. +class SpeechRecognitionBubbleView : public views::BubbleDelegateView, public views::ButtonListener, public views::LinkListener { public: - SpeechInputBubbleView(SpeechInputBubbleDelegate* delegate, - views::View* anchor_view, - const gfx::Rect& element_rect, - WebContents* web_contents); + SpeechRecognitionBubbleView(SpeechRecognitionBubbleDelegate* delegate, + views::View* anchor_view, + const gfx::Rect& element_rect, + WebContents* web_contents); - void UpdateLayout(SpeechInputBubbleBase::DisplayMode mode, + void UpdateLayout(SpeechRecognitionBubbleBase::DisplayMode mode, const string16& message_text, const SkBitmap& image); void SetImage(const SkBitmap& image); @@ -76,7 +76,7 @@ class SpeechInputBubbleView } private: - SpeechInputBubbleDelegate* delegate_; + SpeechRecognitionBubbleDelegate* delegate_; gfx::Rect element_rect_; WebContents* web_contents_; bool notify_delegate_on_activation_change_; @@ -86,14 +86,14 @@ class SpeechInputBubbleView views::TextButton* try_again_; views::TextButton* cancel_; views::Link* mic_settings_; - SpeechInputBubbleBase::DisplayMode display_mode_; + SpeechRecognitionBubbleBase::DisplayMode display_mode_; const int kIconLayoutMinWidth; - DISALLOW_COPY_AND_ASSIGN(SpeechInputBubbleView); + DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionBubbleView); }; -SpeechInputBubbleView::SpeechInputBubbleView( - SpeechInputBubbleDelegate* delegate, +SpeechRecognitionBubbleView::SpeechRecognitionBubbleView( + SpeechRecognitionBubbleDelegate* delegate, views::View* anchor_view, const gfx::Rect& element_rect, WebContents* web_contents) @@ -108,7 +108,7 @@ SpeechInputBubbleView::SpeechInputBubbleView( try_again_(NULL), cancel_(NULL), mic_settings_(NULL), - display_mode_(SpeechInputBubbleBase::DISPLAY_MODE_WARM_UP), + display_mode_(SpeechRecognitionBubbleBase::DISPLAY_MODE_WARM_UP), kIconLayoutMinWidth(ResourceBundle::GetSharedInstance().GetBitmapNamed( IDR_SPEECH_INPUT_MIC_EMPTY)->width()) { // The bubble lifetime is managed by its controller; closing on escape or @@ -117,14 +117,14 @@ SpeechInputBubbleView::SpeechInputBubbleView( set_close_on_deactivate(false); } -void SpeechInputBubbleView::OnWidgetActivationChanged(views::Widget* widget, - bool active) { +void SpeechRecognitionBubbleView::OnWidgetActivationChanged( + views::Widget* widget, bool active) { if (widget == GetWidget() && !active && notify_delegate_on_activation_change_) delegate_->InfoBubbleFocusChanged(); BubbleDelegateView::OnWidgetActivationChanged(widget, active); } -gfx::Rect SpeechInputBubbleView::GetAnchorRect() { +gfx::Rect SpeechRecognitionBubbleView::GetAnchorRect() { gfx::Rect container_rect; web_contents_->GetContainerBounds(&container_rect); gfx::Rect anchor(element_rect_); @@ -134,7 +134,7 @@ gfx::Rect SpeechInputBubbleView::GetAnchorRect() { return anchor; } -void SpeechInputBubbleView::Init() { +void SpeechRecognitionBubbleView::Init() { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); const gfx::Font& font = rb.GetFont(ResourceBundle::MediumFont); @@ -172,18 +172,20 @@ void SpeechInputBubbleView::Init() { AddChildView(mic_settings_); } -void SpeechInputBubbleView::UpdateLayout( - SpeechInputBubbleBase::DisplayMode mode, +void SpeechRecognitionBubbleView::UpdateLayout( + SpeechRecognitionBubbleBase::DisplayMode mode, const string16& message_text, const SkBitmap& image) { display_mode_ = mode; - bool is_message = (mode == SpeechInputBubbleBase::DISPLAY_MODE_MESSAGE); + bool is_message = (mode == SpeechRecognitionBubbleBase::DISPLAY_MODE_MESSAGE); icon_->SetVisible(!is_message); message_->SetVisible(is_message); mic_settings_->SetVisible(is_message); try_again_->SetVisible(is_message); - cancel_->SetVisible(mode != SpeechInputBubbleBase::DISPLAY_MODE_WARM_UP); - heading_->SetVisible(mode == SpeechInputBubbleBase::DISPLAY_MODE_RECORDING); + cancel_->SetVisible( + mode != SpeechRecognitionBubbleBase::DISPLAY_MODE_WARM_UP); + heading_->SetVisible( + mode == SpeechRecognitionBubbleBase::DISPLAY_MODE_RECORDING); // Clickable elements should be enabled if and only if they are visible. mic_settings_->SetEnabled(mic_settings_->visible()); @@ -208,27 +210,29 @@ void SpeechInputBubbleView::UpdateLayout( SizeToContents(); } -void SpeechInputBubbleView::SetImage(const SkBitmap& image) { +void SpeechRecognitionBubbleView::SetImage(const SkBitmap& image) { icon_->SetImage(image); } -void SpeechInputBubbleView::ButtonPressed(views::Button* source, - const views::Event& event) { +void SpeechRecognitionBubbleView::ButtonPressed(views::Button* source, + const views::Event& event) { if (source == cancel_) { - delegate_->InfoBubbleButtonClicked(SpeechInputBubble::BUTTON_CANCEL); + delegate_->InfoBubbleButtonClicked(SpeechRecognitionBubble::BUTTON_CANCEL); } else if (source == try_again_) { - delegate_->InfoBubbleButtonClicked(SpeechInputBubble::BUTTON_TRY_AGAIN); + delegate_->InfoBubbleButtonClicked( + SpeechRecognitionBubble::BUTTON_TRY_AGAIN); } else { NOTREACHED() << "Unknown button"; } } -void SpeechInputBubbleView::LinkClicked(views::Link* source, int event_flags) { +void SpeechRecognitionBubbleView::LinkClicked(views::Link* source, + int event_flags) { DCHECK_EQ(source, mic_settings_); - content::SpeechInputManager::GetInstance()->ShowAudioInputSettings(); + content::SpeechRecognitionManager::GetInstance()->ShowAudioInputSettings(); } -gfx::Size SpeechInputBubbleView::GetPreferredSize() { +gfx::Size SpeechRecognitionBubbleView::GetPreferredSize() { int width = heading_->GetPreferredSize().width(); int control_width = cancel_->GetPreferredSize().width(); if (try_again_->visible()) { @@ -261,7 +265,7 @@ gfx::Size SpeechInputBubbleView::GetPreferredSize() { return gfx::Size(width, height); } -void SpeechInputBubbleView::Layout() { +void SpeechRecognitionBubbleView::Layout() { int x = kBubbleHorizMargin; int y = kBubbleVertMargin; int available_width = width() - kBubbleHorizMargin * 2; @@ -292,7 +296,7 @@ void SpeechInputBubbleView::Layout() { DCHECK(icon_->visible()); int control_height = icon_->GetImage().height(); - if (display_mode_ == SpeechInputBubbleBase::DISPLAY_MODE_WARM_UP) + if (display_mode_ == SpeechRecognitionBubbleBase::DISPLAY_MODE_WARM_UP) y = (available_height - control_height) / 2; icon_->SetBounds(x, y, available_width, control_height); y += control_height; @@ -312,47 +316,47 @@ void SpeechInputBubbleView::Layout() { } } -// Implementation of SpeechInputBubble. -class SpeechInputBubbleImpl : public SpeechInputBubbleBase { +// Implementation of SpeechRecognitionBubble. +class SpeechRecognitionBubbleImpl : public SpeechRecognitionBubbleBase { public: - SpeechInputBubbleImpl(WebContents* web_contents, + SpeechRecognitionBubbleImpl(WebContents* web_contents, Delegate* delegate, const gfx::Rect& element_rect); - virtual ~SpeechInputBubbleImpl(); + virtual ~SpeechRecognitionBubbleImpl(); - // SpeechInputBubble methods. + // SpeechRecognitionBubble methods. virtual void Show() OVERRIDE; virtual void Hide() OVERRIDE; - // SpeechInputBubbleBase methods. + // SpeechRecognitionBubbleBase methods. virtual void UpdateLayout() OVERRIDE; virtual void UpdateImage() OVERRIDE; private: Delegate* delegate_; - SpeechInputBubbleView* bubble_; + SpeechRecognitionBubbleView* bubble_; gfx::Rect element_rect_; - DISALLOW_COPY_AND_ASSIGN(SpeechInputBubbleImpl); + DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionBubbleImpl); }; -SpeechInputBubbleImpl::SpeechInputBubbleImpl(WebContents* web_contents, - Delegate* delegate, - const gfx::Rect& element_rect) - : SpeechInputBubbleBase(web_contents), +SpeechRecognitionBubbleImpl::SpeechRecognitionBubbleImpl( + WebContents* web_contents, Delegate* delegate, + const gfx::Rect& element_rect) + : SpeechRecognitionBubbleBase(web_contents), delegate_(delegate), bubble_(NULL), element_rect_(element_rect) { } -SpeechInputBubbleImpl::~SpeechInputBubbleImpl() { +SpeechRecognitionBubbleImpl::~SpeechRecognitionBubbleImpl() { if (bubble_) { bubble_->set_notify_delegate_on_activation_change(false); bubble_->GetWidget()->Close(); } } -void SpeechInputBubbleImpl::Show() { +void SpeechRecognitionBubbleImpl::Show() { if (!bubble_) { // Anchor to the location icon view, in case |element_rect| is offscreen. Browser* browser = Browser::GetOrCreateTabbedBrowser( @@ -360,34 +364,34 @@ void SpeechInputBubbleImpl::Show() { BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); views::View* icon = browser_view->GetLocationBarView() ? browser_view->GetLocationBarView()->location_icon_view() : NULL; - bubble_ = new SpeechInputBubbleView(delegate_, icon, element_rect_, - web_contents()); + bubble_ = new SpeechRecognitionBubbleView(delegate_, icon, element_rect_, + web_contents()); browser::CreateViewsBubble(bubble_); UpdateLayout(); } bubble_->Show(); } -void SpeechInputBubbleImpl::Hide() { +void SpeechRecognitionBubbleImpl::Hide() { if (bubble_) bubble_->GetWidget()->Hide(); } -void SpeechInputBubbleImpl::UpdateLayout() { +void SpeechRecognitionBubbleImpl::UpdateLayout() { if (bubble_) bubble_->UpdateLayout(display_mode(), message_text(), icon_image()); } -void SpeechInputBubbleImpl::UpdateImage() { +void SpeechRecognitionBubbleImpl::UpdateImage() { if (bubble_) bubble_->SetImage(icon_image()); } } // namespace -SpeechInputBubble* SpeechInputBubble::CreateNativeBubble( +SpeechRecognitionBubble* SpeechRecognitionBubble::CreateNativeBubble( WebContents* web_contents, - SpeechInputBubble::Delegate* delegate, + SpeechRecognitionBubble::Delegate* delegate, const gfx::Rect& element_rect) { - return new SpeechInputBubbleImpl(web_contents, delegate, element_rect); + return new SpeechRecognitionBubbleImpl(web_contents, delegate, element_rect); } diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index 91b6908..2bf2ebe 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -68,7 +68,7 @@ #include "content/public/browser/notification_service.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/render_widget_host_view.h" -#include "content/public/browser/speech_input_preferences.h" +#include "content/public/browser/speech_recognition_preferences.h" #include "content/public/browser/user_metrics.h" #include "content/public/browser/web_contents.h" #include "content/public/common/content_restriction.h" @@ -1415,7 +1415,7 @@ bool RenderViewContextMenu::IsCommandIdChecked(int id) const { // Check box for menu item 'Block offensive words'. if (id == IDC_CONTENT_CONTEXT_SPEECH_INPUT_FILTER_PROFANITIES) { return profile_->GetPrefs()->GetBoolean( - prefs::kSpeechInputFilterProfanities); + prefs::kSpeechRecognitionFilterProfanities); } return false; @@ -1851,9 +1851,9 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) { case IDC_CONTENT_CONTEXT_SPEECH_INPUT_FILTER_PROFANITIES: { PrefService* prefs = profile_->GetPrefs(); const bool filter = !prefs->GetBoolean( - prefs::kSpeechInputFilterProfanities); - prefs->SetBoolean(prefs::kSpeechInputFilterProfanities, filter); - profile_->GetSpeechInputPreferences()->SetFilterProfanities(filter); + prefs::kSpeechRecognitionFilterProfanities); + prefs->SetBoolean(prefs::kSpeechRecognitionFilterProfanities, filter); + profile_->GetSpeechRecognitionPreferences()->SetFilterProfanities(filter); break; } diff --git a/chrome/browser/ui/cocoa/speech_input_window_controller.h b/chrome/browser/ui/cocoa/speech_recognition_window_controller.h index c472ecc..5227dc94 100644 --- a/chrome/browser/ui/cocoa/speech_input_window_controller.h +++ b/chrome/browser/ui/cocoa/speech_recognition_window_controller.h @@ -1,22 +1,22 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_COCOA_SPEECH_INPUT_WINDOW_CONTROLLER_H_ -#define CHROME_BROWSER_UI_COCOA_SPEECH_INPUT_WINDOW_CONTROLLER_H_ +#ifndef CHROME_BROWSER_UI_COCOA_SPEECH_RECOGNITION_WINDOW_CONTROLLER_H_ +#define CHROME_BROWSER_UI_COCOA_SPEECH_RECOGNITION_WINDOW_CONTROLLER_H_ #pragma once #import <Cocoa/Cocoa.h> -#include "chrome/browser/speech/speech_input_bubble.h" +#include "chrome/browser/speech/speech_recognition_bubble.h" #include "chrome/browser/ui/cocoa/base_bubble_controller.h" -// Controller for the speech input bubble window. This bubble window gets +// Controller for the speech recognition bubble window. This bubble window gets // displayed when the user starts speech input in a html input element. -@interface SpeechInputWindowController : BaseBubbleController { +@interface SpeechRecognitionWindowController : BaseBubbleController { @private - SpeechInputBubble::Delegate* delegate_; // weak. - SpeechInputBubbleBase::DisplayMode displayMode_; + SpeechRecognitionBubble::Delegate* delegate_; // weak. + SpeechRecognitionBubbleBase::DisplayMode displayMode_; // References below are weak, being obtained from the nib. IBOutlet NSImageView* iconImage_; @@ -28,7 +28,7 @@ // Initialize the window. |anchoredAt| is in screen coordinates. - (id)initWithParentWindow:(NSWindow*)parentWindow - delegate:(SpeechInputBubbleDelegate*)delegate + delegate:(SpeechRecognitionBubbleDelegate*)delegate anchoredAt:(NSPoint)anchoredAt; // Handler for the cancel button. @@ -41,23 +41,23 @@ - (IBAction)micSettings:(id)sender; // Updates the UI with data related to the given display mode. -- (void)updateLayout:(SpeechInputBubbleBase::DisplayMode)mode +- (void)updateLayout:(SpeechRecognitionBubbleBase::DisplayMode)mode messageText:(const string16&)messageText iconImage:(NSImage*)iconImage; -// Makes the speech input bubble visible on screen. +// Makes the speech recognition bubble visible on screen. - (void)show; -// Hides the speech input bubble away from screen. This does NOT release the -// controller and the window. +// Hides the speech recognition bubble away from screen. This does NOT release +// the controller and the window. - (void)hide; // Sets the image to be displayed in the bubble's status ImageView. A future // call to updateLayout may change the image. // TODO(satish): Clean that up and move it into the platform independent -// SpeechInputBubbleBase class. +// SpeechRecognitionBubbleBase class. - (void)setImage:(NSImage*)image; @end -#endif // CHROME_BROWSER_UI_COCOA_SPEECH_INPUT_WINDOW_CONTROLLER_H_ +#endif // CHROME_BROWSER_UI_COCOA_SPEECH_RECOGNITION_WINDOW_CONTROLLER_H_ diff --git a/chrome/browser/ui/cocoa/speech_input_window_controller.mm b/chrome/browser/ui/cocoa/speech_recognition_window_controller.mm index d692f6e..e5206a7 100644 --- a/chrome/browser/ui/cocoa/speech_input_window_controller.mm +++ b/chrome/browser/ui/cocoa/speech_recognition_window_controller.mm @@ -1,8 +1,8 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import "speech_input_window_controller.h" +#import "speech_recognition_window_controller.h" #include "base/logging.h" #include "base/sys_string_conversions.h" @@ -19,23 +19,23 @@ const int kBubbleControlVerticalSpacing = 10; // Space between controls. const int kBubbleHorizontalMargin = 5; // Space on either sides of controls. const int kInstructionLabelMaxWidth = 150; -@interface SpeechInputWindowController (Private) +@interface SpeechRecognitionWindowController (Private) - (NSSize)calculateContentSize; - (void)layout:(NSSize)size; @end -@implementation SpeechInputWindowController +@implementation SpeechRecognitionWindowController - (id)initWithParentWindow:(NSWindow*)parentWindow - delegate:(SpeechInputBubbleDelegate*)delegate + delegate:(SpeechRecognitionBubbleDelegate*)delegate anchoredAt:(NSPoint)anchoredAt { anchoredAt.y += info_bubble::kBubbleArrowHeight / 2.0; - if ((self = [super initWithWindowNibPath:@"SpeechInputBubble" + if ((self = [super initWithWindowNibPath:@"SpeechRecognitionBubble" parentWindow:parentWindow anchoredAt:anchoredAt])) { DCHECK(delegate); delegate_ = delegate; - displayMode_ = SpeechInputBubbleBase::DISPLAY_MODE_WARM_UP; + displayMode_ = SpeechRecognitionBubbleBase::DISPLAY_MODE_WARM_UP; } return self; } @@ -46,11 +46,11 @@ const int kInstructionLabelMaxWidth = 150; } - (IBAction)cancel:(id)sender { - delegate_->InfoBubbleButtonClicked(SpeechInputBubble::BUTTON_CANCEL); + delegate_->InfoBubbleButtonClicked(SpeechRecognitionBubble::BUTTON_CANCEL); } - (IBAction)tryAgain:(id)sender { - delegate_->InfoBubbleButtonClicked(SpeechInputBubble::BUTTON_TRY_AGAIN); + delegate_->InfoBubbleButtonClicked(SpeechRecognitionBubble::BUTTON_TRY_AGAIN); } - (IBAction)micSettings:(id)sender { @@ -76,7 +76,7 @@ const int kInstructionLabelMaxWidth = 150; // recording mode, so from warm up it can transition to recording without any // UI jank. bool isWarmUp = (displayMode_ == - SpeechInputBubbleBase::DISPLAY_MODE_WARM_UP); + SpeechRecognitionBubbleBase::DISPLAY_MODE_WARM_UP); if (![iconImage_ isHidden]) { NSSize size = [[iconImage_ image] size]; @@ -161,7 +161,7 @@ const int kInstructionLabelMaxWidth = 150; if (![iconImage_ isHidden]) { rect.size = [[iconImage_ image] size]; // In warm-up mode only the icon gets displayed so center it vertically. - if (displayMode_ == SpeechInputBubbleBase::DISPLAY_MODE_WARM_UP) + if (displayMode_ == SpeechRecognitionBubbleBase::DISPLAY_MODE_WARM_UP) y = (size.height - rect.size.height) / 2; rect.origin.x = (size.width - NSWidth(rect)) / 2; rect.origin.y = y; @@ -169,7 +169,7 @@ const int kInstructionLabelMaxWidth = 150; } } -- (void)updateLayout:(SpeechInputBubbleBase::DisplayMode)mode +- (void)updateLayout:(SpeechRecognitionBubbleBase::DisplayMode)mode messageText:(const string16&)messageText iconImage:(NSImage*)iconImage { // The very first time this method is called, the child views would still be @@ -177,9 +177,10 @@ const int kInstructionLabelMaxWidth = 150; // the child views properly so we can do the layout calculations below. NSWindow* window = [self window]; displayMode_ = mode; - BOOL is_message = (mode == SpeechInputBubbleBase::DISPLAY_MODE_MESSAGE); - BOOL is_recording = (mode == SpeechInputBubbleBase::DISPLAY_MODE_RECORDING); - BOOL is_warm_up = (mode == SpeechInputBubbleBase::DISPLAY_MODE_WARM_UP); + BOOL is_message = (mode == SpeechRecognitionBubbleBase::DISPLAY_MODE_MESSAGE); + BOOL is_recording = + (mode == SpeechRecognitionBubbleBase::DISPLAY_MODE_RECORDING); + BOOL is_warm_up = (mode == SpeechRecognitionBubbleBase::DISPLAY_MODE_WARM_UP); [iconImage_ setHidden:is_message]; [tryAgainButton_ setHidden:!is_message]; [micSettingsButton_ setHidden:!is_message]; @@ -223,4 +224,4 @@ const int kInstructionLabelMaxWidth = 150; [iconImage_ setImage:image]; } -@end // implementation SpeechInputWindowController +@end // implementation SpeechRecognitionWindowController diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index ddaebcd..b62a994 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2328,23 +2328,23 @@ 'browser/signin/ubertoken_fetcher.cc', 'browser/signin/ubertoken_fetcher.h', 'browser/simple_message_box.h', - 'browser/speech/chrome_speech_input_manager_delegate.cc', - 'browser/speech/chrome_speech_input_manager_delegate.h', - 'browser/speech/chrome_speech_input_preferences.cc', - 'browser/speech/chrome_speech_input_preferences.h', - 'browser/speech/speech_input_bubble.cc', - 'browser/speech/speech_input_bubble.h', - 'browser/speech/speech_input_bubble_controller.cc', - 'browser/speech/speech_input_bubble_controller.h', - 'browser/speech/speech_input_bubble_gtk.cc', - 'browser/speech/speech_input_bubble_mac.mm', - 'browser/speech/speech_input_bubble_views.cc', + 'browser/speech/chrome_speech_recognition_manager_delegate.cc', + 'browser/speech/chrome_speech_recognition_manager_delegate.h', + 'browser/speech/chrome_speech_recognition_preferences.cc', + 'browser/speech/chrome_speech_recognition_preferences.h', 'browser/speech/speech_input_extension_api.cc', 'browser/speech/speech_input_extension_api.h', 'browser/speech/speech_input_extension_manager.cc', 'browser/speech/speech_input_extension_manager.h', 'browser/speech/speech_input_extension_notification.cc', 'browser/speech/speech_input_extension_notification.h', + 'browser/speech/speech_recognition_bubble.cc', + 'browser/speech/speech_recognition_bubble.h', + 'browser/speech/speech_recognition_bubble_controller.cc', + 'browser/speech/speech_recognition_bubble_controller.h', + 'browser/speech/speech_recognition_bubble_gtk.cc', + 'browser/speech/speech_recognition_bubble_mac.mm', + 'browser/speech/speech_recognition_bubble_views.cc', 'browser/spellchecker/spellcheck_factory.cc', 'browser/spellchecker/spellcheck_factory.h', 'browser/spellchecker/spellcheck_host.cc', @@ -3016,8 +3016,8 @@ 'browser/ui/cocoa/restart_browser.mm', 'browser/ui/cocoa/select_file_dialog_mac.mm', 'browser/ui/cocoa/simple_message_box_mac.mm', - 'browser/ui/cocoa/speech_input_window_controller.h', - 'browser/ui/cocoa/speech_input_window_controller.mm', + 'browser/ui/cocoa/speech_recognition_window_controller.h', + 'browser/ui/cocoa/speech_recognition_window_controller.mm', 'browser/ui/cocoa/ssl_client_certificate_selector.mm', 'browser/ui/cocoa/status_bubble_mac.h', 'browser/ui/cocoa/status_bubble_mac.mm', @@ -4935,7 +4935,7 @@ 'app/nibs/MainMenu.xib', 'app/nibs/SadTab.xib', 'app/nibs/SaveAccessoryView.xib', - 'app/nibs/SpeechInputBubble.xib', + 'app/nibs/SpeechRecognitionBubble.xib', 'app/nibs/TaskManager.xib', 'app/nibs/Toolbar.xib', 'app/nibs/WrenchMenu.xib', @@ -5049,7 +5049,7 @@ ['exclude', '^browser/extensions/extension_rlz_module'], ['include', 'browser/printing/print_dialog_cloud.cc'], ['include', 'browser/printing/print_dialog_cloud.h'], - ['include', '^browser/speech/speech_input_bubble_views.cc'], + ['include', '^browser/speech/speech_recognition_bubble_views.cc'], # Exclude all of browser/ui/gtk, then include the things we want. ['exclude', '^browser/ui/gtk'], @@ -5339,7 +5339,7 @@ ['exclude', '^browser/extensions/extension_host_mac.mm'], ['exclude', '^browser/extensions/external_registry_extension_loader_win.cc'], ['exclude', '^browser/extensions/external_registry_extension_loader_win.h'], - ['exclude', '^browser/speech/speech_input_bubble_gtk.cc'], + ['exclude', '^browser/speech/speech_recognition_bubble_gtk.cc'], ['exclude', '^browser/tab_contents/render_view_context_menu_gtk.cc'], ['exclude', '^browser/tab_contents/render_view_context_menu_gtk.h'], ['exclude', '^browser/tab_contents/tab_contents_view_gtk.cc'], diff --git a/chrome/chrome_dll.gypi b/chrome/chrome_dll.gypi index db5160e..1c158d5 100644 --- a/chrome/chrome_dll.gypi +++ b/chrome/chrome_dll.gypi @@ -276,7 +276,7 @@ 'app/nibs/PreviewableContents.xib', 'app/nibs/SaveAccessoryView.xib', 'app/nibs/SadTab.xib', - 'app/nibs/SpeechInputBubble.xib', + 'app/nibs/SpeechRecognitionBubble.xib', 'app/nibs/TabView.xib', 'app/nibs/TaskManager.xib', 'app/nibs/Toolbar.xib', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index c06e2c2..34b128e 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1723,7 +1723,7 @@ 'browser/signin/token_service_unittest.cc', 'browser/signin/token_service_unittest.h', 'browser/signin/ubertoken_fetcher_unittest.cc', - 'browser/speech/speech_input_bubble_controller_unittest.cc', + 'browser/speech/speech_recognition_bubble_controller_unittest.cc', 'browser/spellchecker/spellcheck_platform_mac_unittest.cc', 'browser/spellchecker/spellcheck_profile_unittest.cc', 'browser/status_icons/status_icon_unittest.cc', @@ -2754,8 +2754,8 @@ 'browser/service/service_process_control_browsertest.cc', 'browser/sessions/session_restore_browsertest.cc', 'browser/sessions/tab_restore_service_browsertest.cc', - 'browser/speech/speech_input_bubble_browsertest.cc', 'browser/speech/speech_input_extension_apitest.cc', + 'browser/speech/speech_recognition_bubble_browsertest.cc', 'browser/spellchecker/spellcheck_host_browsertest.cc', 'browser/ssl/ssl_browser_tests.cc', 'browser/tab_contents/render_view_context_menu_browsertest.cc', @@ -2894,7 +2894,7 @@ '../content/browser/renderer_host/render_view_host_browsertest.cc', '../content/browser/renderer_host/render_view_host_manager_browsertest.cc', '../content/browser/renderer_host/resource_dispatcher_host_browsertest.cc', - '../content/browser/speech/speech_input_browsertest.cc', + '../content/browser/speech/speech_recognition_browsertest.cc', '../content/browser/webkit_browsertest.cc', '../content/renderer/mouse_lock_dispatcher_browsertest.cc', '../content/renderer/render_view_browsertest.cc', diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 9401963..8d1cc80 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -691,7 +691,7 @@ const char kEnableAutoSpellCorrect[] = "browser.enable_autospellcorrect"; // Boolean pref to define the default setting for "block offensive words". // The old key value is kept to avoid unnecessary migration code. -const char kSpeechInputFilterProfanities[] = +const char kSpeechRecognitionFilterProfanities[] = "browser.speechinput_censor_results"; // Boolean pref to determine if the tray notification balloon for speech input diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index bc6e009..021fb2d4 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -250,8 +250,8 @@ extern const char kDeleteCookies[]; extern const char kDeletePasswords[]; extern const char kDeleteFormData[]; extern const char kEnableSpellCheck[]; -extern const char kSpeechInputFilterProfanities[]; extern const char kSpeechInputTrayNotificationShown[]; +extern const char kSpeechRecognitionFilterProfanities[]; extern const char kEnabledLabsExperiments[]; extern const char kEnableAutoSpellCorrect[]; extern const char kSavingBrowserHistoryDisabled[]; diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc index 54d7605..930fa98a 100644 --- a/chrome/test/base/testing_profile.cc +++ b/chrome/test/base/testing_profile.cc @@ -36,7 +36,7 @@ #include "chrome/browser/search_engines/template_url_service.h" #include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/browser/signin/token_service.h" -#include "chrome/browser/speech/chrome_speech_input_preferences.h" +#include "chrome/browser/speech/chrome_speech_recognition_preferences.h" #include "chrome/browser/sync/profile_sync_service_mock.h" #include "chrome/browser/ui/webui/chrome_url_data_manager.h" #include "chrome/common/chrome_constants.h" @@ -651,11 +651,13 @@ TestingProfile::GetGeolocationPermissionContext() { return geolocation_permission_context_.get(); } -content::SpeechInputPreferences* TestingProfile::GetSpeechInputPreferences() { +content::SpeechRecognitionPreferences* + TestingProfile::GetSpeechRecognitionPreferences() { #if defined(ENABLE_INPUT_SPEECH) - if (!speech_input_preferences_.get()) - speech_input_preferences_ = new ChromeSpeechInputPreferences(GetPrefs()); - return speech_input_preferences_.get(); + if (!speech_recognition_preferences_.get()) + speech_recognition_preferences_ = + new ChromeSpeechRecognitionPreferences(GetPrefs()); + return speech_recognition_preferences_.get(); #else return NULL; #endif diff --git a/chrome/test/base/testing_profile.h b/chrome/test/base/testing_profile.h index 0ba2120..1088970 100644 --- a/chrome/test/base/testing_profile.h +++ b/chrome/test/base/testing_profile.h @@ -17,7 +17,7 @@ namespace content { class MockResourceContext; -class SpeechInputPreferences; +class SpeechRecognitionPreferences; } namespace history { @@ -165,7 +165,8 @@ class TestingProfile : public Profile { virtual content::ResourceContext* GetResourceContext() OVERRIDE; virtual content::GeolocationPermissionContext* GetGeolocationPermissionContext() OVERRIDE; - virtual content::SpeechInputPreferences* GetSpeechInputPreferences() OVERRIDE; + virtual content::SpeechRecognitionPreferences* + GetSpeechRecognitionPreferences() OVERRIDE; virtual bool DidLastSessionExitCleanly() OVERRIDE; virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; @@ -351,7 +352,8 @@ class TestingProfile : public Profile { scoped_refptr<content::GeolocationPermissionContext> geolocation_permission_context_; - scoped_refptr<content::SpeechInputPreferences> speech_input_preferences_; + scoped_refptr<content::SpeechRecognitionPreferences> + speech_recognition_preferences_; FilePath last_selected_directory_; scoped_refptr<history::TopSites> top_sites_; // For history and thumbnails. diff --git a/content/browser/mock_content_browser_client.cc b/content/browser/mock_content_browser_client.cc index 0de277c..395ade5 100644 --- a/content/browser/mock_content_browser_client.cc +++ b/content/browser/mock_content_browser_client.cc @@ -251,8 +251,8 @@ std::string MockContentBrowserClient::GetWorkerProcessTitle( void MockContentBrowserClient::ResourceDispatcherHostCreated() { } -SpeechInputManagerDelegate* - MockContentBrowserClient::GetSpeechInputManagerDelegate() { +SpeechRecognitionManagerDelegate* + MockContentBrowserClient::GetSpeechRecognitionManagerDelegate() { return NULL; } diff --git a/content/browser/mock_content_browser_client.h b/content/browser/mock_content_browser_client.h index e1a523c..e6fe8cb 100644 --- a/content/browser/mock_content_browser_client.h +++ b/content/browser/mock_content_browser_client.h @@ -139,7 +139,8 @@ class MockContentBrowserClient : public ContentBrowserClient { virtual std::string GetWorkerProcessTitle(const GURL& url, ResourceContext* context) OVERRIDE; virtual void ResourceDispatcherHostCreated() OVERRIDE; - virtual SpeechInputManagerDelegate* GetSpeechInputManagerDelegate() OVERRIDE; + virtual SpeechRecognitionManagerDelegate* + GetSpeechRecognitionManagerDelegate() OVERRIDE; virtual ui::Clipboard* GetClipboard() OVERRIDE; virtual net::NetLog* GetNetLog() OVERRIDE; virtual AccessTokenStore* CreateAccessTokenStore() OVERRIDE; diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index f02f5b1..ed47da7 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -114,7 +114,7 @@ #endif #if defined(ENABLE_INPUT_SPEECH) -#include "content/browser/speech/speech_input_dispatcher_host.h" +#include "content/browser/speech/input_tag_speech_dispatcher_host.h" #endif #include "third_party/skia/include/core/SkBitmap.h" @@ -493,9 +493,9 @@ void RenderProcessHostImpl::CreateMessageFilters() { channel_->AddFilter(new PepperMessageFilter(PepperMessageFilter::RENDERER, GetID(), resource_context)); #if defined(ENABLE_INPUT_SPEECH) - channel_->AddFilter(new speech_input::SpeechInputDispatcherHost( + channel_->AddFilter(new speech::InputTagSpeechDispatcherHost( GetID(), browser_context->GetRequestContext(), - browser_context->GetSpeechInputPreferences(), + browser_context->GetSpeechRecognitionPreferences(), content::BrowserMainLoop::GetAudioManager())); #endif channel_->AddFilter(new FileAPIMessageFilter( diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc index 12d5e04..faf2a96 100644 --- a/content/browser/renderer_host/render_view_host_impl.cc +++ b/content/browser/renderer_host/render_view_host_impl.cc @@ -28,7 +28,7 @@ #include "content/common/accessibility_messages.h" #include "content/common/desktop_notification_messages.h" #include "content/common/drag_messages.h" -#include "content/common/speech_input_messages.h" +#include "content/common/speech_recognition_messages.h" #include "content/common/swapped_out_messages.h" #include "content/common/view_messages.h" #include "content/port/browser/render_widget_host_view_port.h" @@ -1405,7 +1405,7 @@ void RenderViewHostImpl::DidCancelPopupMenu() { #endif void RenderViewHostImpl::ToggleSpeechInput() { - Send(new SpeechInputMsg_ToggleSpeechInput(GetRoutingID())); + Send(new InputTagSpeechMsg_ToggleSpeechInput(GetRoutingID())); } void RenderViewHostImpl::FilterURL(ChildProcessSecurityPolicyImpl* policy, diff --git a/content/browser/speech/audio_encoder.cc b/content/browser/speech/audio_encoder.cc index 683ec0e..83e0475 100644 --- a/content/browser/speech/audio_encoder.cc +++ b/content/browser/speech/audio_encoder.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -21,7 +21,7 @@ namespace { const char* const kContentTypeFLAC = "audio/x-flac; rate="; const int kFLACCompressionLevel = 0; // 0 for speed -class FLACEncoder : public speech_input::AudioEncoder { +class FLACEncoder : public speech::AudioEncoder { public: FLACEncoder(int sampling_rate, int bits_per_sample); virtual ~FLACEncoder(); @@ -107,7 +107,7 @@ const int kMaxSpeexFrameLength = 110; // (44kbps rate sampled at 32kHz). // make sure it is within the byte range. COMPILE_ASSERT(kMaxSpeexFrameLength <= 0xFF, invalidLength); -class SpeexEncoder : public speech_input::AudioEncoder { +class SpeexEncoder : public speech::AudioEncoder { public: explicit SpeexEncoder(int sampling_rate); virtual ~SpeexEncoder(); @@ -163,7 +163,7 @@ void SpeexEncoder::Encode(const short* samples, int num_samples) { } // namespace -namespace speech_input { +namespace speech { AudioEncoder* AudioEncoder::Create(Codec codec, int sampling_rate, @@ -205,4 +205,4 @@ void AudioEncoder::AppendToBuffer(std::string* item) { audio_buffers_.push_back(item); } -} // namespace speech_input +} // namespace speech diff --git a/content/browser/speech/audio_encoder.h b/content/browser/speech/audio_encoder.h index 7b0a246..92bc645 100644 --- a/content/browser/speech/audio_encoder.h +++ b/content/browser/speech/audio_encoder.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,7 +10,7 @@ #include "base/basictypes.h" -namespace speech_input { +namespace speech { // Provides a simple interface to encode raw audio using the various speech // codecs. @@ -54,6 +54,6 @@ class AudioEncoder { DISALLOW_COPY_AND_ASSIGN(AudioEncoder); }; -} // namespace speech_input +} // namespace speech #endif // CONTENT_BROWSER_SPEECH_AUDIO_ENCODER_H_ diff --git a/content/browser/speech/endpointer/endpointer.cc b/content/browser/speech/endpointer/endpointer.cc index 69c79a6..fe3e0bf 100644 --- a/content/browser/speech/endpointer/endpointer.cc +++ b/content/browser/speech/endpointer/endpointer.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -12,7 +12,7 @@ namespace { static const int kFrameRate = 50; // 1 frame = 20ms of audio. } -namespace speech_input { +namespace speech { Endpointer::Endpointer(int sample_rate) : speech_input_possibly_complete_silence_length_us_(-1), diff --git a/content/browser/speech/endpointer/endpointer.h b/content/browser/speech/endpointer/endpointer.h index 2d74839..9ba2018 100644 --- a/content/browser/speech/endpointer/endpointer.h +++ b/content/browser/speech/endpointer/endpointer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -11,7 +11,7 @@ class EpStatus; -namespace speech_input { +namespace speech { // A simple interface to the underlying energy-endpointer implementation, this // class lets callers provide audio as being recorded and let them poll to find @@ -147,6 +147,6 @@ class CONTENT_EXPORT Endpointer { int32 frame_size_; }; -} // namespace speech_input +} // namespace speech #endif // CONTENT_BROWSER_SPEECH_ENDPOINTER_ENDPOINTER_H_ diff --git a/content/browser/speech/endpointer/endpointer_unittest.cc b/content/browser/speech/endpointer/endpointer_unittest.cc index b71c01a..240e5dc 100644 --- a/content/browser/speech/endpointer/endpointer_unittest.cc +++ b/content/browser/speech/endpointer/endpointer_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -15,7 +15,7 @@ const int kFrameSize = kSampleRate / kFrameRate; // 160 samples. COMPILE_ASSERT(kFrameSize == 160, invalid_frame_size); } -namespace speech_input { +namespace speech { class FrameProcessor { public: @@ -142,4 +142,4 @@ TEST(EndpointerTest, TestEmbeddedEndpointerEvents) { endpointer.EndSession(); } -} // namespace speech_input +} // namespace speech diff --git a/content/browser/speech/endpointer/energy_endpointer.cc b/content/browser/speech/endpointer/energy_endpointer.cc index 39cf617..b88d7a3 100644 --- a/content/browser/speech/endpointer/energy_endpointer.cc +++ b/content/browser/speech/endpointer/energy_endpointer.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -41,7 +41,7 @@ float GetDecibel(float value) { } // namespace -namespace speech_input { +namespace speech { // Stores threshold-crossing histories for making decisions about the speech // state. diff --git a/content/browser/speech/endpointer/energy_endpointer.h b/content/browser/speech/endpointer/energy_endpointer.h index b440c4d..9db927a 100644 --- a/content/browser/speech/endpointer/energy_endpointer.h +++ b/content/browser/speech/endpointer/energy_endpointer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -44,7 +44,7 @@ #include "content/browser/speech/endpointer/energy_endpointer_params.h" #include "content/common/content_export.h" -namespace speech_input { +namespace speech { // Endpointer status codes enum EpStatus { @@ -150,6 +150,6 @@ class CONTENT_EXPORT EnergyEndpointer { DISALLOW_COPY_AND_ASSIGN(EnergyEndpointer); }; -} // namespace speech_input +} // namespace speech #endif // CONTENT_BROWSER_SPEECH_ENDPOINTER_ENERGY_ENDPOINTER_H_ diff --git a/content/browser/speech/endpointer/energy_endpointer_params.cc b/content/browser/speech/endpointer/energy_endpointer_params.cc index e110b24..89852f1 100644 --- a/content/browser/speech/endpointer/energy_endpointer_params.cc +++ b/content/browser/speech/endpointer/energy_endpointer_params.cc @@ -1,10 +1,10 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "content/browser/speech/endpointer/energy_endpointer_params.h" -namespace speech_input { +namespace speech { EnergyEndpointerParams::EnergyEndpointerParams() { SetDefaults(); @@ -50,4 +50,4 @@ void EnergyEndpointerParams::operator=(const EnergyEndpointerParams& source) { contamination_rejection_period_ = source.contamination_rejection_period(); } -} // namespace speech_input +} // namespace speech diff --git a/content/browser/speech/endpointer/energy_endpointer_params.h b/content/browser/speech/endpointer/energy_endpointer_params.h index 5a3ea42..9641d9d 100644 --- a/content/browser/speech/endpointer/energy_endpointer_params.h +++ b/content/browser/speech/endpointer/energy_endpointer_params.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,7 +8,7 @@ #include "base/basictypes.h" #include "content/common/content_export.h" -namespace speech_input { +namespace speech { // Input parameters for the EnergyEndpointer class. class CONTENT_EXPORT EnergyEndpointerParams { @@ -133,6 +133,6 @@ class CONTENT_EXPORT EnergyEndpointerParams { float contamination_rejection_period_; }; -} // namespace speech_input +} // namespace speech #endif // CONTENT_BROWSER_SPEECH_ENDPOINTER_ENERGY_ENDPOINTER_PARAMS_H_ diff --git a/content/browser/speech/speech_input_dispatcher_host.cc b/content/browser/speech/input_tag_speech_dispatcher_host.cc index 3883969..7c10270 100644 --- a/content/browser/speech/speech_input_dispatcher_host.cc +++ b/content/browser/speech/input_tag_speech_dispatcher_host.cc @@ -2,24 +2,24 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/browser/speech/speech_input_dispatcher_host.h" +#include "content/browser/speech/input_tag_speech_dispatcher_host.h" #include "base/lazy_instance.h" -#include "content/browser/speech/speech_input_manager_impl.h" +#include "content/browser/speech/speech_recognition_manager_impl.h" #include "content/browser/speech/speech_recognizer_impl.h" -#include "content/common/speech_input_messages.h" -#include "content/public/browser/speech_input_preferences.h" +#include "content/common/speech_recognition_messages.h" +#include "content/public/browser/speech_recognition_preferences.h" using content::BrowserThread; -namespace speech_input { +namespace speech { -//----------------------------- SpeechInputCallers ----------------------------- +//----------------------------- Callers ----------------------------- // A singleton class to map the tuple // (render-process-id, render-view-id, requestid) to a single ID which is passed // through rest of the speech code. -class SpeechInputDispatcherHost::SpeechInputCallers { +class InputTagSpeechDispatcherHost::Callers { public: // Creates a new ID for a given tuple. int CreateId(int render_process_id, int render_view_id, int request_id); @@ -41,24 +41,24 @@ class SpeechInputDispatcherHost::SpeechInputCallers { int render_view_id; int request_id; }; - friend struct base::DefaultLazyInstanceTraits<SpeechInputCallers>; + friend struct base::DefaultLazyInstanceTraits<Callers>; - SpeechInputCallers(); + Callers(); std::map<int, CallerInfo> callers_; int next_id_; }; -static base::LazyInstance<SpeechInputDispatcherHost::SpeechInputCallers> - g_speech_input_callers = LAZY_INSTANCE_INITIALIZER; +static base::LazyInstance<InputTagSpeechDispatcherHost::Callers> + g_callers = LAZY_INSTANCE_INITIALIZER; -SpeechInputDispatcherHost::SpeechInputCallers::SpeechInputCallers() +InputTagSpeechDispatcherHost::Callers::Callers() : next_id_(1) { } -int SpeechInputDispatcherHost::SpeechInputCallers::GetId(int render_process_id, - int render_view_id, - int request_id) { +int InputTagSpeechDispatcherHost::Callers::GetId(int render_process_id, + int render_view_id, + int request_id) { for (std::map<int, CallerInfo>::iterator it = callers_.begin(); it != callers_.end(); it++) { const CallerInfo& item = it->second; @@ -76,10 +76,9 @@ int SpeechInputDispatcherHost::SpeechInputCallers::GetId(int render_process_id, return 0; } -int SpeechInputDispatcherHost::SpeechInputCallers::CreateId( - int render_process_id, - int render_view_id, - int request_id) { +int InputTagSpeechDispatcherHost::Callers::CreateId(int render_process_id, + int render_view_id, + int request_id) { CallerInfo info; info.render_process_id = render_process_id; info.render_view_id = render_view_id; @@ -88,46 +87,49 @@ int SpeechInputDispatcherHost::SpeechInputCallers::CreateId( return next_id_++; } -void SpeechInputDispatcherHost::SpeechInputCallers::RemoveId(int id) { +void InputTagSpeechDispatcherHost::Callers::RemoveId(int id) { callers_.erase(id); } -int SpeechInputDispatcherHost::SpeechInputCallers::render_process_id(int id) { +int InputTagSpeechDispatcherHost::Callers::render_process_id( + int id) { return callers_[id].render_process_id; } -int SpeechInputDispatcherHost::SpeechInputCallers::render_view_id(int id) { +int InputTagSpeechDispatcherHost::Callers::render_view_id( + int id) { return callers_[id].render_view_id; } -int SpeechInputDispatcherHost::SpeechInputCallers::request_id(int id) { +int InputTagSpeechDispatcherHost::Callers::request_id(int id) { return callers_[id].request_id; } -//-------------------------- SpeechInputDispatcherHost ------------------------- +//----------------------- InputTagSpeechDispatcherHost ---------------------- -SpeechInputManagerImpl* SpeechInputDispatcherHost::manager_; +SpeechRecognitionManagerImpl* InputTagSpeechDispatcherHost::manager_; -void SpeechInputDispatcherHost::set_manager(SpeechInputManagerImpl* manager) { +void InputTagSpeechDispatcherHost::set_manager( + SpeechRecognitionManagerImpl* manager) { manager_ = manager; } -SpeechInputDispatcherHost::SpeechInputDispatcherHost( +InputTagSpeechDispatcherHost::InputTagSpeechDispatcherHost( int render_process_id, net::URLRequestContextGetter* context_getter, - content::SpeechInputPreferences* speech_input_preferences, + content::SpeechRecognitionPreferences* recognition_preferences, AudioManager* audio_manager) : render_process_id_(render_process_id), may_have_pending_requests_(false), context_getter_(context_getter), - speech_input_preferences_(speech_input_preferences), + recognition_preferences_(recognition_preferences), audio_manager_(audio_manager) { // This is initialized by Browser. Do not add any non-trivial // initialization here, instead do it lazily when required (e.g. see the // method |manager()|) or add an Init() method. } -SpeechInputDispatcherHost::~SpeechInputDispatcherHost() { +InputTagSpeechDispatcherHost::~InputTagSpeechDispatcherHost() { // If the renderer crashed for some reason or if we didn't receive a proper // Cancel/Stop call for an existing session, cancel such active sessions now. // We first check if this dispatcher received any speech IPC requst so that @@ -137,27 +139,27 @@ SpeechInputDispatcherHost::~SpeechInputDispatcherHost() { manager()->CancelAllRequestsWithDelegate(this); } -SpeechInputManagerImpl* SpeechInputDispatcherHost::manager() { +SpeechRecognitionManagerImpl* InputTagSpeechDispatcherHost::manager() { if (manager_) return manager_; #if defined(ENABLE_INPUT_SPEECH) - return SpeechInputManagerImpl::GetInstance(); + return SpeechRecognitionManagerImpl::GetInstance(); #else return NULL; #endif } -bool SpeechInputDispatcherHost::OnMessageReceived( +bool InputTagSpeechDispatcherHost::OnMessageReceived( const IPC::Message& message, bool* message_was_ok) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); bool handled = true; - IPC_BEGIN_MESSAGE_MAP_EX(SpeechInputDispatcherHost, message, + IPC_BEGIN_MESSAGE_MAP_EX(InputTagSpeechDispatcherHost, message, *message_was_ok) - IPC_MESSAGE_HANDLER(SpeechInputHostMsg_StartRecognition, + IPC_MESSAGE_HANDLER(InputTagSpeechHostMsg_StartRecognition, OnStartRecognition) - IPC_MESSAGE_HANDLER(SpeechInputHostMsg_CancelRecognition, + IPC_MESSAGE_HANDLER(InputTagSpeechHostMsg_CancelRecognition, OnCancelRecognition) - IPC_MESSAGE_HANDLER(SpeechInputHostMsg_StopRecording, + IPC_MESSAGE_HANDLER(InputTagSpeechHostMsg_StopRecording, OnStopRecording) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -166,10 +168,10 @@ bool SpeechInputDispatcherHost::OnMessageReceived( return handled; } -void SpeechInputDispatcherHost::OnStartRecognition( - const SpeechInputHostMsg_StartRecognition_Params ¶ms) { +void InputTagSpeechDispatcherHost::OnStartRecognition( + const InputTagSpeechHostMsg_StartRecognition_Params ¶ms) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - int caller_id = g_speech_input_callers.Get().CreateId( + int caller_id = g_callers.Get().CreateId( render_process_id_, params.render_view_id, params.request_id); manager()->StartRecognition(this, caller_id, render_process_id_, @@ -177,63 +179,61 @@ void SpeechInputDispatcherHost::OnStartRecognition( params.language, params.grammar, params.origin_url, context_getter_.get(), - speech_input_preferences_.get()); + recognition_preferences_.get()); } -void SpeechInputDispatcherHost::OnCancelRecognition(int render_view_id, - int request_id) { - int caller_id = g_speech_input_callers.Get().GetId( +void InputTagSpeechDispatcherHost::OnCancelRecognition(int render_view_id, + int request_id) { + int caller_id = g_callers.Get().GetId( render_process_id_, render_view_id, request_id); if (caller_id) { manager()->CancelRecognition(caller_id); // Request sequence ended so remove mapping. - g_speech_input_callers.Get().RemoveId(caller_id); + g_callers.Get().RemoveId(caller_id); } } -void SpeechInputDispatcherHost::OnStopRecording(int render_view_id, - int request_id) { - int caller_id = g_speech_input_callers.Get().GetId( +void InputTagSpeechDispatcherHost::OnStopRecording(int render_view_id, + int request_id) { + int caller_id = g_callers.Get().GetId( render_process_id_, render_view_id, request_id); if (caller_id) manager()->StopRecording(caller_id); } -void SpeechInputDispatcherHost::SetRecognitionResult( - int caller_id, const content::SpeechInputResult& result) { - VLOG(1) << "SpeechInputDispatcherHost::SetRecognitionResult enter"; +void InputTagSpeechDispatcherHost::SetRecognitionResult( + int caller_id, const content::SpeechRecognitionResult& result) { + VLOG(1) << "InputTagSpeechDispatcherHost::SetRecognitionResult enter"; DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - int caller_render_view_id = - g_speech_input_callers.Get().render_view_id(caller_id); - int caller_request_id = g_speech_input_callers.Get().request_id(caller_id); - Send(new SpeechInputMsg_SetRecognitionResult(caller_render_view_id, - caller_request_id, - result)); - VLOG(1) << "SpeechInputDispatcherHost::SetRecognitionResult exit"; + int caller_render_view_id = g_callers.Get().render_view_id(caller_id); + int caller_request_id = g_callers.Get().request_id(caller_id); + Send(new InputTagSpeechMsg_SetRecognitionResult(caller_render_view_id, + caller_request_id, + result)); + VLOG(1) << "InputTagSpeechDispatcherHost::SetRecognitionResult exit"; } -void SpeechInputDispatcherHost::DidCompleteRecording(int caller_id) { - VLOG(1) << "SpeechInputDispatcherHost::DidCompleteRecording enter"; +void InputTagSpeechDispatcherHost::DidCompleteRecording(int caller_id) { + VLOG(1) << "InputTagSpeechDispatcherHost::DidCompleteRecording enter"; DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - int caller_render_view_id = - g_speech_input_callers.Get().render_view_id(caller_id); - int caller_request_id = g_speech_input_callers.Get().request_id(caller_id); - Send(new SpeechInputMsg_RecordingComplete(caller_render_view_id, - caller_request_id)); - VLOG(1) << "SpeechInputDispatcherHost::DidCompleteRecording exit"; + int caller_render_view_id = g_callers.Get().render_view_id(caller_id); + int caller_request_id = g_callers.Get().request_id(caller_id); + Send(new InputTagSpeechMsg_RecordingComplete(caller_render_view_id, + caller_request_id)); + VLOG(1) << "InputTagSpeechDispatcherHost::DidCompleteRecording exit"; } -void SpeechInputDispatcherHost::DidCompleteRecognition(int caller_id) { - VLOG(1) << "SpeechInputDispatcherHost::DidCompleteRecognition enter"; +void InputTagSpeechDispatcherHost::DidCompleteRecognition(int caller_id) { + VLOG(1) << "InputTagSpeechDispatcherHost::DidCompleteRecognition enter"; DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); int caller_render_view_id = - g_speech_input_callers.Get().render_view_id(caller_id); - int caller_request_id = g_speech_input_callers.Get().request_id(caller_id); - Send(new SpeechInputMsg_RecognitionComplete(caller_render_view_id, - caller_request_id)); + g_callers.Get().render_view_id(caller_id); + int caller_request_id = g_callers.Get().request_id(caller_id); + Send(new InputTagSpeechMsg_RecognitionComplete(caller_render_view_id, + caller_request_id)); // Request sequence ended, so remove mapping. - g_speech_input_callers.Get().RemoveId(caller_id); - VLOG(1) << "SpeechInputDispatcherHost::DidCompleteRecognition exit"; + g_callers.Get().RemoveId(caller_id); + VLOG(1) << "InputTagSpeechDispatcherHost::DidCompleteRecognition exit"; } -} // namespace speech_input +} // namespace speech diff --git a/content/browser/speech/input_tag_speech_dispatcher_host.h b/content/browser/speech/input_tag_speech_dispatcher_host.h new file mode 100644 index 0000000..61d68b0 --- /dev/null +++ b/content/browser/speech/input_tag_speech_dispatcher_host.h @@ -0,0 +1,78 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_BROWSER_SPEECH_INPUT_TAG_SPEECH_DISPATCHER_HOST_H_ +#define CONTENT_BROWSER_SPEECH_INPUT_TAG_SPEECH_DISPATCHER_HOST_H_ + +#include "base/memory/scoped_ptr.h" +#include "content/common/content_export.h" +#include "content/public/browser/browser_message_filter.h" +#include "net/url_request/url_request_context_getter.h" + +class AudioManager; +struct InputTagSpeechHostMsg_StartRecognition_Params; + +namespace content { +class SpeechRecognitionPreferences; +struct SpeechRecognitionResult; +} + +namespace speech { + +class SpeechRecognitionManagerImpl; + +// InputTagSpeechDispatcherHost is a delegate for Speech API messages used by +// RenderMessageFilter. +// It's the complement of InputTagSpeechDispatcher (owned by RenderView). +class CONTENT_EXPORT InputTagSpeechDispatcherHost + : public content::BrowserMessageFilter { + public: + class Callers; + + InputTagSpeechDispatcherHost( + int render_process_id, + net::URLRequestContextGetter* context_getter, + content::SpeechRecognitionPreferences* recognition_preferences, + AudioManager* audio_manager); + + // Methods called by SpeechRecognitionManagerImpl. + void SetRecognitionResult(int caller_id, + const content::SpeechRecognitionResult& result); + void DidCompleteRecording(int caller_id); + void DidCompleteRecognition(int caller_id); + + // content::BrowserMessageFilter implementation. + virtual bool OnMessageReceived(const IPC::Message& message, + bool* message_was_ok) OVERRIDE; + + // Singleton manager setter useful for tests. + static void set_manager(SpeechRecognitionManagerImpl* manager); + + private: + virtual ~InputTagSpeechDispatcherHost(); + + void OnStartRecognition( + const InputTagSpeechHostMsg_StartRecognition_Params ¶ms); + void OnCancelRecognition(int render_view_id, int request_id); + void OnStopRecording(int render_view_id, int request_id); + + // Returns the speech recognition manager to forward events to, creating one + // if needed. + SpeechRecognitionManagerImpl* manager(); + + int render_process_id_; + bool may_have_pending_requests_; // Set if we received any speech IPC request + + scoped_refptr<net::URLRequestContextGetter> context_getter_; + scoped_refptr<content::SpeechRecognitionPreferences> recognition_preferences_; + AudioManager* audio_manager_; + + static SpeechRecognitionManagerImpl* manager_; + + DISALLOW_COPY_AND_ASSIGN(InputTagSpeechDispatcherHost); +}; + +} // namespace speech + +#endif // CONTENT_BROWSER_SPEECH_INPUT_TAG_SPEECH_DISPATCHER_HOST_H_ diff --git a/content/browser/speech/speech_input_dispatcher_host.h b/content/browser/speech/speech_input_dispatcher_host.h deleted file mode 100644 index 5e38f37..0000000 --- a/content/browser/speech/speech_input_dispatcher_host.h +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_BROWSER_SPEECH_SPEECH_INPUT_DISPATCHER_HOST_H_ -#define CONTENT_BROWSER_SPEECH_SPEECH_INPUT_DISPATCHER_HOST_H_ - -#include "base/memory/scoped_ptr.h" -#include "content/common/content_export.h" -#include "content/public/browser/browser_message_filter.h" -#include "net/url_request/url_request_context_getter.h" - -class AudioManager; -struct SpeechInputHostMsg_StartRecognition_Params; - -namespace content { -class SpeechInputPreferences; -struct SpeechInputResult; -} - -namespace speech_input { - -class SpeechInputManagerImpl; - -// SpeechInputDispatcherHost is a delegate for Speech API messages used by -// RenderMessageFilter. -// It's the complement of SpeechInputDispatcher (owned by RenderView). -class CONTENT_EXPORT SpeechInputDispatcherHost - : public content::BrowserMessageFilter { - public: - class SpeechInputCallers; - - SpeechInputDispatcherHost( - int render_process_id, - net::URLRequestContextGetter* context_getter, - content::SpeechInputPreferences* speech_input_preferences, - AudioManager* audio_manager); - - // Methods called by SpeechInputManagerImpl. - void SetRecognitionResult(int caller_id, - const content::SpeechInputResult& result); - void DidCompleteRecording(int caller_id); - void DidCompleteRecognition(int caller_id); - - // content::BrowserMessageFilter implementation. - virtual bool OnMessageReceived(const IPC::Message& message, - bool* message_was_ok) OVERRIDE; - - // Singleton manager setter useful for tests. - static void set_manager(SpeechInputManagerImpl* manager); - - private: - virtual ~SpeechInputDispatcherHost(); - - void OnStartRecognition( - const SpeechInputHostMsg_StartRecognition_Params ¶ms); - void OnCancelRecognition(int render_view_id, int request_id); - void OnStopRecording(int render_view_id, int request_id); - - // Returns the speech input manager to forward events to, creating one if - // needed. - SpeechInputManagerImpl* manager(); - - int render_process_id_; - bool may_have_pending_requests_; // Set if we received any speech IPC request - - scoped_refptr<net::URLRequestContextGetter> context_getter_; - scoped_refptr<content::SpeechInputPreferences> speech_input_preferences_; - AudioManager* audio_manager_; - - static SpeechInputManagerImpl* manager_; - - DISALLOW_COPY_AND_ASSIGN(SpeechInputDispatcherHost); -}; - -} // namespace speech_input - -#endif // CONTENT_BROWSER_SPEECH_SPEECH_INPUT_DISPATCHER_HOST_H_ diff --git a/content/browser/speech/speech_input_browsertest.cc b/content/browser/speech/speech_recognition_browsertest.cc index 6083ca0..0b56226 100644 --- a/content/browser/speech/speech_input_browsertest.cc +++ b/content/browser/speech/speech_recognition_browsertest.cc @@ -12,28 +12,28 @@ #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" #include "content/browser/renderer_host/render_view_host_impl.h" -#include "content/browser/speech/speech_input_dispatcher_host.h" -#include "content/browser/speech/speech_input_manager_impl.h" +#include "content/browser/speech/input_tag_speech_dispatcher_host.h" +#include "content/browser/speech/speech_recognition_manager_impl.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_types.h" #include "content/public/common/content_switches.h" -#include "content/public/common/speech_input_result.h" +#include "content/public/common/speech_recognition_result.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" using content::NavigationController; using content::WebContents; -namespace speech_input { -class FakeSpeechInputManager; +namespace speech { +class FakeSpeechRecognitionManager; } -namespace speech_input { +namespace speech { const char kTestResult[] = "Pictures of the moon"; -class FakeSpeechInputManager : public SpeechInputManagerImpl { +class FakeSpeechRecognitionManager : public SpeechRecognitionManagerImpl { public: - FakeSpeechInputManager() + FakeSpeechRecognitionManager() : caller_id_(0), delegate_(NULL), did_cancel_all_(false), @@ -61,9 +61,9 @@ class FakeSpeechInputManager : public SpeechInputManagerImpl { return recognition_started_event_; } - // SpeechInputManager methods. + // SpeechRecognitionManager methods. virtual void StartRecognition( - SpeechInputDispatcherHost* delegate, + InputTagSpeechDispatcherHost* delegate, int caller_id, int render_process_id, int render_view_id, @@ -72,7 +72,7 @@ class FakeSpeechInputManager : public SpeechInputManagerImpl { const std::string& grammar, const std::string& origin_url, net::URLRequestContextGetter* context_getter, - content::SpeechInputPreferences* speech_input_prefs) OVERRIDE { + content::SpeechRecognitionPreferences* recognition_prefs) OVERRIDE { VLOG(1) << "StartRecognition invoked."; EXPECT_EQ(0, caller_id_); EXPECT_EQ(NULL, delegate_); @@ -82,7 +82,7 @@ class FakeSpeechInputManager : public SpeechInputManagerImpl { if (should_send_fake_response_) { // Give the fake result in a short while. MessageLoop::current()->PostTask(FROM_HERE, base::Bind( - &FakeSpeechInputManager::SetFakeRecognitionResult, + &FakeSpeechRecognitionManager::SetFakeRecognitionResult, // This class does not need to be refcounted (typically done by // PostTask) since it will outlive the test and gets released only // when the test shuts down. Disabling refcounting here saves a bit @@ -104,7 +104,7 @@ class FakeSpeechInputManager : public SpeechInputManagerImpl { // Nothing to do here since we aren't really recording. } virtual void CancelAllRequestsWithDelegate( - SpeechInputDispatcherHost* delegate) OVERRIDE { + InputTagSpeechDispatcherHost* delegate) OVERRIDE { VLOG(1) << "CancelAllRequestsWithDelegate invoked."; // delegate_ is set to NULL if a fake result was received (see below), so // check that delegate_ matches the incoming parameter only when there is @@ -118,8 +118,8 @@ class FakeSpeechInputManager : public SpeechInputManagerImpl { if (caller_id_) { // Do a check in case we were cancelled.. VLOG(1) << "Setting fake recognition result."; delegate_->DidCompleteRecording(caller_id_); - content::SpeechInputResult results; - results.hypotheses.push_back(content::SpeechInputHypothesis( + content::SpeechRecognitionResult results; + results.hypotheses.push_back(content::SpeechRecognitionHypothesis( ASCIIToUTF16(kTestResult), 1.0)); delegate_->SetRecognitionResult(caller_id_, results); delegate_->DidCompleteRecognition(caller_id_); @@ -130,14 +130,14 @@ class FakeSpeechInputManager : public SpeechInputManagerImpl { } int caller_id_; - SpeechInputDispatcherHost* delegate_; + InputTagSpeechDispatcherHost* delegate_; std::string grammar_; bool did_cancel_all_; bool should_send_fake_response_; base::WaitableEvent recognition_started_event_; }; -class SpeechInputBrowserTest : public InProcessBrowserTest { +class SpeechRecognitionBrowserTest : public InProcessBrowserTest { public: // InProcessBrowserTest methods virtual void SetUpCommandLine(CommandLine* command_line) { @@ -150,7 +150,7 @@ class SpeechInputBrowserTest : public InProcessBrowserTest { } protected: - void LoadAndStartSpeechInputTest(const FilePath::CharType* filename) { + void LoadAndStartSpeechRecognitionTest(const FilePath::CharType* filename) { // The test page calculates the speech button's coordinate in the page on // load & sets that coordinate in the URL fragment. We send mouse down & up // events at that coordinate to trigger speech recognition. @@ -171,46 +171,47 @@ class SpeechInputBrowserTest : public InProcessBrowserTest { web_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event); mouse_event.type = WebKit::WebInputEvent::MouseUp; web_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event); - fake_speech_input_manager_.recognition_started_event().Wait(); + fake_speech_recognition_manager_.recognition_started_event().Wait(); // We should wait for a navigation event, raised by the test page JS code // upon the onwebkitspeechchange event, in all cases except when the // speech response is inhibited. - if (fake_speech_input_manager_.should_send_fake_response()) + if (fake_speech_recognition_manager_.should_send_fake_response()) observer.Wait(); } - void RunSpeechInputTest(const FilePath::CharType* filename) { + void RunSpeechRecognitionTest(const FilePath::CharType* filename) { // The fake speech input manager would receive the speech input // request and return the test string as recognition result. The test page // then sets the URL fragment as 'pass' if it received the expected string. - LoadAndStartSpeechInputTest(filename); + LoadAndStartSpeechRecognitionTest(filename); EXPECT_EQ("pass", browser()->GetSelectedWebContents()->GetURL().ref()); } // InProcessBrowserTest methods. virtual void SetUpInProcessBrowserTestFixture() { - fake_speech_input_manager_.set_should_send_fake_response(true); - speech_input_manager_ = &fake_speech_input_manager_; + fake_speech_recognition_manager_.set_should_send_fake_response(true); + speech_recognition_manager_ = &fake_speech_recognition_manager_; // Inject the fake manager factory so that the test result is returned to // the web page. - SpeechInputDispatcherHost::set_manager(speech_input_manager_); + InputTagSpeechDispatcherHost::set_manager(speech_recognition_manager_); } virtual void TearDownInProcessBrowserTestFixture() { - speech_input_manager_ = NULL; + speech_recognition_manager_ = NULL; } - FakeSpeechInputManager fake_speech_input_manager_; + FakeSpeechRecognitionManager fake_speech_recognition_manager_; // This is used by the static |fakeManager|, and it is a pointer rather than a // direct instance per the style guide. - static SpeechInputManagerImpl* speech_input_manager_; + static SpeechRecognitionManagerImpl* speech_recognition_manager_; }; -SpeechInputManagerImpl* SpeechInputBrowserTest::speech_input_manager_ = NULL; +SpeechRecognitionManagerImpl* + SpeechRecognitionBrowserTest::speech_recognition_manager_ = NULL; // TODO(satish): Once this flakiness has been fixed, add a second test here to // check for sending many clicks in succession to the speech button and verify @@ -220,33 +221,34 @@ SpeechInputManagerImpl* SpeechInputBrowserTest::speech_input_manager_ = NULL; // TODO(satish): Similar to above, once this flakiness has been fixed add // another test here to check that when speech recognition is in progress and // a renderer crashes, we get a call to -// SpeechInputManager::CancelAllRequestsWithDelegate. -IN_PROC_BROWSER_TEST_F(SpeechInputBrowserTest, TestBasicRecognition) { - RunSpeechInputTest(FILE_PATH_LITERAL("basic_recognition.html")); - EXPECT_TRUE(fake_speech_input_manager_.grammar().empty()); +// SpeechRecognitionManager::CancelAllRequestsWithDelegate. +IN_PROC_BROWSER_TEST_F(SpeechRecognitionBrowserTest, TestBasicRecognition) { + RunSpeechRecognitionTest(FILE_PATH_LITERAL("basic_recognition.html")); + EXPECT_TRUE(fake_speech_recognition_manager_.grammar().empty()); } -IN_PROC_BROWSER_TEST_F(SpeechInputBrowserTest, GrammarAttribute) { - RunSpeechInputTest(FILE_PATH_LITERAL("grammar_attribute.html")); +IN_PROC_BROWSER_TEST_F(SpeechRecognitionBrowserTest, GrammarAttribute) { + RunSpeechRecognitionTest(FILE_PATH_LITERAL("grammar_attribute.html")); EXPECT_EQ("http://example.com/grammar.xml", - fake_speech_input_manager_.grammar()); + fake_speech_recognition_manager_.grammar()); } -IN_PROC_BROWSER_TEST_F(SpeechInputBrowserTest, TestCancelAll) { +IN_PROC_BROWSER_TEST_F(SpeechRecognitionBrowserTest, TestCancelAll) { // The test checks that the cancel-all callback gets issued when a session // is pending, so don't send a fake response. // We are not expecting a navigation event being raised from the JS of the // test page JavaScript in this case. - fake_speech_input_manager_.set_should_send_fake_response(false); + fake_speech_recognition_manager_.set_should_send_fake_response(false); - LoadAndStartSpeechInputTest(FILE_PATH_LITERAL("basic_recognition.html")); + LoadAndStartSpeechRecognitionTest( + FILE_PATH_LITERAL("basic_recognition.html")); - // Make the renderer crash. This should trigger SpeechInputDispatcherHost to - // cancel all pending sessions. + // Make the renderer crash. This should trigger + // InputTagSpeechDispatcherHost to cancel all pending sessions. GURL test_url("about:crash"); ui_test_utils::NavigateToURL(browser(), test_url); - EXPECT_TRUE(fake_speech_input_manager_.did_cancel_all()); + EXPECT_TRUE(fake_speech_recognition_manager_.did_cancel_all()); } -} // namespace speech_input +} // namespace speech diff --git a/content/browser/speech/speech_input_manager_impl.cc b/content/browser/speech/speech_recognition_manager_impl.cc index 6df0b3d..9ced53f 100644 --- a/content/browser/speech/speech_input_manager_impl.cc +++ b/content/browser/speech/speech_recognition_manager_impl.cc @@ -2,33 +2,34 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/browser/speech/speech_input_manager_impl.h" +#include "content/browser/speech/speech_recognition_manager_impl.h" #include "base/bind.h" #include "content/browser/browser_main_loop.h" #include "content/browser/renderer_host/render_view_host_impl.h" -#include "content/browser/speech/speech_input_dispatcher_host.h" +#include "content/browser/speech/input_tag_speech_dispatcher_host.h" #include "content/browser/speech/speech_recognizer_impl.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/content_browser_client.h" #include "content/public/browser/render_view_host_delegate.h" #include "content/public/browser/resource_context.h" -#include "content/public/browser/speech_input_manager_delegate.h" -#include "content/public/browser/speech_input_preferences.h" +#include "content/public/browser/speech_recognition_manager_delegate.h" +#include "content/public/browser/speech_recognition_preferences.h" #include "content/public/common/view_type.h" using content::BrowserMainLoop; using content::BrowserThread; -using content::SpeechInputManagerDelegate; +using content::SpeechRecognitionManager; +using content::SpeechRecognitionManagerDelegate; -content::SpeechInputManager* content::SpeechInputManager::GetInstance() { - return speech_input::SpeechInputManagerImpl::GetInstance(); +SpeechRecognitionManager* SpeechRecognitionManager::GetInstance() { + return speech::SpeechRecognitionManagerImpl::GetInstance(); } -namespace speech_input { +namespace speech { -struct SpeechInputManagerImpl::SpeechInputParams { - SpeechInputParams(SpeechInputDispatcherHost* delegate, +struct SpeechRecognitionManagerImpl::SpeechRecognitionParams { + SpeechRecognitionParams(InputTagSpeechDispatcherHost* delegate, int caller_id, int render_process_id, int render_view_id, @@ -37,7 +38,7 @@ struct SpeechInputManagerImpl::SpeechInputParams { const std::string& grammar, const std::string& origin_url, net::URLRequestContextGetter* context_getter, - content::SpeechInputPreferences* speech_input_prefs) + content::SpeechRecognitionPreferences* recognition_prefs) : delegate(delegate), caller_id(caller_id), render_process_id(render_process_id), @@ -47,10 +48,10 @@ struct SpeechInputManagerImpl::SpeechInputParams { grammar(grammar), origin_url(origin_url), context_getter(context_getter), - speech_input_prefs(speech_input_prefs) { + recognition_prefs(recognition_prefs) { } - SpeechInputDispatcherHost* delegate; + InputTagSpeechDispatcherHost* delegate; int caller_id; int render_process_id; int render_view_id; @@ -59,53 +60,53 @@ struct SpeechInputManagerImpl::SpeechInputParams { std::string grammar; std::string origin_url; net::URLRequestContextGetter* context_getter; - content::SpeechInputPreferences* speech_input_prefs; + content::SpeechRecognitionPreferences* recognition_prefs; }; -SpeechInputManagerImpl* SpeechInputManagerImpl::GetInstance() { - return Singleton<SpeechInputManagerImpl>::get(); +SpeechRecognitionManagerImpl* SpeechRecognitionManagerImpl::GetInstance() { + return Singleton<SpeechRecognitionManagerImpl>::get(); } -SpeechInputManagerImpl::SpeechInputManagerImpl() +SpeechRecognitionManagerImpl::SpeechRecognitionManagerImpl() : can_report_metrics_(false), recording_caller_id_(0) { - delegate_ = - content::GetContentClient()->browser()->GetSpeechInputManagerDelegate(); + delegate_ = content::GetContentClient()->browser()-> + GetSpeechRecognitionManagerDelegate(); } -SpeechInputManagerImpl::~SpeechInputManagerImpl() { +SpeechRecognitionManagerImpl::~SpeechRecognitionManagerImpl() { while (requests_.begin() != requests_.end()) CancelRecognition(requests_.begin()->first); } -bool SpeechInputManagerImpl::HasAudioInputDevices() { +bool SpeechRecognitionManagerImpl::HasAudioInputDevices() { return BrowserMainLoop::GetAudioManager()->HasAudioInputDevices(); } -bool SpeechInputManagerImpl::IsRecordingInProcess() { +bool SpeechRecognitionManagerImpl::IsCapturingAudio() { return BrowserMainLoop::GetAudioManager()->IsRecordingInProcess(); } -string16 SpeechInputManagerImpl::GetAudioInputDeviceModel() { +string16 SpeechRecognitionManagerImpl::GetAudioInputDeviceModel() { return BrowserMainLoop::GetAudioManager()->GetAudioInputDeviceModel(); } -bool SpeechInputManagerImpl::HasPendingRequest(int caller_id) const { +bool SpeechRecognitionManagerImpl::HasPendingRequest(int caller_id) const { return requests_.find(caller_id) != requests_.end(); } -SpeechInputDispatcherHost* SpeechInputManagerImpl::GetDelegate( +InputTagSpeechDispatcherHost* SpeechRecognitionManagerImpl::GetDelegate( int caller_id) const { return requests_.find(caller_id)->second.delegate; } -void SpeechInputManagerImpl::ShowAudioInputSettings() { +void SpeechRecognitionManagerImpl::ShowAudioInputSettings() { // Since AudioManager::ShowAudioInputSettings can potentially launch external // processes, do that in the FILE thread to not block the calling threads. if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) { BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind(&SpeechInputManagerImpl::ShowAudioInputSettings, + base::Bind(&SpeechRecognitionManagerImpl::ShowAudioInputSettings, base::Unretained(this))); return; } @@ -116,8 +117,8 @@ void SpeechInputManagerImpl::ShowAudioInputSettings() { audio_manager->ShowAudioInputSettings(); } -void SpeechInputManagerImpl::StartRecognition( - SpeechInputDispatcherHost* delegate, +void SpeechRecognitionManagerImpl::StartRecognition( + InputTagSpeechDispatcherHost* delegate, int caller_id, int render_process_id, int render_view_id, @@ -126,21 +127,21 @@ void SpeechInputManagerImpl::StartRecognition( const std::string& grammar, const std::string& origin_url, net::URLRequestContextGetter* context_getter, - content::SpeechInputPreferences* speech_input_prefs) { + content::SpeechRecognitionPreferences* recognition_prefs) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, base::Bind( - &SpeechInputManagerImpl::CheckRenderViewTypeAndStartRecognition, + &SpeechRecognitionManagerImpl::CheckRenderViewTypeAndStartRecognition, base::Unretained(this), - SpeechInputParams( + SpeechRecognitionParams( delegate, caller_id, render_process_id, render_view_id, element_rect, language, grammar, origin_url, context_getter, - speech_input_prefs))); + recognition_prefs))); } -void SpeechInputManagerImpl::CheckRenderViewTypeAndStartRecognition( - const SpeechInputParams& params) { +void SpeechRecognitionManagerImpl::CheckRenderViewTypeAndStartRecognition( + const SpeechRecognitionParams& params) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); RenderViewHostImpl* render_view_host = RenderViewHostImpl::FromID( @@ -158,13 +159,13 @@ void SpeechInputManagerImpl::CheckRenderViewTypeAndStartRecognition( content::VIEW_TYPE_TAB_CONTENTS) { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind(&SpeechInputManagerImpl::ProceedStartingRecognition, + base::Bind(&SpeechRecognitionManagerImpl::ProceedStartingRecognition, base::Unretained(this), params)); } } -void SpeechInputManagerImpl::ProceedStartingRecognition( - const SpeechInputParams& params) { +void SpeechRecognitionManagerImpl::ProceedStartingRecognition( + const SpeechRecognitionParams& params) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(!HasPendingRequest(params.caller_id)); @@ -175,18 +176,18 @@ void SpeechInputManagerImpl::ProceedStartingRecognition( delegate_->GetRequestInfo(&can_report_metrics_, &request_info_); } - SpeechInputRequest* request = &requests_[params.caller_id]; + Request* request = &requests_[params.caller_id]; request->delegate = params.delegate; request->recognizer = new SpeechRecognizerImpl( this, params.caller_id, params.language, params.grammar, - params.context_getter, params.speech_input_prefs->FilterProfanities(), + params.context_getter, params.recognition_prefs->FilterProfanities(), request_info_, can_report_metrics_ ? params.origin_url : ""); request->is_active = false; StartRecognitionForRequest(params.caller_id); } -void SpeechInputManagerImpl::StartRecognitionForRequest(int caller_id) { +void SpeechRecognitionManagerImpl::StartRecognitionForRequest(int caller_id) { SpeechRecognizerMap::iterator request = requests_.find(caller_id); if (request == requests_.end()) { NOTREACHED(); @@ -202,13 +203,13 @@ void SpeechInputManagerImpl::StartRecognitionForRequest(int caller_id) { if (!HasAudioInputDevices()) { if (delegate_) { - delegate_->ShowMicError( - caller_id, SpeechInputManagerDelegate::MIC_ERROR_NO_DEVICE_AVAILABLE); + delegate_->ShowMicError(caller_id, + SpeechRecognitionManagerDelegate::MIC_ERROR_NO_DEVICE_AVAILABLE); } - } else if (IsRecordingInProcess()) { + } else if (IsCapturingAudio()) { if (delegate_) { delegate_->ShowMicError( - caller_id, SpeechInputManagerDelegate::MIC_ERROR_DEVICE_IN_USE); + caller_id, SpeechRecognitionManagerDelegate::MIC_ERROR_DEVICE_IN_USE); } } else { recording_caller_id_ = caller_id; @@ -219,7 +220,7 @@ void SpeechInputManagerImpl::StartRecognitionForRequest(int caller_id) { } } -void SpeechInputManagerImpl::CancelRecognitionForRequest(int caller_id) { +void SpeechRecognitionManagerImpl::CancelRecognitionForRequest(int caller_id) { // Ignore if the caller id was not in our active recognizers list because the // user might have clicked more than once, or recognition could have been // ended due to other reasons before the user click was processed. @@ -229,7 +230,7 @@ void SpeechInputManagerImpl::CancelRecognitionForRequest(int caller_id) { CancelRecognitionAndInformDelegate(caller_id); } -void SpeechInputManagerImpl::FocusLostForRequest(int caller_id) { +void SpeechRecognitionManagerImpl::FocusLostForRequest(int caller_id) { // See above comment. if (!HasPendingRequest(caller_id)) return; @@ -242,7 +243,7 @@ void SpeechInputManagerImpl::FocusLostForRequest(int caller_id) { CancelRecognitionAndInformDelegate(caller_id); } -void SpeechInputManagerImpl::CancelRecognition(int caller_id) { +void SpeechRecognitionManagerImpl::CancelRecognition(int caller_id) { DCHECK(HasPendingRequest(caller_id)); if (requests_[caller_id].is_active) requests_[caller_id].recognizer->CancelRecognition(); @@ -253,8 +254,8 @@ void SpeechInputManagerImpl::CancelRecognition(int caller_id) { delegate_->DoClose(caller_id); } -void SpeechInputManagerImpl::CancelAllRequestsWithDelegate( - SpeechInputDispatcherHost* delegate) { +void SpeechRecognitionManagerImpl::CancelAllRequestsWithDelegate( + InputTagSpeechDispatcherHost* delegate) { SpeechRecognizerMap::iterator it = requests_.begin(); while (it != requests_.end()) { if (it->second.delegate == delegate) { @@ -267,7 +268,7 @@ void SpeechInputManagerImpl::CancelAllRequestsWithDelegate( } } -void SpeechInputManagerImpl::StopRecording(int caller_id) { +void SpeechRecognitionManagerImpl::StopRecording(int caller_id) { // No pending requests on extension popups. if (!HasPendingRequest(caller_id)) return; @@ -275,13 +276,13 @@ void SpeechInputManagerImpl::StopRecording(int caller_id) { requests_[caller_id].recognizer->StopRecording(); } -void SpeechInputManagerImpl::SetRecognitionResult( - int caller_id, const content::SpeechInputResult& result) { +void SpeechRecognitionManagerImpl::SetRecognitionResult( + int caller_id, const content::SpeechRecognitionResult& result) { DCHECK(HasPendingRequest(caller_id)); GetDelegate(caller_id)->SetRecognitionResult(caller_id, result); } -void SpeechInputManagerImpl::DidCompleteRecording(int caller_id) { +void SpeechRecognitionManagerImpl::DidCompleteRecording(int caller_id) { DCHECK(recording_caller_id_ == caller_id); DCHECK(HasPendingRequest(caller_id)); recording_caller_id_ = 0; @@ -290,21 +291,21 @@ void SpeechInputManagerImpl::DidCompleteRecording(int caller_id) { delegate_->ShowRecognizing(caller_id); } -void SpeechInputManagerImpl::DidCompleteRecognition(int caller_id) { +void SpeechRecognitionManagerImpl::DidCompleteRecognition(int caller_id) { GetDelegate(caller_id)->DidCompleteRecognition(caller_id); requests_.erase(caller_id); if (delegate_) delegate_->DoClose(caller_id); } -void SpeechInputManagerImpl::DidStartReceivingSpeech(int caller_id) { +void SpeechRecognitionManagerImpl::DidStartReceivingSpeech(int caller_id) { } -void SpeechInputManagerImpl::DidStopReceivingSpeech(int caller_id) { +void SpeechRecognitionManagerImpl::DidStopReceivingSpeech(int caller_id) { } -void SpeechInputManagerImpl::OnRecognizerError( - int caller_id, content::SpeechInputError error) { +void SpeechRecognitionManagerImpl::OnRecognizerError( + int caller_id, content::SpeechRecognitionErrorCode error) { if (caller_id == recording_caller_id_) recording_caller_id_ = 0; requests_[caller_id].is_active = false; @@ -312,40 +313,41 @@ void SpeechInputManagerImpl::OnRecognizerError( delegate_->ShowRecognizerError(caller_id, error); } -void SpeechInputManagerImpl::DidStartReceivingAudio(int caller_id) { +void SpeechRecognitionManagerImpl::DidStartReceivingAudio(int caller_id) { DCHECK(HasPendingRequest(caller_id)); DCHECK(recording_caller_id_ == caller_id); if (delegate_) delegate_->ShowRecording(caller_id); } -void SpeechInputManagerImpl::DidCompleteEnvironmentEstimation(int caller_id) { +void SpeechRecognitionManagerImpl::DidCompleteEnvironmentEstimation( + int caller_id) { DCHECK(HasPendingRequest(caller_id)); DCHECK(recording_caller_id_ == caller_id); } -void SpeechInputManagerImpl::SetInputVolume(int caller_id, float volume, - float noise_volume) { +void SpeechRecognitionManagerImpl::SetInputVolume(int caller_id, float volume, + float noise_volume) { DCHECK(HasPendingRequest(caller_id)); DCHECK_EQ(recording_caller_id_, caller_id); if (delegate_) delegate_->ShowInputVolume(caller_id, volume, noise_volume); } -void SpeechInputManagerImpl::CancelRecognitionAndInformDelegate( +void SpeechRecognitionManagerImpl::CancelRecognitionAndInformDelegate( int caller_id) { - SpeechInputDispatcherHost* cur_delegate = GetDelegate(caller_id); + InputTagSpeechDispatcherHost* cur_delegate = GetDelegate(caller_id); CancelRecognition(caller_id); cur_delegate->DidCompleteRecording(caller_id); cur_delegate->DidCompleteRecognition(caller_id); } -SpeechInputManagerImpl::SpeechInputRequest::SpeechInputRequest() +SpeechRecognitionManagerImpl::Request::Request() : delegate(NULL), is_active(false) { } -SpeechInputManagerImpl::SpeechInputRequest::~SpeechInputRequest() { +SpeechRecognitionManagerImpl::Request::~Request() { } -} // namespace speech_input +} // namespace speech diff --git a/content/browser/speech/speech_input_manager_impl.h b/content/browser/speech/speech_recognition_manager_impl.h index 6675fb8..8b91029 100644 --- a/content/browser/speech/speech_input_manager_impl.h +++ b/content/browser/speech/speech_recognition_manager_impl.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_ -#define CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_ +#ifndef CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_MANAGER_H_ +#define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_MANAGER_H_ #include <map> #include <string> @@ -12,7 +12,7 @@ #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" #include "base/memory/singleton.h" -#include "content/public/browser/speech_input_manager.h" +#include "content/public/browser/speech_recognition_manager.h" #include "content/public/browser/speech_recognizer_delegate.h" #include "ui/gfx/rect.h" @@ -20,32 +20,32 @@ class AudioManager; namespace content { class ResourceContext; -class SpeechInputManagerDelegate; -class SpeechInputPreferences; -struct SpeechInputResult; +class SpeechRecognitionManagerDelegate; +class SpeechRecognitionPreferences; +struct SpeechRecognitionResult; } namespace net { class URLRequestContextGetter; } -namespace speech_input { +namespace speech { -class SpeechInputDispatcherHost; +class InputTagSpeechDispatcherHost; class SpeechRecognizerImpl; -class CONTENT_EXPORT SpeechInputManagerImpl - : NON_EXPORTED_BASE(public content::SpeechInputManager), +class CONTENT_EXPORT SpeechRecognitionManagerImpl + : NON_EXPORTED_BASE(public content::SpeechRecognitionManager), NON_EXPORTED_BASE(public content::SpeechRecognizerDelegate) { public: - static SpeechInputManagerImpl* GetInstance(); + static SpeechRecognitionManagerImpl* GetInstance(); - // SpeechInputManager implementation: + // SpeechRecognitionManager implementation: virtual void StartRecognitionForRequest(int caller_id) OVERRIDE; virtual void CancelRecognitionForRequest(int caller_id) OVERRIDE; virtual void FocusLostForRequest(int caller_id) OVERRIDE; virtual bool HasAudioInputDevices() OVERRIDE; - virtual bool IsRecordingInProcess() OVERRIDE; + virtual bool IsCapturingAudio() OVERRIDE; virtual string16 GetAudioInputDeviceModel() OVERRIDE; virtual void ShowAudioInputSettings() OVERRIDE; @@ -58,7 +58,7 @@ class CONTENT_EXPORT SpeechInputManagerImpl // |element_rect| is the display bounds of the html element requesting speech // input (in page coordinates). virtual void StartRecognition( - SpeechInputDispatcherHost* delegate, + InputTagSpeechDispatcherHost* delegate, int caller_id, int render_process_id, int render_view_id, @@ -67,63 +67,63 @@ class CONTENT_EXPORT SpeechInputManagerImpl const std::string& grammar, const std::string& origin_url, net::URLRequestContextGetter* context_getter, - content::SpeechInputPreferences* speech_input_prefs); + content::SpeechRecognitionPreferences* speech_recognition_prefs); virtual void CancelRecognition(int caller_id); virtual void CancelAllRequestsWithDelegate( - SpeechInputDispatcherHost* delegate); + InputTagSpeechDispatcherHost* delegate); virtual void StopRecording(int caller_id); // Overridden from content::SpeechRecognizerDelegate: virtual void DidStartReceivingAudio(int caller_id) OVERRIDE; virtual void SetRecognitionResult( - int caller_id, - const content::SpeechInputResult& result) OVERRIDE; + int caller_id, const content::SpeechRecognitionResult& result) OVERRIDE; virtual void DidCompleteRecording(int caller_id) OVERRIDE; virtual void DidCompleteRecognition(int caller_id) OVERRIDE; virtual void DidStartReceivingSpeech(int caller_id) OVERRIDE; virtual void DidStopReceivingSpeech(int caller_id) OVERRIDE; - virtual void OnRecognizerError(int caller_id, - content::SpeechInputError error) OVERRIDE; + virtual void OnRecognizerError( + int caller_id, content::SpeechRecognitionErrorCode error) OVERRIDE; virtual void DidCompleteEnvironmentEstimation(int caller_id) OVERRIDE; virtual void SetInputVolume(int caller_id, float volume, float noise_volume) OVERRIDE; protected: // Private constructor to enforce singleton. - friend struct DefaultSingletonTraits<SpeechInputManagerImpl>; - SpeechInputManagerImpl(); - virtual ~SpeechInputManagerImpl(); + friend struct DefaultSingletonTraits<SpeechRecognitionManagerImpl>; + SpeechRecognitionManagerImpl(); + virtual ~SpeechRecognitionManagerImpl(); bool HasPendingRequest(int caller_id) const; private: - struct SpeechInputRequest { - SpeechInputRequest(); - ~SpeechInputRequest(); + struct Request { + Request(); + ~Request(); - SpeechInputDispatcherHost* delegate; + InputTagSpeechDispatcherHost* delegate; scoped_refptr<SpeechRecognizerImpl> recognizer; bool is_active; // Set to true when recording or recognition is going on. }; - struct SpeechInputParams; + struct SpeechRecognitionParams; - SpeechInputDispatcherHost* GetDelegate(int caller_id) const; + InputTagSpeechDispatcherHost* GetDelegate(int caller_id) const; - void CheckRenderViewTypeAndStartRecognition(const SpeechInputParams& params); - void ProceedStartingRecognition(const SpeechInputParams& params); + void CheckRenderViewTypeAndStartRecognition( + const SpeechRecognitionParams& params); + void ProceedStartingRecognition(const SpeechRecognitionParams& params); void CancelRecognitionAndInformDelegate(int caller_id); - typedef std::map<int, SpeechInputRequest> SpeechRecognizerMap; + typedef std::map<int, Request> SpeechRecognizerMap; SpeechRecognizerMap requests_; std::string request_info_; bool can_report_metrics_; int recording_caller_id_; - content::SpeechInputManagerDelegate* delegate_; + content::SpeechRecognitionManagerDelegate* delegate_; }; -} // namespace speech_input +} // namespace speech -#endif // CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_ +#endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_MANAGER_H_ diff --git a/content/browser/speech/speech_recognition_request.cc b/content/browser/speech/speech_recognition_request.cc index 8176128..89dde84 100644 --- a/content/browser/speech/speech_recognition_request.cc +++ b/content/browser/speech/speech_recognition_request.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -11,7 +11,7 @@ #include "base/string_util.h" #include "base/values.h" #include "content/common/net/url_fetcher_impl.h" -#include "content/public/common/speech_input_result.h" +#include "content/public/common/speech_recognition_result.h" #include "net/base/escape.h" #include "net/base/load_flags.h" #include "net/url_request/url_request_context.h" @@ -32,7 +32,7 @@ const char* const kConfidenceString = "confidence"; const int kMaxResults = 6; bool ParseServerResponse(const std::string& response_body, - content::SpeechInputResult* result) { + content::SpeechRecognitionResult* result) { if (response_body.empty()) { LOG(WARNING) << "ParseServerResponse: Response was empty."; return false; @@ -66,9 +66,9 @@ bool ParseServerResponse(const std::string& response_body, // Process the status. switch (status) { - case content::SPEECH_INPUT_ERROR_NONE: - case content::SPEECH_INPUT_ERROR_NO_SPEECH: - case content::SPEECH_INPUT_ERROR_NO_MATCH: + case content::SPEECH_RECOGNITION_ERROR_NONE: + case content::SPEECH_RECOGNITION_ERROR_NO_SPEECH: + case content::SPEECH_RECOGNITION_ERROR_NO_MATCH: break; default: @@ -77,7 +77,7 @@ bool ParseServerResponse(const std::string& response_body, return false; } - result->error = static_cast<content::SpeechInputError>(status); + result->error = static_cast<content::SpeechRecognitionErrorCode>(status); // Get the hypotheses. Value* hypotheses_value = NULL; @@ -121,7 +121,7 @@ bool ParseServerResponse(const std::string& response_body, double confidence = 0.0; hypothesis_value->GetDouble(kConfidenceString, &confidence); - result->hypotheses.push_back(content::SpeechInputHypothesis( + result->hypotheses.push_back(content::SpeechRecognitionHypothesis( utterance, confidence)); } @@ -135,7 +135,7 @@ bool ParseServerResponse(const std::string& response_body, } // namespace -namespace speech_input { +namespace speech { int SpeechRecognitionRequest::url_fetcher_id_for_tests = 0; @@ -211,12 +211,12 @@ void SpeechRecognitionRequest::OnURLFetchComplete( const content::URLFetcher* source) { DCHECK_EQ(url_fetcher_.get(), source); - content::SpeechInputResult result; + content::SpeechRecognitionResult result; std::string data; if (!source->GetStatus().is_success() || source->GetResponseCode() != 200 || !source->GetResponseAsString(&data) || !ParseServerResponse(data, &result)) { - result.error = content::SPEECH_INPUT_ERROR_NETWORK; + result.error = content::SPEECH_RECOGNITION_ERROR_NETWORK; } DVLOG(1) << "SpeechRecognitionRequest: Invoking delegate with result."; @@ -224,4 +224,4 @@ void SpeechRecognitionRequest::OnURLFetchComplete( delegate_->SetRecognitionResult(result); } -} // namespace speech_input +} // namespace speech diff --git a/content/browser/speech/speech_recognition_request.h b/content/browser/speech/speech_recognition_request.h index 65a9733..b6ce077 100644 --- a/content/browser/speech/speech_recognition_request.h +++ b/content/browser/speech/speech_recognition_request.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -18,14 +18,14 @@ class URLFetcher; namespace content { -struct SpeechInputResult; +struct SpeechRecognitionResult; } namespace net { class URLRequestContextGetter; } -namespace speech_input { +namespace speech { // Provides a simple interface for sending recorded speech data to the server // and get back recognition results. @@ -38,7 +38,7 @@ class SpeechRecognitionRequest : public content::URLFetcherDelegate { class CONTENT_EXPORT Delegate { public: virtual void SetRecognitionResult( - const content::SpeechInputResult& result) = 0; + const content::SpeechRecognitionResult& result) = 0; protected: virtual ~Delegate() {} @@ -83,6 +83,6 @@ class SpeechRecognitionRequest : public content::URLFetcherDelegate { // the workaround was not needed for my machine). typedef SpeechRecognitionRequest::Delegate SpeechRecognitionRequestDelegate; -} // namespace speech_input +} // namespace speech #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_REQUEST_H_ diff --git a/content/browser/speech/speech_recognition_request_unittest.cc b/content/browser/speech/speech_recognition_request_unittest.cc index 9221085..37b82f8 100644 --- a/content/browser/speech/speech_recognition_request_unittest.cc +++ b/content/browser/speech/speech_recognition_request_unittest.cc @@ -1,17 +1,17 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/message_loop.h" #include "base/utf_string_conversions.h" #include "content/browser/speech/speech_recognition_request.h" -#include "content/public/common/speech_input_result.h" +#include "content/public/common/speech_recognition_result.h" #include "content/test/test_url_fetcher_factory.h" #include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_status.h" #include "testing/gtest/include/gtest/gtest.h" -namespace speech_input { +namespace speech { class SpeechRecognitionRequestTest : public SpeechRecognitionRequestDelegate, public testing::Test { @@ -24,14 +24,14 @@ class SpeechRecognitionRequestTest : public SpeechRecognitionRequestDelegate, // SpeechRecognitionRequestDelegate methods. virtual void SetRecognitionResult( - const content::SpeechInputResult& result) OVERRIDE { + const content::SpeechRecognitionResult& result) OVERRIDE { result_ = result; } protected: MessageLoop message_loop_; TestURLFetcherFactory url_fetcher_factory_; - content::SpeechInputResult result_; + content::SpeechRecognitionResult result_; }; void SpeechRecognitionRequestTest::CreateAndTestRequest( @@ -60,7 +60,7 @@ TEST_F(SpeechRecognitionRequestTest, BasicTest) { CreateAndTestRequest(true, "{\"status\":0,\"hypotheses\":" "[{\"utterance\":\"123456\",\"confidence\":0.9}]}"); - EXPECT_EQ(result_.error, content::SPEECH_INPUT_ERROR_NONE); + EXPECT_EQ(result_.error, content::SPEECH_RECOGNITION_ERROR_NONE); EXPECT_EQ(1U, result_.hypotheses.size()); EXPECT_EQ(ASCIIToUTF16("123456"), result_.hypotheses[0].utterance); EXPECT_EQ(0.9, result_.hypotheses[0].confidence); @@ -70,7 +70,7 @@ TEST_F(SpeechRecognitionRequestTest, BasicTest) { "{\"status\":0,\"hypotheses\":[" "{\"utterance\":\"hello\",\"confidence\":0.9}," "{\"utterance\":\"123456\",\"confidence\":0.5}]}"); - EXPECT_EQ(result_.error, content::SPEECH_INPUT_ERROR_NONE); + EXPECT_EQ(result_.error, content::SPEECH_RECOGNITION_ERROR_NONE); EXPECT_EQ(2u, result_.hypotheses.size()); EXPECT_EQ(ASCIIToUTF16("hello"), result_.hypotheses[0].utterance); EXPECT_EQ(0.9, result_.hypotheses[0].confidence); @@ -79,29 +79,29 @@ TEST_F(SpeechRecognitionRequestTest, BasicTest) { // Zero results. CreateAndTestRequest(true, "{\"status\":0,\"hypotheses\":[]}"); - EXPECT_EQ(result_.error, content::SPEECH_INPUT_ERROR_NONE); + EXPECT_EQ(result_.error, content::SPEECH_RECOGNITION_ERROR_NONE); EXPECT_EQ(0U, result_.hypotheses.size()); // Http failure case. CreateAndTestRequest(false, ""); - EXPECT_EQ(result_.error, content::SPEECH_INPUT_ERROR_NETWORK); + EXPECT_EQ(result_.error, content::SPEECH_RECOGNITION_ERROR_NETWORK); EXPECT_EQ(0U, result_.hypotheses.size()); // Invalid status case. CreateAndTestRequest(true, "{\"status\":\"invalid\",\"hypotheses\":[]}"); - EXPECT_EQ(result_.error, content::SPEECH_INPUT_ERROR_NETWORK); + EXPECT_EQ(result_.error, content::SPEECH_RECOGNITION_ERROR_NETWORK); EXPECT_EQ(0U, result_.hypotheses.size()); // Server-side error case. CreateAndTestRequest(true, "{\"status\":1,\"hypotheses\":[]}"); - EXPECT_EQ(result_.error, content::SPEECH_INPUT_ERROR_NETWORK); + EXPECT_EQ(result_.error, content::SPEECH_RECOGNITION_ERROR_NETWORK); EXPECT_EQ(0U, result_.hypotheses.size()); // Malformed JSON case. CreateAndTestRequest(true, "{\"status\":0,\"hypotheses\":" "[{\"unknownkey\":\"hello\"}]}"); - EXPECT_EQ(result_.error, content::SPEECH_INPUT_ERROR_NETWORK); + EXPECT_EQ(result_.error, content::SPEECH_RECOGNITION_ERROR_NETWORK); EXPECT_EQ(0U, result_.hypotheses.size()); } -} // namespace speech_input +} // namespace speech diff --git a/content/browser/speech/speech_recognizer_impl.cc b/content/browser/speech/speech_recognizer_impl.cc index 9d4ed1c..bbcfbd2 100644 --- a/content/browser/speech/speech_recognizer_impl.cc +++ b/content/browser/speech/speech_recognizer_impl.cc @@ -9,7 +9,7 @@ #include "content/browser/browser_main_loop.h" #include "content/public/browser/speech_recognizer_delegate.h" #include "content/public/browser/browser_thread.h" -#include "content/public/common/speech_input_result.h" +#include "content/public/common/speech_recognition_result.h" #include "net/url_request/url_request_context_getter.h" using content::BrowserMainLoop; @@ -61,12 +61,12 @@ SpeechRecognizer* SpeechRecognizer::Create( bool filter_profanities, const std::string& hardware_info, const std::string& origin_url) { - return new speech_input::SpeechRecognizerImpl( + return new speech::SpeechRecognizerImpl( delegate, caller_id, language, grammar, context_getter, filter_profanities, hardware_info, origin_url); } -namespace speech_input { +namespace speech { const int SpeechRecognizerImpl::kAudioSampleRate = 16000; const int SpeechRecognizerImpl::kAudioPacketIntervalMs = 100; @@ -208,7 +208,7 @@ void SpeechRecognizerImpl::HandleOnError(int error_code) { if (!audio_controller_.get()) return; - InformErrorAndCancelRecognition(content::SPEECH_INPUT_ERROR_AUDIO); + InformErrorAndCancelRecognition(content::SPEECH_RECOGNITION_ERROR_AUDIO); } void SpeechRecognizerImpl::OnData(AudioInputController* controller, @@ -272,7 +272,8 @@ void SpeechRecognizerImpl::HandleOnData(string* data) { bool speech_was_heard_after_packet = endpointer_.DidStartReceivingSpeech(); if (!speech_was_heard_after_packet && num_samples_recorded_ >= kNoSpeechTimeoutSec * kAudioSampleRate) { - InformErrorAndCancelRecognition(content::SPEECH_INPUT_ERROR_NO_SPEECH); + InformErrorAndCancelRecognition( + content::SPEECH_RECOGNITION_ERROR_NO_SPEECH); return; } @@ -303,8 +304,8 @@ void SpeechRecognizerImpl::HandleOnData(string* data) { } void SpeechRecognizerImpl::SetRecognitionResult( - const content::SpeechInputResult& result) { - if (result.error != content::SPEECH_INPUT_ERROR_NONE) { + const content::SpeechRecognitionResult& result) { + if (result.error != content::SPEECH_RECOGNITION_ERROR_NONE) { InformErrorAndCancelRecognition(result.error); return; } @@ -316,8 +317,8 @@ void SpeechRecognizerImpl::SetRecognitionResult( } void SpeechRecognizerImpl::InformErrorAndCancelRecognition( - content::SpeechInputError error) { - DCHECK_NE(error, content::SPEECH_INPUT_ERROR_NONE); + content::SpeechRecognitionErrorCode error) { + DCHECK_NE(error, content::SPEECH_RECOGNITION_ERROR_NONE); CancelRecognition(); // Guard against the delegate freeing us until we finish our job. @@ -343,4 +344,4 @@ void SpeechRecognizerImpl::SetAudioManagerForTesting( audio_manager_ = audio_manager; } -} // namespace speech_input +} // namespace speech diff --git a/content/browser/speech/speech_recognizer_impl.h b/content/browser/speech/speech_recognizer_impl.h index 0273ccb..25e0c0c 100644 --- a/content/browser/speech/speech_recognizer_impl.h +++ b/content/browser/speech/speech_recognizer_impl.h @@ -14,12 +14,12 @@ #include "content/browser/speech/endpointer/endpointer.h" #include "content/browser/speech/speech_recognition_request.h" #include "content/public/browser/speech_recognizer.h" -#include "content/public/common/speech_input_result.h" +#include "content/public/common/speech_recognition_result.h" #include "media/audio/audio_input_controller.h" class AudioManager; -namespace speech_input { +namespace speech { // Records audio, sends recorded audio to server and translates server response // to recognition result. @@ -47,8 +47,8 @@ class CONTENT_EXPORT SpeechRecognizerImpl void StopRecording(); // AudioInputController::EventHandler methods. - virtual void OnCreated(media::AudioInputController* controller) OVERRIDE { } - virtual void OnRecording(media::AudioInputController* controller) OVERRIDE { } + virtual void OnCreated(media::AudioInputController* controller) OVERRIDE {} + virtual void OnRecording(media::AudioInputController* controller) OVERRIDE {} virtual void OnError(media::AudioInputController* controller, int error_code) OVERRIDE; virtual void OnData(media::AudioInputController* controller, @@ -57,7 +57,7 @@ class CONTENT_EXPORT SpeechRecognizerImpl // SpeechRecognitionRequest::Delegate methods. virtual void SetRecognitionResult( - const content::SpeechInputResult& result) OVERRIDE; + const content::SpeechRecognitionResult& result) OVERRIDE; static const int kAudioSampleRate; static const int kAudioPacketIntervalMs; // Duration of each audio packet. @@ -69,7 +69,8 @@ class CONTENT_EXPORT SpeechRecognizerImpl private: friend class SpeechRecognizerTest; - void InformErrorAndCancelRecognition(content::SpeechInputError error); + void InformErrorAndCancelRecognition( + content::SpeechRecognitionErrorCode error); void SendRecordedAudioToServer(); void HandleOnError(int error_code); // Handles OnError in the IO thread. @@ -103,6 +104,6 @@ class CONTENT_EXPORT SpeechRecognizerImpl DISALLOW_COPY_AND_ASSIGN(SpeechRecognizerImpl); }; -} // namespace speech_input +} // namespace speech #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_H_ diff --git a/content/browser/speech/speech_recognizer_impl_unittest.cc b/content/browser/speech/speech_recognizer_impl_unittest.cc index 7388914..cfd2c33 100644 --- a/content/browser/speech/speech_recognizer_impl_unittest.cc +++ b/content/browser/speech/speech_recognizer_impl_unittest.cc @@ -20,7 +20,7 @@ using media::AudioInputController; using media::TestAudioInputController; using media::TestAudioInputControllerFactory; -namespace speech_input { +namespace speech { class SpeechRecognizerTest : public content::SpeechRecognizerDelegate, public testing::Test { @@ -32,7 +32,7 @@ class SpeechRecognizerTest : public content::SpeechRecognizerDelegate, recognition_complete_(false), result_received_(false), audio_received_(false), - error_(content::SPEECH_INPUT_ERROR_NONE), + error_(content::SPEECH_RECOGNITION_ERROR_NONE), volume_(-1.0f) { recognizer_ = new SpeechRecognizerImpl( this, 1, std::string(), std::string(), NULL, false, std::string(), @@ -49,7 +49,7 @@ class SpeechRecognizerTest : public content::SpeechRecognizerDelegate, // Overridden from content::SpeechRecognizerDelegate: virtual void SetRecognitionResult( int caller_id, - const content::SpeechInputResult& result) OVERRIDE { + const content::SpeechRecognitionResult& result) OVERRIDE { result_received_ = true; } @@ -74,8 +74,8 @@ class SpeechRecognizerTest : public content::SpeechRecognizerDelegate, virtual void DidStopReceivingSpeech(int caller_id) OVERRIDE { } - virtual void OnRecognizerError(int caller_id, - content::SpeechInputError error) OVERRIDE { + virtual void OnRecognizerError( + int caller_id, content::SpeechRecognitionErrorCode error) OVERRIDE { error_ = error; } @@ -119,7 +119,7 @@ class SpeechRecognizerTest : public content::SpeechRecognizerDelegate, bool recognition_complete_; bool result_received_; bool audio_received_; - content::SpeechInputError error_; + content::SpeechRecognitionErrorCode error_; TestURLFetcherFactory url_fetcher_factory_; TestAudioInputControllerFactory audio_input_controller_factory_; std::vector<uint8> audio_packet_; @@ -135,7 +135,7 @@ TEST_F(SpeechRecognizerTest, StopNoData) { EXPECT_FALSE(recognition_complete_); EXPECT_FALSE(result_received_); EXPECT_FALSE(audio_received_); - EXPECT_EQ(content::SPEECH_INPUT_ERROR_NONE, error_); + EXPECT_EQ(content::SPEECH_RECOGNITION_ERROR_NONE, error_); } TEST_F(SpeechRecognizerTest, CancelNoData) { @@ -147,7 +147,7 @@ TEST_F(SpeechRecognizerTest, CancelNoData) { EXPECT_TRUE(recognition_complete_); EXPECT_FALSE(result_received_); EXPECT_FALSE(audio_received_); - EXPECT_EQ(content::SPEECH_INPUT_ERROR_NONE, error_); + EXPECT_EQ(content::SPEECH_RECOGNITION_ERROR_NONE, error_); } TEST_F(SpeechRecognizerTest, StopWithData) { @@ -177,7 +177,7 @@ TEST_F(SpeechRecognizerTest, StopWithData) { EXPECT_TRUE(recording_complete_); EXPECT_FALSE(recognition_complete_); EXPECT_FALSE(result_received_); - EXPECT_EQ(content::SPEECH_INPUT_ERROR_NONE, error_); + EXPECT_EQ(content::SPEECH_RECOGNITION_ERROR_NONE, error_); // Issue the network callback to complete the process. TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); @@ -194,7 +194,7 @@ TEST_F(SpeechRecognizerTest, StopWithData) { EXPECT_TRUE(recognition_complete_); EXPECT_TRUE(result_received_); - EXPECT_EQ(content::SPEECH_INPUT_ERROR_NONE, error_); + EXPECT_EQ(content::SPEECH_RECOGNITION_ERROR_NONE, error_); } TEST_F(SpeechRecognizerTest, CancelWithData) { @@ -213,7 +213,7 @@ TEST_F(SpeechRecognizerTest, CancelWithData) { EXPECT_FALSE(recording_complete_); EXPECT_FALSE(recognition_complete_); EXPECT_FALSE(result_received_); - EXPECT_EQ(content::SPEECH_INPUT_ERROR_NONE, error_); + EXPECT_EQ(content::SPEECH_RECOGNITION_ERROR_NONE, error_); } TEST_F(SpeechRecognizerTest, ConnectionError) { @@ -234,7 +234,7 @@ TEST_F(SpeechRecognizerTest, ConnectionError) { EXPECT_TRUE(recording_complete_); EXPECT_FALSE(recognition_complete_); EXPECT_FALSE(result_received_); - EXPECT_EQ(content::SPEECH_INPUT_ERROR_NONE, error_); + EXPECT_EQ(content::SPEECH_RECOGNITION_ERROR_NONE, error_); // Issue the network callback to complete the process. fetcher->set_url(fetcher->GetOriginalURL()); @@ -248,7 +248,7 @@ TEST_F(SpeechRecognizerTest, ConnectionError) { EXPECT_FALSE(recognition_complete_); EXPECT_FALSE(result_received_); - EXPECT_EQ(content::SPEECH_INPUT_ERROR_NETWORK, error_); + EXPECT_EQ(content::SPEECH_RECOGNITION_ERROR_NETWORK, error_); } TEST_F(SpeechRecognizerTest, ServerError) { @@ -269,7 +269,7 @@ TEST_F(SpeechRecognizerTest, ServerError) { EXPECT_TRUE(recording_complete_); EXPECT_FALSE(recognition_complete_); EXPECT_FALSE(result_received_); - EXPECT_EQ(content::SPEECH_INPUT_ERROR_NONE, error_); + EXPECT_EQ(content::SPEECH_RECOGNITION_ERROR_NONE, error_); // Issue the network callback to complete the process. fetcher->set_url(fetcher->GetOriginalURL()); @@ -282,7 +282,7 @@ TEST_F(SpeechRecognizerTest, ServerError) { EXPECT_FALSE(recognition_complete_); EXPECT_FALSE(result_received_); - EXPECT_EQ(content::SPEECH_INPUT_ERROR_NETWORK, error_); + EXPECT_EQ(content::SPEECH_RECOGNITION_ERROR_NETWORK, error_); } TEST_F(SpeechRecognizerTest, AudioControllerErrorNoData) { @@ -297,7 +297,7 @@ TEST_F(SpeechRecognizerTest, AudioControllerErrorNoData) { EXPECT_FALSE(recording_complete_); EXPECT_FALSE(recognition_complete_); EXPECT_FALSE(result_received_); - EXPECT_EQ(content::SPEECH_INPUT_ERROR_AUDIO, error_); + EXPECT_EQ(content::SPEECH_RECOGNITION_ERROR_AUDIO, error_); } TEST_F(SpeechRecognizerTest, AudioControllerErrorWithData) { @@ -316,7 +316,7 @@ TEST_F(SpeechRecognizerTest, AudioControllerErrorWithData) { EXPECT_FALSE(recording_complete_); EXPECT_FALSE(recognition_complete_); EXPECT_FALSE(result_received_); - EXPECT_EQ(content::SPEECH_INPUT_ERROR_AUDIO, error_); + EXPECT_EQ(content::SPEECH_RECOGNITION_ERROR_AUDIO, error_); } TEST_F(SpeechRecognizerTest, NoSpeechCallbackIssued) { @@ -341,7 +341,7 @@ TEST_F(SpeechRecognizerTest, NoSpeechCallbackIssued) { EXPECT_FALSE(recording_complete_); EXPECT_FALSE(recognition_complete_); EXPECT_FALSE(result_received_); - EXPECT_EQ(content::SPEECH_INPUT_ERROR_NO_SPEECH, error_); + EXPECT_EQ(content::SPEECH_RECOGNITION_ERROR_NO_SPEECH, error_); } TEST_F(SpeechRecognizerTest, NoSpeechCallbackNotIssued) { @@ -372,7 +372,7 @@ TEST_F(SpeechRecognizerTest, NoSpeechCallbackNotIssued) { } MessageLoop::current()->RunAllPending(); - EXPECT_EQ(content::SPEECH_INPUT_ERROR_NONE, error_); + EXPECT_EQ(content::SPEECH_RECOGNITION_ERROR_NONE, error_); EXPECT_TRUE(audio_received_); EXPECT_FALSE(recording_complete_); EXPECT_FALSE(recognition_complete_); @@ -415,10 +415,10 @@ TEST_F(SpeechRecognizerTest, SetInputVolumeCallback) { EXPECT_FLOAT_EQ(0.89926866f, volume_); EXPECT_FLOAT_EQ(0.75071919f, noise_volume_); - EXPECT_EQ(content::SPEECH_INPUT_ERROR_NONE, error_); + EXPECT_EQ(content::SPEECH_RECOGNITION_ERROR_NONE, error_); EXPECT_FALSE(recording_complete_); EXPECT_FALSE(recognition_complete_); recognizer_->CancelRecognition(); } -} // namespace speech_input +} // namespace speech diff --git a/content/common/content_message_generator.h b/content/common/content_message_generator.h index 1e6f3c5..9ef7371 100644 --- a/content/common/content_message_generator.h +++ b/content/common/content_message_generator.h @@ -35,7 +35,7 @@ #include "content/common/quota_messages.h" #include "content/common/resource_messages.h" #include "content/common/socket_stream_messages.h" -#include "content/common/speech_input_messages.h" +#include "content/common/speech_recognition_messages.h" #include "content/common/text_input_client_messages.h" #include "content/common/utility_messages.h" #include "content/common/view_messages.h" diff --git a/content/common/speech_input_messages.h b/content/common/speech_recognition_messages.h index f50e057..7ab76c1 100644 --- a/content/common/speech_input_messages.h +++ b/content/common/speech_recognition_messages.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,27 +6,27 @@ #include <string> -#include "content/public/common/speech_input_result.h" +#include "content/public/common/speech_recognition_result.h" #include "ipc/ipc_message_macros.h" #include "ipc/ipc_param_traits.h" #include "ui/gfx/rect.h" -#define IPC_MESSAGE_START SpeechInputMsgStart +#define IPC_MESSAGE_START SpeechRecognitionMsgStart -IPC_ENUM_TRAITS(content::SpeechInputError) +IPC_ENUM_TRAITS(content::SpeechRecognitionErrorCode) -IPC_STRUCT_TRAITS_BEGIN(content::SpeechInputHypothesis) +IPC_STRUCT_TRAITS_BEGIN(content::SpeechRecognitionHypothesis) IPC_STRUCT_TRAITS_MEMBER(utterance) IPC_STRUCT_TRAITS_MEMBER(confidence) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(content::SpeechInputResult) +IPC_STRUCT_TRAITS_BEGIN(content::SpeechRecognitionResult) IPC_STRUCT_TRAITS_MEMBER(error) IPC_STRUCT_TRAITS_MEMBER(hypotheses) IPC_STRUCT_TRAITS_END() // Used to start a speech recognition session. -IPC_STRUCT_BEGIN(SpeechInputHostMsg_StartRecognition_Params) +IPC_STRUCT_BEGIN(InputTagSpeechHostMsg_StartRecognition_Params) // The render view requesting speech recognition. IPC_STRUCT_MEMBER(int, render_view_id) // Request ID used within the render view. @@ -35,53 +35,52 @@ IPC_STRUCT_BEGIN(SpeechInputHostMsg_StartRecognition_Params) IPC_STRUCT_MEMBER(gfx::Rect, element_rect) // Language to use for speech recognition. IPC_STRUCT_MEMBER(std::string, language) - // Speech grammar given by the speech input element. + // Speech grammar given by the speech recognition element. IPC_STRUCT_MEMBER(std::string, grammar) // URL of the page (or iframe if applicable). IPC_STRUCT_MEMBER(std::string, origin_url) IPC_STRUCT_END() -// Speech input messages sent from the renderer to the browser. +// Speech recognition messages sent from the renderer to the browser. -// Requests the speech input service to start speech recognition on behalf of -// the given |render_view_id|. -IPC_MESSAGE_CONTROL1(SpeechInputHostMsg_StartRecognition, - SpeechInputHostMsg_StartRecognition_Params) +// Requests the speech recognition service to start speech recognition on behalf +// of the given |render_view_id|. +IPC_MESSAGE_CONTROL1(InputTagSpeechHostMsg_StartRecognition, + InputTagSpeechHostMsg_StartRecognition_Params) -// Requests the speech input service to cancel speech recognition on behalf of -// the given |render_view_id|. If speech recognition is not happening or -// is happening on behalf of some other render view, this call does nothing. -IPC_MESSAGE_CONTROL2(SpeechInputHostMsg_CancelRecognition, +// Requests the speech recognition service to cancel speech recognition on +// behalf of the given |render_view_id|. If speech recognition is not happening +// or is happening on behalf of some other render view, this call does nothing. +IPC_MESSAGE_CONTROL2(InputTagSpeechHostMsg_CancelRecognition, int /* render_view_id */, int /* request_id */) -// Requests the speech input service to stop audio recording on behalf of +// Requests the speech recognition service to stop audio recording on behalf of // the given |render_view_id|. Any audio recorded so far will be fed to the // speech recognizer. If speech recognition is not happening nor or is // happening on behalf of some other render view, this call does nothing. -IPC_MESSAGE_CONTROL2(SpeechInputHostMsg_StopRecording, +IPC_MESSAGE_CONTROL2(InputTagSpeechHostMsg_StopRecording, int /* render_view_id */, int /* request_id */) -// Speech input messages sent from the browser to the renderer. +// Speech recognition messages sent from the browser to the renderer. // Relay a speech recognition result, either partial or final. -IPC_MESSAGE_ROUTED2(SpeechInputMsg_SetRecognitionResult, +IPC_MESSAGE_ROUTED2(InputTagSpeechMsg_SetRecognitionResult, int /* request_id */, - content::SpeechInputResult /* result */) + content::SpeechRecognitionResult /* result */) // Indicate that speech recognizer has stopped recording and started // recognition. -IPC_MESSAGE_ROUTED1(SpeechInputMsg_RecordingComplete, +IPC_MESSAGE_ROUTED1(InputTagSpeechMsg_RecordingComplete, int /* request_id */) -// Indicate that speech recognizer has completed recognition. This will be -// the last message sent in response to a -// ViewHostMsg_SpeechInput_StartRecognition. -IPC_MESSAGE_ROUTED1(SpeechInputMsg_RecognitionComplete, +// Indicate that speech recognizer has completed recognition. This will be the +// last message sent in response to a InputTagSpeechHostMsg_StartRecognition. +IPC_MESSAGE_ROUTED1(InputTagSpeechMsg_RecognitionComplete, int /* request_id */) -// Toggle speech input on or off on the speech input control for the +// Toggle speech recognition on or off on the speech input control for the // current focused element. Has no effect if the current element doesn't -// support speech input. -IPC_MESSAGE_ROUTED0(SpeechInputMsg_ToggleSpeechInput) +// support speech recognition. +IPC_MESSAGE_ROUTED0(InputTagSpeechMsg_ToggleSpeechInput) diff --git a/content/content_browser.gypi b/content/content_browser.gypi index a6a81d8f..e2acdde 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -115,9 +115,9 @@ 'public/browser/sensors_provider.h', 'public/browser/session_storage_namespace.h', 'public/browser/site_instance.h', - 'public/browser/speech_input_manager.h', - 'public/browser/speech_input_manager_delegate.h', - 'public/browser/speech_input_preferences.h', + 'public/browser/speech_recognition_manager.h', + 'public/browser/speech_recognition_manager_delegate.h', + 'public/browser/speech_recognition_preferences.h', 'public/browser/speech_recognizer.h', 'public/browser/speech_recognizer_delegate.h', 'public/browser/user_metrics.h', @@ -605,10 +605,10 @@ 'browser/speech/endpointer/energy_endpointer.h', 'browser/speech/endpointer/energy_endpointer_params.cc', 'browser/speech/endpointer/energy_endpointer_params.h', - 'browser/speech/speech_input_dispatcher_host.cc', - 'browser/speech/speech_input_dispatcher_host.h', - 'browser/speech/speech_input_manager_impl.cc', - 'browser/speech/speech_input_manager_impl.h', + 'browser/speech/input_tag_speech_dispatcher_host.cc', + 'browser/speech/input_tag_speech_dispatcher_host.h', + 'browser/speech/speech_recognition_manager_impl.cc', + 'browser/speech/speech_recognition_manager_impl.h', 'browser/speech/speech_recognition_request.cc', 'browser/speech/speech_recognition_request.h', 'browser/speech/speech_recognizer_impl.cc', diff --git a/content/content_common.gypi b/content/content_common.gypi index 4889f2c..e93daf8 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -74,8 +74,8 @@ 'public/common/serialized_script_value.h', 'public/common/show_desktop_notification_params.cc', 'public/common/show_desktop_notification_params.h', - 'public/common/speech_input_result.cc', - 'public/common/speech_input_result.h', + 'public/common/speech_recognition_result.h', + 'public/common/speech_recognition_result.cc', 'public/common/ssl_status.cc', 'public/common/ssl_status.h', 'public/common/stop_find_action.h', @@ -286,7 +286,7 @@ 'common/socket_stream_dispatcher.cc', 'common/socket_stream_dispatcher.h', 'common/socket_stream_messages.h', - 'common/speech_input_messages.h', + 'common/speech_recognition_messages.h', 'common/ssl_status_serialization.cc', 'common/ssl_status_serialization.h', 'common/swapped_out_messages.cc', diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi index 7c484a6..c67a3a3 100644 --- a/content/content_renderer.gypi +++ b/content/content_renderer.gypi @@ -64,6 +64,8 @@ 'renderer/gpu/input_event_filter.h', 'renderer/idle_user_detector.cc', 'renderer/idle_user_detector.h', + 'renderer/input_tag_speech_dispatcher.cc', + 'renderer/input_tag_speech_dispatcher.h', 'renderer/java/java_bridge_channel.cc', 'renderer/java/java_bridge_channel.h', 'renderer/java/java_bridge_dispatcher.cc', @@ -172,8 +174,6 @@ 'renderer/renderer_webstoragearea_impl.h', 'renderer/renderer_webstoragenamespace_impl.cc', 'renderer/renderer_webstoragenamespace_impl.h', - 'renderer/speech_input_dispatcher.cc', - 'renderer/speech_input_dispatcher.h', 'renderer/text_input_client_observer.cc', 'renderer/text_input_client_observer.h', 'renderer/v8_value_converter_impl.cc', @@ -217,8 +217,8 @@ }], ['input_speech==0', { 'sources!': [ - 'renderer/speech_input_dispatcher.cc', - 'renderer/speech_input_dispatcher.h', + 'renderer/input_tag_speech_dispatcher.cc', + 'renderer/input_tag_speech_dispatcher.h', ] }], ['notifications==0', { diff --git a/content/public/browser/browser_context.h b/content/public/browser/browser_context.h index 60786dcf..7a4577e 100644 --- a/content/public/browser/browser_context.h +++ b/content/public/browser/browser_context.h @@ -40,7 +40,7 @@ class DownloadManager; class GeolocationPermissionContext; class IndexedDBContext; class ResourceContext; -class SpeechInputPreferences; +class SpeechRecognitionPreferences; // This class holds the context needed for a browsing session. // It lives on the UI thread. @@ -110,9 +110,9 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData { // Returns the geolocation permission context for this context. virtual GeolocationPermissionContext* GetGeolocationPermissionContext() = 0; - // Returns the speech input preferences. SpeechInputPreferences is a + // Returns the speech input preferences. SpeechRecognitionPreferences is a // ref counted class, so callers should take a reference if needed. - virtual SpeechInputPreferences* GetSpeechInputPreferences() = 0; + virtual SpeechRecognitionPreferences* GetSpeechRecognitionPreferences() = 0; // Returns true if the last time this context was open it was exited cleanly. // This doesn't belong here; http://crbug.com/90737 diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h index 19eb3b3..cca6ae2 100644 --- a/content/public/browser/content_browser_client.h +++ b/content/public/browser/content_browser_client.h @@ -26,6 +26,18 @@ class ResourceDispatcherHost; class SkBitmap; struct WebPreferences; +namespace content { +class AccessTokenStore; +class BrowserMainParts; +class RenderProcessHost; +class SiteInstance; +class SpeechRecognitionManagerDelegate; +class WebContents; +class WebContentsView; +struct MainFunctionParams; +struct ShowDesktopNotificationHostMsgParams; +} + namespace crypto { class CryptoModuleBlockingPasswordDelegate; } @@ -322,9 +334,10 @@ class ContentBrowserClient { // This is when it can optionally add a delegate or ResourceQueueDelegates. virtual void ResourceDispatcherHostCreated() = 0; - // Allows the embedder to return a delegate for the SpeechInputManager. The - // delegate will be owned by the manager. It's valid to return NULL. - virtual SpeechInputManagerDelegate* GetSpeechInputManagerDelegate() = 0; + // Allows the embedder to return a delegate for the SpeechRecognitionManager. + // The delegate will be owned by the manager. It's valid to return NULL. + virtual SpeechRecognitionManagerDelegate* + GetSpeechRecognitionManagerDelegate() = 0; // Getters for common objects. virtual ui::Clipboard* GetClipboard() = 0; diff --git a/content/public/browser/speech_input_manager.h b/content/public/browser/speech_recognition_manager.h index 409d5dc..89651c1 100644 --- a/content/public/browser/speech_input_manager.h +++ b/content/public/browser/speech_recognition_manager.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_PUBLIC_BROWSER_SPEECH_INPUT_MANAGER_H_ -#define CONTENT_PUBLIC_BROWSER_SPEECH_INPUT_MANAGER_H_ +#ifndef CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_MANAGER_H_ +#define CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_MANAGER_H_ #include "base/string16.h" #include "content/common/content_export.h" @@ -14,10 +14,10 @@ namespace content { // handles requests received from various render views and makes sure only one // of them can use speech recognition at a time. It also sends recognition // results and status events to the render views when required. -class SpeechInputManager { +class SpeechRecognitionManager { public: // Returns the singleton instance. - CONTENT_EXPORT static SpeechInputManager* GetInstance(); + CONTENT_EXPORT static SpeechRecognitionManager* GetInstance(); // Starts/restarts recognition for an existing request. virtual void StartRecognitionForRequest(int caller_id) = 0; @@ -33,7 +33,7 @@ class SpeechInputManager { virtual bool HasAudioInputDevices() = 0; // Used to determine if something else is currently making use of audio input. - virtual bool IsRecordingInProcess() = 0; + virtual bool IsCapturingAudio() = 0; // Returns a human readable string for the model/make of the active audio // input device for this computer. @@ -44,9 +44,9 @@ class SpeechInputManager { virtual void ShowAudioInputSettings() = 0; protected: - virtual ~SpeechInputManager() {} + virtual ~SpeechRecognitionManager() {} }; } // namespace content -#endif // CONTENT_PUBLIC_BROWSER_SPEECH_INPUT_MANAGER_H_ +#endif // CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_MANAGER_H_ diff --git a/content/public/browser/speech_input_manager_delegate.h b/content/public/browser/speech_recognition_manager_delegate.h index 348bfbe..dfe04c7 100644 --- a/content/public/browser/speech_input_manager_delegate.h +++ b/content/public/browser/speech_recognition_manager_delegate.h @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_PUBLIC_BROWSER_SPEECH_INPUT_MANAGER_DELEGATE_H_ -#define CONTENT_PUBLIC_BROWSER_SPEECH_INPUT_MANAGER_DELEGATE_H_ +#ifndef CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_ +#define CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_ #pragma once #include <string> -#include "content/public/common/speech_input_result.h" +#include "content/public/common/speech_recognition_result.h" namespace gfx { class Rect; @@ -16,11 +16,11 @@ class Rect; namespace content { -struct SpeechInputResult; +struct SpeechRecognitionResult; // Allows embedders to display the current state of recognition, for getting the // user's permission and for fetching optional request information. -class SpeechInputManagerDelegate { +class SpeechRecognitionManagerDelegate { public: // Describes the microphone errors that are reported via ShowMicError. enum MicError { @@ -28,7 +28,7 @@ class SpeechInputManagerDelegate { MIC_ERROR_DEVICE_IN_USE }; - virtual ~SpeechInputManagerDelegate() {} + virtual ~SpeechRecognitionManagerDelegate() {} // Get the optional request information if available. virtual void GetRequestInfo(bool* can_report_metrics, @@ -62,7 +62,7 @@ class SpeechInputManagerDelegate { // Called when there has been a error with the recognition. virtual void ShowRecognizerError(int caller_id, - SpeechInputError error) = 0; + SpeechRecognitionErrorCode error) = 0; // Called when recognition has ended or has been canceled. virtual void DoClose(int caller_id) = 0; @@ -70,4 +70,4 @@ class SpeechInputManagerDelegate { } // namespace content -#endif // CONTENT_PUBLIC_BROWSER_SPEECH_INPUT_MANAGER_DELEGATE_H_ +#endif // CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_ diff --git a/content/public/browser/speech_input_preferences.h b/content/public/browser/speech_recognition_preferences.h index e5a9420..c5682e2 100644 --- a/content/public/browser/speech_input_preferences.h +++ b/content/public/browser/speech_recognition_preferences.h @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_PUBLIC_BROWSER_SPEECH_INPUT_PREFERENCES_H_ -#define CONTENT_PUBLIC_BROWSER_SPEECH_INPUT_PREFERENCES_H_ +#ifndef CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_PREFERENCES_H_ +#define CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_PREFERENCES_H_ #pragma once #include "base/memory/ref_counted.h" namespace content { -class SpeechInputPreferences - : public base::RefCountedThreadSafe<SpeechInputPreferences> { +class SpeechRecognitionPreferences + : public base::RefCountedThreadSafe<SpeechRecognitionPreferences> { public: // Only to be called on the IO thread. virtual bool FilterProfanities() const = 0; @@ -19,12 +19,12 @@ class SpeechInputPreferences virtual void SetFilterProfanities(bool filter_profanities) = 0; protected: - virtual ~SpeechInputPreferences() {} + virtual ~SpeechRecognitionPreferences() {} private: - friend class base::RefCountedThreadSafe<SpeechInputPreferences>; + friend class base::RefCountedThreadSafe<SpeechRecognitionPreferences>; }; } // namespace content -#endif // CONTENT_PUBLIC_BROWSER_SPEECH_INPUT_PREFERENCES_H_ +#endif // CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_PREFERENCES_H_ diff --git a/content/public/browser/speech_recognizer.h b/content/public/browser/speech_recognizer.h index 32a8069..50c5c31 100644 --- a/content/public/browser/speech_recognizer.h +++ b/content/public/browser/speech_recognizer.h @@ -46,6 +46,6 @@ class SpeechRecognizer : public base::RefCountedThreadSafe<SpeechRecognizer> { virtual void CancelRecognition() = 0; }; -} // namespace speech_input +} // namespace speech #endif // CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNIZER_H_ diff --git a/content/public/browser/speech_recognizer_delegate.h b/content/public/browser/speech_recognizer_delegate.h index daf482a..14be404 100644 --- a/content/public/browser/speech_recognizer_delegate.h +++ b/content/public/browser/speech_recognizer_delegate.h @@ -6,7 +6,7 @@ #define CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNIZER_DELEGATE_H_ #pragma once -#include "content/public/common/speech_input_result.h" +#include "content/public/common/speech_recognition_result.h" namespace content { @@ -15,7 +15,7 @@ namespace content { class SpeechRecognizerDelegate { public: virtual void SetRecognitionResult(int caller_id, - const SpeechInputResult& result) = 0; + const SpeechRecognitionResult& result) = 0; // Invoked when the first audio packet was received from the audio capture // device. @@ -41,7 +41,8 @@ class SpeechRecognizerDelegate { // session has already been cancelled when this call is made and the DidXxxx // callbacks will not be issued. It is safe to destroy/release the // |SpeechRecognizer| object while processing this call. - virtual void OnRecognizerError(int caller_id, SpeechInputError error) = 0; + virtual void OnRecognizerError(int caller_id, + SpeechRecognitionErrorCode error) = 0; // At the start of recognition, a short amount of audio is recorded to // estimate the environment/background noise and this callback is issued diff --git a/content/public/common/speech_input_result.cc b/content/public/common/speech_input_result.cc deleted file mode 100644 index 3c9e1f3..0000000 --- a/content/public/common/speech_input_result.cc +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/public/common/speech_input_result.h" - -namespace content { - -SpeechInputResult::SpeechInputResult() - : error(SPEECH_INPUT_ERROR_NONE) { -} - -SpeechInputResult::~SpeechInputResult() { -} - -} // namespace content diff --git a/content/public/common/speech_input_result.h b/content/public/common/speech_input_result.h deleted file mode 100644 index 1e494c7..0000000 --- a/content/public/common/speech_input_result.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_PUBLIC_COMMON_SPEECH_INPUT_RESULT_H_ -#define CONTENT_PUBLIC_COMMON_SPEECH_INPUT_RESULT_H_ - -#include <vector> - -#include "base/basictypes.h" -#include "base/string16.h" -#include "content/common/content_export.h" - -namespace content { - -struct SpeechInputHypothesis { - string16 utterance; - double confidence; - - SpeechInputHypothesis() : confidence(0.0) {} - - SpeechInputHypothesis(const string16 utterance_value, double confidence_value) - : utterance(utterance_value), - confidence(confidence_value) { - } -}; - -typedef std::vector<SpeechInputHypothesis> SpeechInputHypothesisArray; - -// This enumeration follows the values described here: -// http://www.w3.org/2005/Incubator/htmlspeech/2010/10/google-api-draft.html#speech-input-error -enum SpeechInputError { - // There was no error. - SPEECH_INPUT_ERROR_NONE = 0, - // The user or a script aborted speech input. - SPEECH_INPUT_ERROR_ABORTED, - // There was an error with recording audio. - SPEECH_INPUT_ERROR_AUDIO, - // There was a network error. - SPEECH_INPUT_ERROR_NETWORK, - // No speech heard before timeout. - SPEECH_INPUT_ERROR_NO_SPEECH, - // Speech was heard, but could not be interpreted. - SPEECH_INPUT_ERROR_NO_MATCH, - // There was an error in the speech recognition grammar. - SPEECH_INPUT_ERROR_BAD_GRAMMAR, -}; - -struct CONTENT_EXPORT SpeechInputResult { - SpeechInputError error; - SpeechInputHypothesisArray hypotheses; - - SpeechInputResult(); - ~SpeechInputResult(); -}; - -} // namespace content - -#endif // CONTENT_PUBLIC_COMMON_SPEECH_INPUT_RESULT_H_ diff --git a/content/public/common/speech_recognition_result.cc b/content/public/common/speech_recognition_result.cc new file mode 100644 index 0000000..198b88e --- /dev/null +++ b/content/public/common/speech_recognition_result.cc @@ -0,0 +1,16 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/public/common/speech_recognition_result.h" + +namespace content { + +SpeechRecognitionResult::SpeechRecognitionResult() + : error(SPEECH_RECOGNITION_ERROR_NONE) { +} + +SpeechRecognitionResult::~SpeechRecognitionResult() { +} + +} diff --git a/content/public/common/speech_recognition_result.h b/content/public/common/speech_recognition_result.h new file mode 100644 index 0000000..e5efe5b --- /dev/null +++ b/content/public/common/speech_recognition_result.h @@ -0,0 +1,61 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_PUBLIC_COMMON_SPEECH_RECOGNITION_RESULT_H_ +#define CONTENT_PUBLIC_COMMON_SPEECH_RECOGNITION_RESULT_H_ + +#include <vector> + +#include "base/basictypes.h" +#include "base/string16.h" +#include "content/common/content_export.h" + +namespace content { + +struct SpeechRecognitionHypothesis { + string16 utterance; + double confidence; + + SpeechRecognitionHypothesis() : confidence(0.0) {} + + SpeechRecognitionHypothesis(const string16 utterance_value, + double confidence_value) + : utterance(utterance_value), + confidence(confidence_value) { + } +}; + +typedef std::vector<SpeechRecognitionHypothesis> + SpeechRecognitionHypothesisArray; + +// This enumeration follows the values described here: +// http://www.w3.org/2005/Incubator/htmlspeech/2010/10/google-api-draft.html#speech-input-error +enum SpeechRecognitionErrorCode { + // There was no error. + SPEECH_RECOGNITION_ERROR_NONE = 0, + // The user or a script aborted speech input. + SPEECH_RECOGNITION_ERROR_ABORTED, + // There was an error with recording audio. + SPEECH_RECOGNITION_ERROR_AUDIO, + // There was a network error. + SPEECH_RECOGNITION_ERROR_NETWORK, + // No speech heard before timeout. + SPEECH_RECOGNITION_ERROR_NO_SPEECH, + // Speech was heard, but could not be interpreted. + SPEECH_RECOGNITION_ERROR_NO_MATCH, + // There was an error in the speech recognition grammar. + SPEECH_RECOGNITION_ERROR_BAD_GRAMMAR, +}; + +struct CONTENT_EXPORT SpeechRecognitionResult { + SpeechRecognitionErrorCode error; + SpeechRecognitionHypothesisArray hypotheses; + + SpeechRecognitionResult(); + ~SpeechRecognitionResult(); +}; + +} // namespace content + +#endif // CONTENT_PUBLIC_COMMON_SPEECH_RECOGNITION_RESULT_H_ diff --git a/content/renderer/speech_input_dispatcher.cc b/content/renderer/input_tag_speech_dispatcher.cc index 8ffc69e..7aa6d9f 100644 --- a/content/renderer/speech_input_dispatcher.cc +++ b/content/renderer/input_tag_speech_dispatcher.cc @@ -1,11 +1,11 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/renderer/speech_input_dispatcher.h" +#include "content/renderer/input_tag_speech_dispatcher.h" #include "base/utf_string_conversions.h" -#include "content/common/speech_input_messages.h" +#include "content/common/speech_recognition_messages.h" #include "content/renderer/render_view_impl.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" @@ -25,38 +25,39 @@ using WebKit::WebInputElement; using WebKit::WebNode; using WebKit::WebView; -SpeechInputDispatcher::SpeechInputDispatcher( +InputTagSpeechDispatcher::InputTagSpeechDispatcher( RenderViewImpl* render_view, WebKit::WebSpeechInputListener* listener) : content::RenderViewObserver(render_view), listener_(listener) { } -bool SpeechInputDispatcher::OnMessageReceived(const IPC::Message& message) { +bool InputTagSpeechDispatcher::OnMessageReceived( + const IPC::Message& message) { bool handled = true; - IPC_BEGIN_MESSAGE_MAP(SpeechInputDispatcher, message) - IPC_MESSAGE_HANDLER(SpeechInputMsg_SetRecognitionResult, + IPC_BEGIN_MESSAGE_MAP(InputTagSpeechDispatcher, message) + IPC_MESSAGE_HANDLER(InputTagSpeechMsg_SetRecognitionResult, OnSpeechRecognitionResult) - IPC_MESSAGE_HANDLER(SpeechInputMsg_RecordingComplete, + IPC_MESSAGE_HANDLER(InputTagSpeechMsg_RecordingComplete, OnSpeechRecordingComplete) - IPC_MESSAGE_HANDLER(SpeechInputMsg_RecognitionComplete, + IPC_MESSAGE_HANDLER(InputTagSpeechMsg_RecognitionComplete, OnSpeechRecognitionComplete) - IPC_MESSAGE_HANDLER(SpeechInputMsg_ToggleSpeechInput, + IPC_MESSAGE_HANDLER(InputTagSpeechMsg_ToggleSpeechInput, OnSpeechRecognitionToggleSpeechInput) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; } -bool SpeechInputDispatcher::startRecognition( +bool InputTagSpeechDispatcher::startRecognition( int request_id, const WebKit::WebRect& element_rect, const WebKit::WebString& language, const WebKit::WebString& grammar, const WebKit::WebSecurityOrigin& origin) { - VLOG(1) << "SpeechInputDispatcher::startRecognition enter"; + VLOG(1) << "InputTagSpeechDispatcher::startRecognition enter"; - SpeechInputHostMsg_StartRecognition_Params params; + InputTagSpeechHostMsg_StartRecognition_Params params; params.grammar = UTF16ToUTF8(grammar); params.language = UTF16ToUTF8(language); params.origin_url = UTF16ToUTF8(origin.toString()); @@ -66,50 +67,51 @@ bool SpeechInputDispatcher::startRecognition( params.element_rect = element_rect; params.element_rect.Offset(-scroll.width(), -scroll.height()); - Send(new SpeechInputHostMsg_StartRecognition(params)); - VLOG(1) << "SpeechInputDispatcher::startRecognition exit"; + Send(new InputTagSpeechHostMsg_StartRecognition(params)); + VLOG(1) << "InputTagSpeechDispatcher::startRecognition exit"; return true; } -void SpeechInputDispatcher::cancelRecognition(int request_id) { - VLOG(1) << "SpeechInputDispatcher::cancelRecognition enter"; - Send(new SpeechInputHostMsg_CancelRecognition(routing_id(), request_id)); - VLOG(1) << "SpeechInputDispatcher::cancelRecognition exit"; +void InputTagSpeechDispatcher::cancelRecognition(int request_id) { + VLOG(1) << "InputTagSpeechDispatcher::cancelRecognition enter"; + Send(new InputTagSpeechHostMsg_CancelRecognition(routing_id(), request_id)); + VLOG(1) << "InputTagSpeechDispatcher::cancelRecognition exit"; } -void SpeechInputDispatcher::stopRecording(int request_id) { - VLOG(1) << "SpeechInputDispatcher::stopRecording enter"; - Send(new SpeechInputHostMsg_StopRecording(routing_id(), request_id)); - VLOG(1) << "SpeechInputDispatcher::stopRecording exit"; +void InputTagSpeechDispatcher::stopRecording(int request_id) { + VLOG(1) << "InputTagSpeechDispatcher::stopRecording enter"; + Send(new InputTagSpeechHostMsg_StopRecording(routing_id(), + request_id)); + VLOG(1) << "InputTagSpeechDispatcher::stopRecording exit"; } -void SpeechInputDispatcher::OnSpeechRecognitionResult( +void InputTagSpeechDispatcher::OnSpeechRecognitionResult( int request_id, - const content::SpeechInputResult& result) { - VLOG(1) << "SpeechInputDispatcher::OnSpeechRecognitionResult enter"; + const content::SpeechRecognitionResult& result) { + VLOG(1) << "InputTagSpeechDispatcher::OnSpeechRecognitionResult enter"; WebKit::WebSpeechInputResultArray webkit_result(result.hypotheses.size()); for (size_t i = 0; i < result.hypotheses.size(); ++i) { webkit_result[i].assign(result.hypotheses[i].utterance, result.hypotheses[i].confidence); } listener_->setRecognitionResult(request_id, webkit_result); - VLOG(1) << "SpeechInputDispatcher::OnSpeechRecognitionResult exit"; + VLOG(1) << "InputTagSpeechDispatcher::OnSpeechRecognitionResult exit"; } -void SpeechInputDispatcher::OnSpeechRecordingComplete(int request_id) { - VLOG(1) << "SpeechInputDispatcher::OnSpeechRecordingComplete enter"; +void InputTagSpeechDispatcher::OnSpeechRecordingComplete(int request_id) { + VLOG(1) << "InputTagSpeechDispatcher::OnSpeechRecordingComplete enter"; listener_->didCompleteRecording(request_id); - VLOG(1) << "SpeechInputDispatcher::OnSpeechRecordingComplete exit"; + VLOG(1) << "InputTagSpeechDispatcher::OnSpeechRecordingComplete exit"; } -void SpeechInputDispatcher::OnSpeechRecognitionComplete(int request_id) { - VLOG(1) << "SpeechInputDispatcher::OnSpeechRecognitionComplete enter"; +void InputTagSpeechDispatcher::OnSpeechRecognitionComplete(int request_id) { + VLOG(1) << "InputTagSpeechDispatcher::OnSpeechRecognitionComplete enter"; listener_->didCompleteRecognition(request_id); - VLOG(1) << "SpeechInputDispatcher::OnSpeechRecognitionComplete exit"; + VLOG(1) << "InputTagSpeechDispatcher::OnSpeechRecognitionComplete exit"; } -void SpeechInputDispatcher::OnSpeechRecognitionToggleSpeechInput() { - VLOG(1) << "SpeechInputDispatcher::OnSpeechRecognitionToggleSpeechInput"; +void InputTagSpeechDispatcher::OnSpeechRecognitionToggleSpeechInput() { + VLOG(1) <<"InputTagSpeechDispatcher::OnSpeechRecognitionToggleSpeechInput"; WebView* web_view = render_view()->GetWebView(); diff --git a/content/renderer/speech_input_dispatcher.h b/content/renderer/input_tag_speech_dispatcher.h index 174dd6a..dca92ab 100644 --- a/content/renderer/speech_input_dispatcher.h +++ b/content/renderer/input_tag_speech_dispatcher.h @@ -1,9 +1,9 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_RENDERER_SPEECH_INPUT_DISPATCHER_H_ -#define CONTENT_RENDERER_SPEECH_INPUT_DISPATCHER_H_ +#ifndef CONTENT_RENDERER_INPUT_TAG_SPEECH_DISPATCHER_H_ +#define CONTENT_RENDERER_INPUT_TAG_SPEECH_DISPATCHER_H_ #include "base/basictypes.h" #include "content/public/renderer/render_view_observer.h" @@ -12,20 +12,20 @@ class RenderViewImpl; namespace content { -struct SpeechInputResult; +struct SpeechRecognitionResult; } namespace WebKit { class WebSpeechInputListener; } -// SpeechInputDispatcher is a delegate for speech input messages used by WebKit. -// It's the complement of SpeechInputDispatcherHost (owned by RenderViewHost). -class SpeechInputDispatcher : public content::RenderViewObserver, - public WebKit::WebSpeechInputController { +// InputTagSpeechDispatcher is a delegate for messages used by WebKit. It's +// the complement of InputTagSpeechDispatcherHost (owned by RenderViewHost). +class InputTagSpeechDispatcher : public content::RenderViewObserver, + public WebKit::WebSpeechInputController { public: - SpeechInputDispatcher(RenderViewImpl* render_view, - WebKit::WebSpeechInputListener* listener); + InputTagSpeechDispatcher(RenderViewImpl* render_view, + WebKit::WebSpeechInputListener* listener); private: // RenderView::Observer implementation. @@ -41,15 +41,15 @@ class SpeechInputDispatcher : public content::RenderViewObserver, virtual void cancelRecognition(int request_id); virtual void stopRecording(int request_id); - void OnSpeechRecognitionResult(int request_id, - const content::SpeechInputResult& result); + void OnSpeechRecognitionResult( + int request_id, const content::SpeechRecognitionResult& result); void OnSpeechRecordingComplete(int request_id); void OnSpeechRecognitionComplete(int request_id); void OnSpeechRecognitionToggleSpeechInput(); WebKit::WebSpeechInputListener* listener_; - DISALLOW_COPY_AND_ASSIGN(SpeechInputDispatcher); + DISALLOW_COPY_AND_ASSIGN(InputTagSpeechDispatcher); }; -#endif // CHROME_RENDERER_SPEECH_INPUT_DISPATCHER_H_ +#endif // CONTENT_RENDERER_INPUT_TAG_SPEECH_DISPATCHER_H_ diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 9f34b6c..fcd507d 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -56,6 +56,7 @@ #include "content/renderer/external_popup_menu.h" #include "content/renderer/geolocation_dispatcher.h" #include "content/renderer/idle_user_detector.h" +#include "content/renderer/input_tag_speech_dispatcher.h" #include "content/renderer/web_intents_host.h" #include "content/renderer/java/java_bridge_dispatcher.h" #include "content/renderer/load_progress_tracker.h" @@ -78,7 +79,6 @@ #include "content/renderer/renderer_accessibility.h" #include "content/renderer/renderer_webapplicationcachehost_impl.h" #include "content/renderer/renderer_webstoragenamespace_impl.h" -#include "content/renderer/speech_input_dispatcher.h" #include "content/renderer/text_input_client_observer.h" #include "content/renderer/v8_value_converter_impl.h" #include "content/renderer/web_ui_bindings.h" @@ -444,7 +444,7 @@ RenderViewImpl::RenderViewImpl( queried_for_swapbuffers_complete_callback_(false), ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), geolocation_dispatcher_(NULL), - speech_input_dispatcher_(NULL), + input_tag_speech_dispatcher_(NULL), device_orientation_dispatcher_(NULL), media_stream_dispatcher_(NULL), p2p_socket_dispatcher_(NULL), @@ -4910,10 +4910,11 @@ WebKit::WebGeolocationClient* RenderViewImpl::geolocationClient() { WebKit::WebSpeechInputController* RenderViewImpl::speechInputController( WebKit::WebSpeechInputListener* listener) { #if defined(ENABLE_INPUT_SPEECH) - if (!speech_input_dispatcher_) - speech_input_dispatcher_ = new SpeechInputDispatcher(this, listener); + if (!input_tag_speech_dispatcher_) + input_tag_speech_dispatcher_ = + new InputTagSpeechDispatcher(this, listener); #endif - return speech_input_dispatcher_; + return input_tag_speech_dispatcher_; } WebKit::WebDeviceOrientationClient* RenderViewImpl::deviceOrientationClient() { diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h index a7c893b..b253f53 100644 --- a/content/renderer/render_view_impl.h +++ b/content/renderer/render_view_impl.h @@ -76,7 +76,7 @@ struct PP_NetAddress_Private; class RenderWidgetFullscreenPepper; class RendererAccessibility; class SkBitmap; -class SpeechInputDispatcher; +class InputTagSpeechDispatcher; struct ViewMsg_Navigate_Params; struct ViewMsg_StopFinding_Params; struct ViewMsg_SwapOut_Params; @@ -1179,7 +1179,7 @@ class RenderViewImpl : public RenderWidget, WebIntentsHost* intents_host_; // The speech dispatcher attached to this view, lazily initialized. - SpeechInputDispatcher* speech_input_dispatcher_; + InputTagSpeechDispatcher* input_tag_speech_dispatcher_; // Device orientation dispatcher attached to this view; lazily initialized. DeviceOrientationDispatcher* device_orientation_dispatcher_; diff --git a/content/shell/shell_browser_context.cc b/content/shell/shell_browser_context.cc index f617b23..4872dc6 100644 --- a/content/shell/shell_browser_context.cc +++ b/content/shell/shell_browser_context.cc @@ -13,7 +13,7 @@ #include "content/browser/download/download_manager_impl.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/geolocation_permission_context.h" -#include "content/public/browser/speech_input_preferences.h" +#include "content/public/browser/speech_recognition_preferences.h" #include "content/shell/shell_browser_main.h" #include "content/shell/shell_download_manager_delegate.h" #include "content/shell/shell_resource_context.h" @@ -63,12 +63,12 @@ class ShellGeolocationPermissionContext : public GeolocationPermissionContext { DISALLOW_COPY_AND_ASSIGN(ShellGeolocationPermissionContext); }; -class ShellSpeechInputPreferences : public SpeechInputPreferences { +class ShellSpeechRecognitionPreferences : public SpeechRecognitionPreferences { public: - ShellSpeechInputPreferences() { + ShellSpeechRecognitionPreferences() { } - // Overridden from SpeechInputPreferences: + // Overridden from SpeechRecognitionPreferences: virtual bool FilterProfanities() const OVERRIDE { return false; } @@ -77,7 +77,7 @@ class ShellSpeechInputPreferences : public SpeechInputPreferences { } private: - DISALLOW_COPY_AND_ASSIGN(ShellSpeechInputPreferences); + DISALLOW_COPY_AND_ASSIGN(ShellSpeechRecognitionPreferences); }; } // namespace @@ -170,10 +170,11 @@ GeolocationPermissionContext* return geolocation_permission_context_; } -SpeechInputPreferences* ShellBrowserContext::GetSpeechInputPreferences() { - if (!speech_input_preferences_.get()) - speech_input_preferences_ = new ShellSpeechInputPreferences(); - return speech_input_preferences_.get(); +SpeechRecognitionPreferences* + ShellBrowserContext::GetSpeechRecognitionPreferences() { + if (!speech_recognition_preferences_.get()) + speech_recognition_preferences_ = new ShellSpeechRecognitionPreferences(); + return speech_recognition_preferences_.get(); } bool ShellBrowserContext::DidLastSessionExitCleanly() { diff --git a/content/shell/shell_browser_context.h b/content/shell/shell_browser_context.h index 9fbccab..581febb 100644 --- a/content/shell/shell_browser_context.h +++ b/content/shell/shell_browser_context.h @@ -37,7 +37,8 @@ class ShellBrowserContext : public BrowserContext { virtual ResourceContext* GetResourceContext() OVERRIDE; virtual GeolocationPermissionContext* GetGeolocationPermissionContext() OVERRIDE; - virtual SpeechInputPreferences* GetSpeechInputPreferences() OVERRIDE; + virtual SpeechRecognitionPreferences* + GetSpeechRecognitionPreferences() OVERRIDE; virtual bool DidLastSessionExitCleanly() OVERRIDE; virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; @@ -49,7 +50,7 @@ class ShellBrowserContext : public BrowserContext { scoped_refptr<DownloadManager> download_manager_; scoped_refptr<net::URLRequestContextGetter> url_request_getter_; scoped_refptr<GeolocationPermissionContext> geolocation_permission_context_; - scoped_refptr<SpeechInputPreferences> speech_input_preferences_; + scoped_refptr<SpeechRecognitionPreferences> speech_recognition_preferences_; ShellBrowserMainParts* shell_main_parts_; diff --git a/content/shell/shell_content_browser_client.cc b/content/shell/shell_content_browser_client.cc index d29b4ec..dfc7344 100644 --- a/content/shell/shell_content_browser_client.cc +++ b/content/shell/shell_content_browser_client.cc @@ -283,8 +283,8 @@ std::string ShellContentBrowserClient::GetWorkerProcessTitle( void ShellContentBrowserClient::ResourceDispatcherHostCreated() { } -SpeechInputManagerDelegate* - ShellContentBrowserClient::GetSpeechInputManagerDelegate() { +SpeechRecognitionManagerDelegate* + ShellContentBrowserClient::GetSpeechRecognitionManagerDelegate() { return NULL; } diff --git a/content/shell/shell_content_browser_client.h b/content/shell/shell_content_browser_client.h index 08eaa71..5db7a3b 100644 --- a/content/shell/shell_content_browser_client.h +++ b/content/shell/shell_content_browser_client.h @@ -146,7 +146,8 @@ class ShellContentBrowserClient : public ContentBrowserClient { virtual std::string GetWorkerProcessTitle( const GURL& url, content::ResourceContext* context) OVERRIDE; virtual void ResourceDispatcherHostCreated() OVERRIDE; - virtual SpeechInputManagerDelegate* GetSpeechInputManagerDelegate() OVERRIDE; + virtual SpeechRecognitionManagerDelegate* + GetSpeechRecognitionManagerDelegate() OVERRIDE; virtual ui::Clipboard* GetClipboard() OVERRIDE; virtual net::NetLog* GetNetLog() OVERRIDE; virtual AccessTokenStore* CreateAccessTokenStore() OVERRIDE; diff --git a/content/test/test_browser_context.cc b/content/test/test_browser_context.cc index 8510603..9943ac0 100644 --- a/content/test/test_browser_context.cc +++ b/content/test/test_browser_context.cc @@ -64,8 +64,8 @@ TestBrowserContext::GetGeolocationPermissionContext() { return NULL; } -content::SpeechInputPreferences* -TestBrowserContext::GetSpeechInputPreferences() { +content::SpeechRecognitionPreferences* +TestBrowserContext::GetSpeechRecognitionPreferences() { return NULL; } diff --git a/content/test/test_browser_context.h b/content/test/test_browser_context.h index f522fa5..4002320 100644 --- a/content/test/test_browser_context.h +++ b/content/test/test_browser_context.h @@ -39,7 +39,8 @@ class TestBrowserContext : public content::BrowserContext { virtual content::ResourceContext* GetResourceContext() OVERRIDE; virtual content::GeolocationPermissionContext* GetGeolocationPermissionContext() OVERRIDE; - virtual content::SpeechInputPreferences* GetSpeechInputPreferences() OVERRIDE; + virtual content::SpeechRecognitionPreferences* + GetSpeechRecognitionPreferences() OVERRIDE; virtual bool DidLastSessionExitCleanly() OVERRIDE; virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h index 80ce912..1a7555b 100644 --- a/ipc/ipc_message_utils.h +++ b/ipc/ipc_message_utils.h @@ -66,7 +66,7 @@ enum IPCMessageStart { DOMStorageMsgStart, IndexedDBMsgStart, PepperFileMsgStart, - SpeechInputMsgStart, + SpeechRecognitionMsgStart, PepperMsgStart, AutofillMsgStart, SafeBrowsingMsgStart, |