| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h" | 5 #include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 // event (corresponding to the old session that should be aborted) can be | 266 // event (corresponding to the old session that should be aborted) can be |
| 267 // received after a new session (corresponding to the 2nd click) is started. | 267 // received after a new session (corresponding to the 2nd click) is started. |
| 268 if (GetBubbleController()->GetActiveSessionID() != session_id) | 268 if (GetBubbleController()->GetActiveSessionID() != session_id) |
| 269 return; | 269 return; |
| 270 | 270 |
| 271 // Note, the session might have been destroyed, therefore avoid calls to the | 271 // Note, the session might have been destroyed, therefore avoid calls to the |
| 272 // manager which imply its existance (e.g., GetSessionContext()). | 272 // manager which imply its existance (e.g., GetSessionContext()). |
| 273 GetBubbleController()->CloseBubble(); | 273 GetBubbleController()->CloseBubble(); |
| 274 last_session_config_.reset(); | 274 last_session_config_.reset(); |
| 275 | 275 |
| 276 // If the user clicks outside the bubble while capturing audio we abort the | 276 // Clicking outside the bubble means we should abort. |
| 277 // session. Otherwise, i.e. audio capture is ended and we are just waiting for | 277 SpeechRecognitionManager::GetInstance()->AbortSession(session_id); |
| 278 // results, this activity is carried silently in background. | |
| 279 if (SpeechRecognitionManager::GetInstance()->IsCapturingAudio()) | |
| 280 SpeechRecognitionManager::GetInstance()->AbortSession(session_id); | |
| 281 } | 278 } |
| 282 | 279 |
| 283 void ChromeSpeechRecognitionManagerDelegate::RestartLastSession() { | 280 void ChromeSpeechRecognitionManagerDelegate::RestartLastSession() { |
| 284 DCHECK(last_session_config_.get()); | 281 DCHECK(last_session_config_.get()); |
| 285 SpeechRecognitionManager* manager = SpeechRecognitionManager::GetInstance(); | 282 SpeechRecognitionManager* manager = SpeechRecognitionManager::GetInstance(); |
| 286 const int new_session_id = manager->CreateSession(*last_session_config_); | 283 const int new_session_id = manager->CreateSession(*last_session_config_); |
| 287 DCHECK_NE(SpeechRecognitionManager::kSessionIDInvalid, new_session_id); | 284 DCHECK_NE(SpeechRecognitionManager::kSessionIDInvalid, new_session_id); |
| 288 last_session_config_.reset(); | 285 last_session_config_.reset(); |
| 289 manager->StartSession(new_session_id); | 286 manager->StartSession(new_session_id); |
| 290 } | 287 } |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 | 567 |
| 571 SpeechRecognitionTrayIconController* | 568 SpeechRecognitionTrayIconController* |
| 572 ChromeSpeechRecognitionManagerDelegate::GetTrayIconController() { | 569 ChromeSpeechRecognitionManagerDelegate::GetTrayIconController() { |
| 573 if (!tray_icon_controller_.get()) | 570 if (!tray_icon_controller_.get()) |
| 574 tray_icon_controller_ = new SpeechRecognitionTrayIconController(); | 571 tray_icon_controller_ = new SpeechRecognitionTrayIconController(); |
| 575 return tray_icon_controller_.get(); | 572 return tray_icon_controller_.get(); |
| 576 } | 573 } |
| 577 | 574 |
| 578 | 575 |
| 579 } // namespace speech | 576 } // namespace speech |
| OLD | NEW |