diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-24 23:51:04 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-24 23:51:04 +0000 |
commit | 3bc0b560d93f137fc0f4a0ca16ef722d9dc80652 (patch) | |
tree | e3f984afce2c62319ea58b2d1fb952735406ce27 /chrome/browser/speech/chrome_speech_input_manager.h | |
parent | e6ad33a0c9538029a6835807e0f5444193e33327 (diff) | |
download | chromium_src-3bc0b560d93f137fc0f4a0ca16ef722d9dc80652.zip chromium_src-3bc0b560d93f137fc0f4a0ca16ef722d9dc80652.tar.gz chromium_src-3bc0b560d93f137fc0f4a0ca16ef722d9dc80652.tar.bz2 |
Get rid of link dependency from content to chrome. Make it get the SpeechInputManager through the embedder interface.
I've renamed Chrome's SpeechInputManagerImpl to ChromeSpeechInputManager, to match what we've been doing for other chrome implementations of content classes.
BUG=76697
Review URL: http://codereview.chromium.org/7729001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98147 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/speech/chrome_speech_input_manager.h')
-rw-r--r-- | chrome/browser/speech/chrome_speech_input_manager.h | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/chrome/browser/speech/chrome_speech_input_manager.h b/chrome/browser/speech/chrome_speech_input_manager.h new file mode 100644 index 0000000..6754761 --- /dev/null +++ b/chrome/browser/speech/chrome_speech_input_manager.h @@ -0,0 +1,88 @@ +// 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_H_ +#define CHROME_BROWSER_SPEECH_CHROME_SPEECH_INPUT_MANAGER_H_ + +#include <map> + +#include "base/memory/ref_counted.h" +#include "base/memory/singleton.h" +#include "chrome/browser/speech/speech_input_bubble_controller.h" +#include "content/browser/speech/speech_input_manager.h" +#include "content/browser/speech/speech_recognizer.h" + +namespace speech_input { + +class ChromeSpeechInputManager : public SpeechInputManager, + public SpeechInputBubbleControllerDelegate, + public SpeechRecognizerDelegate { + public: + static ChromeSpeechInputManager* GetInstance(); + + // SpeechInputManager methods. + virtual void StartRecognition(SpeechInputManagerDelegate* delegate, + int caller_id, + int render_process_id, + int render_view_id, + const gfx::Rect& element_rect, + const std::string& language, + const std::string& grammar, + const std::string& origin_url); + virtual void CancelRecognition(int caller_id); + virtual void StopRecording(int caller_id); + virtual void CancelAllRequestsWithDelegate( + SpeechInputManagerDelegate* delegate); + + // SpeechRecognizer::Delegate methods. + virtual void DidStartReceivingAudio(int caller_id); + virtual void SetRecognitionResult(int caller_id, + bool error, + const SpeechInputResultArray& result); + virtual void DidCompleteRecording(int caller_id); + virtual void DidCompleteRecognition(int caller_id); + virtual void OnRecognizerError(int caller_id, + SpeechRecognizer::ErrorCode error); + virtual void DidCompleteEnvironmentEstimation(int caller_id); + virtual void SetInputVolume(int caller_id, float volume, float noise_volume); + + // SpeechInputBubbleController::Delegate methods. + virtual void InfoBubbleButtonClicked(int caller_id, + SpeechInputBubble::Button button); + virtual void InfoBubbleFocusChanged(int caller_id); + + private: + class OptionalRequestInfo; + + struct SpeechInputRequest { + SpeechInputManagerDelegate* delegate; + scoped_refptr<SpeechRecognizer> recognizer; + bool is_active; // Set to true when recording or recognition is going on. + }; + + // Private constructor to enforce singleton. + friend struct DefaultSingletonTraits<ChromeSpeechInputManager>; + ChromeSpeechInputManager(); + virtual ~ChromeSpeechInputManager(); + + bool HasPendingRequest(int caller_id) const; + SpeechInputManagerDelegate* GetDelegate(int caller_id) const; + + void CancelRecognitionAndInformDelegate(int caller_id); + + // Starts/restarts recognition for an existing request. + void StartRecognitionForRequest(int caller_id); + + typedef std::map<int, SpeechInputRequest> SpeechRecognizerMap; + SpeechRecognizerMap requests_; + int recording_caller_id_; + scoped_refptr<SpeechInputBubbleController> bubble_controller_; + scoped_refptr<OptionalRequestInfo> optional_request_info_; + + DISALLOW_COPY_AND_ASSIGN(ChromeSpeechInputManager); +}; + +} // namespace speech_input + +#endif // CHROME_BROWSER_SPEECH_CHROME_SPEECH_INPUT_MANAGER_H_ |