diff options
Diffstat (limited to 'chrome/browser/speech/speech_recognition_bubble_controller.cc')
| -rw-r--r-- | chrome/browser/speech/speech_recognition_bubble_controller.cc | 91 |
1 files changed, 46 insertions, 45 deletions
diff --git a/chrome/browser/speech/speech_recognition_bubble_controller.cc b/chrome/browser/speech/speech_recognition_bubble_controller.cc index f2b3f0b..fc66279 100644 --- a/chrome/browser/speech/speech_recognition_bubble_controller.cc +++ b/chrome/browser/speech/speech_recognition_bubble_controller.cc @@ -21,7 +21,7 @@ namespace speech { SpeechRecognitionBubbleController::SpeechRecognitionBubbleController( Delegate* delegate) : delegate_(delegate), - current_bubble_caller_id_(0), + current_bubble_session_id_(0), registrar_(new content::NotificationRegistrar) { } @@ -30,7 +30,7 @@ SpeechRecognitionBubbleController::~SpeechRecognitionBubbleController() { } void SpeechRecognitionBubbleController::CreateBubble( - int caller_id, + int session_id, int render_process_id, int render_view_id, const gfx::Rect& element_rect) { @@ -38,14 +38,15 @@ void SpeechRecognitionBubbleController::CreateBubble( BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, base::Bind(&SpeechRecognitionBubbleController::CreateBubble, this, - caller_id, render_process_id, render_view_id, element_rect)); + session_id, render_process_id, render_view_id, + element_rect)); return; } DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); WebContents* web_contents = tab_util::GetWebContentsByID(render_process_id, render_view_id); - DCHECK_EQ(0u, bubbles_.count(caller_id)); + DCHECK_EQ(0u, bubbles_.count(session_id)); SpeechRecognitionBubble* bubble = SpeechRecognitionBubble::Create( web_contents, this, element_rect); if (!bubble) { @@ -55,58 +56,58 @@ void SpeechRecognitionBubbleController::CreateBubble( BrowserThread::IO, FROM_HERE, base::Bind( &SpeechRecognitionBubbleController::InvokeDelegateButtonClicked, - this, caller_id, SpeechRecognitionBubble::BUTTON_CANCEL)); + this, session_id, SpeechRecognitionBubble::BUTTON_CANCEL)); return; } - bubbles_[caller_id] = bubble; + bubbles_[session_id] = bubble; - UpdateTabContentsSubscription(caller_id, BUBBLE_ADDED); + UpdateTabContentsSubscription(session_id, BUBBLE_ADDED); } -void SpeechRecognitionBubbleController::CloseBubble(int caller_id) { - ProcessRequestInUiThread(caller_id, REQUEST_CLOSE, string16(), 0, 0); +void SpeechRecognitionBubbleController::CloseBubble(int session_id) { + ProcessRequestInUiThread(session_id, REQUEST_CLOSE, string16(), 0, 0); } -void SpeechRecognitionBubbleController::SetBubbleWarmUpMode(int caller_id) { - ProcessRequestInUiThread(caller_id, REQUEST_SET_WARM_UP_MODE, +void SpeechRecognitionBubbleController::SetBubbleWarmUpMode(int session_id) { + ProcessRequestInUiThread(session_id, REQUEST_SET_WARM_UP_MODE, string16(), 0, 0); } -void SpeechRecognitionBubbleController::SetBubbleRecordingMode(int caller_id) { - ProcessRequestInUiThread(caller_id, REQUEST_SET_RECORDING_MODE, +void SpeechRecognitionBubbleController::SetBubbleRecordingMode(int session_id) { + ProcessRequestInUiThread(session_id, REQUEST_SET_RECORDING_MODE, string16(), 0, 0); } void SpeechRecognitionBubbleController::SetBubbleRecognizingMode( - int caller_id) { - ProcessRequestInUiThread(caller_id, REQUEST_SET_RECOGNIZING_MODE, + int session_id) { + ProcessRequestInUiThread(session_id, REQUEST_SET_RECOGNIZING_MODE, string16(), 0, 0); } void SpeechRecognitionBubbleController::SetBubbleInputVolume( - int caller_id, float volume, float noise_volume) { - ProcessRequestInUiThread(caller_id, REQUEST_SET_INPUT_VOLUME, string16(), + int session_id, float volume, float noise_volume) { + ProcessRequestInUiThread(session_id, REQUEST_SET_INPUT_VOLUME, string16(), volume, noise_volume); } -void SpeechRecognitionBubbleController::SetBubbleMessage(int caller_id, +void SpeechRecognitionBubbleController::SetBubbleMessage(int session_id, const string16& text) { - ProcessRequestInUiThread(caller_id, REQUEST_SET_MESSAGE, text, 0, 0); + ProcessRequestInUiThread(session_id, REQUEST_SET_MESSAGE, text, 0, 0); } void SpeechRecognitionBubbleController::UpdateTabContentsSubscription( - int caller_id, ManageSubscriptionAction action) { + int session_id, ManageSubscriptionAction action) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); // If there are any other bubbles existing for the same WebContents, we would // have subscribed to tab close notifications on their behalf and we need to // stay registered. So we don't change the subscription in such cases. - WebContents* web_contents = bubbles_[caller_id]->GetWebContents(); - for (BubbleCallerIdMap::iterator iter = bubbles_.begin(); + WebContents* web_contents = bubbles_[session_id]->GetWebContents(); + for (BubbleSessionIdMap::iterator iter = bubbles_.begin(); iter != bubbles_.end(); ++iter) { if (iter->second->GetWebContents() == web_contents && - iter->first != caller_id) { + iter->first != session_id) { // At least one other bubble exists for the same WebContents. So don't // make any change to the subscription. return; @@ -129,7 +130,7 @@ void SpeechRecognitionBubbleController::Observe( if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { // Cancel all bubbles and active recognition sessions for this tab. WebContents* web_contents = content::Source<WebContents>(source).ptr(); - BubbleCallerIdMap::iterator iter = bubbles_.begin(); + BubbleSessionIdMap::iterator iter = bubbles_.begin(); while (iter != bubbles_.end()) { if (iter->second->GetWebContents() == web_contents) { BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, @@ -150,29 +151,29 @@ void SpeechRecognitionBubbleController::Observe( } void SpeechRecognitionBubbleController::ProcessRequestInUiThread( - int caller_id, RequestType type, const string16& text, float volume, + int session_id, RequestType type, const string16& text, float volume, float noise_volume) { if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( &SpeechRecognitionBubbleController::ProcessRequestInUiThread, this, - caller_id, type, text, volume, noise_volume)); + session_id, type, text, volume, noise_volume)); return; } DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); // The bubble may have been closed before we got a chance to process this // request. So check before proceeding. - if (!bubbles_.count(caller_id)) + if (!bubbles_.count(session_id)) return; bool change_active_bubble = (type == REQUEST_SET_WARM_UP_MODE || type == REQUEST_SET_MESSAGE); if (change_active_bubble) { - if (current_bubble_caller_id_ && current_bubble_caller_id_ != caller_id) - bubbles_[current_bubble_caller_id_]->Hide(); - current_bubble_caller_id_ = caller_id; + if (current_bubble_session_id_ && current_bubble_session_id_ != session_id) + bubbles_[current_bubble_session_id_]->Hide(); + current_bubble_session_id_ = session_id; } - SpeechRecognitionBubble* bubble = bubbles_[caller_id]; + SpeechRecognitionBubble* bubble = bubbles_[session_id]; switch (type) { case REQUEST_SET_WARM_UP_MODE: bubble->SetWarmUpMode(); @@ -190,11 +191,11 @@ void SpeechRecognitionBubbleController::ProcessRequestInUiThread( bubble->SetInputVolume(volume, noise_volume); break; case REQUEST_CLOSE: - if (current_bubble_caller_id_ == caller_id) - current_bubble_caller_id_ = 0; - UpdateTabContentsSubscription(caller_id, BUBBLE_REMOVED); + if (current_bubble_session_id_ == session_id) + current_bubble_session_id_ = 0; + UpdateTabContentsSubscription(session_id, BUBBLE_REMOVED); delete bubble; - bubbles_.erase(caller_id); + bubbles_.erase(session_id); break; default: NOTREACHED(); @@ -208,37 +209,37 @@ void SpeechRecognitionBubbleController::ProcessRequestInUiThread( void SpeechRecognitionBubbleController::InfoBubbleButtonClicked( SpeechRecognitionBubble::Button button) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DCHECK(current_bubble_caller_id_); + DCHECK(current_bubble_session_id_); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind( &SpeechRecognitionBubbleController::InvokeDelegateButtonClicked, - this, current_bubble_caller_id_, button)); + this, current_bubble_session_id_, button)); } void SpeechRecognitionBubbleController::InfoBubbleFocusChanged() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DCHECK(current_bubble_caller_id_); + DCHECK(current_bubble_session_id_); - int old_bubble_caller_id = current_bubble_caller_id_; - current_bubble_caller_id_ = 0; + int old_bubble_session_id = current_bubble_session_id_; + current_bubble_session_id_ = 0; BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind( &SpeechRecognitionBubbleController::InvokeDelegateFocusChanged, - this, old_bubble_caller_id)); + this, old_bubble_session_id)); } void SpeechRecognitionBubbleController::InvokeDelegateButtonClicked( - int caller_id, SpeechRecognitionBubble::Button button) { - delegate_->InfoBubbleButtonClicked(caller_id, button); + int session_id, SpeechRecognitionBubble::Button button) { + delegate_->InfoBubbleButtonClicked(session_id, button); } void SpeechRecognitionBubbleController::InvokeDelegateFocusChanged( - int caller_id) { - delegate_->InfoBubbleFocusChanged(caller_id); + int session_id) { + delegate_->InfoBubbleFocusChanged(session_id); } } // namespace speech |
