| 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/speech_input_extension_manager.h" | 5 #include "chrome/browser/speech/speech_input_extension_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 } | 333 } |
| 334 | 334 |
| 335 VLOG(1) << "Sending start notification"; | 335 VLOG(1) << "Sending start notification"; |
| 336 content::NotificationService::current()->Notify( | 336 content::NotificationService::current()->Notify( |
| 337 chrome::NOTIFICATION_EXTENSION_SPEECH_INPUT_RECORDING_STARTED, | 337 chrome::NOTIFICATION_EXTENSION_SPEECH_INPUT_RECORDING_STARTED, |
| 338 content::Source<Profile>(profile_), | 338 content::Source<Profile>(profile_), |
| 339 content::Details<std::string>(&extension_id_in_use_)); | 339 content::Details<std::string>(&extension_id_in_use_)); |
| 340 } | 340 } |
| 341 | 341 |
| 342 void SpeechInputExtensionManager::OnRecognitionError( | 342 void SpeechInputExtensionManager::OnRecognitionError( |
| 343 int caller_id, const content::SpeechRecognitionErrorCode& error) { | 343 int caller_id, const content::SpeechRecognitionError& error) { |
| 344 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 344 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 345 DCHECK_EQ(caller_id, kSpeechCallerId); | 345 DCHECK_EQ(caller_id, kSpeechCallerId); |
| 346 VLOG(1) << "OnRecognitionError: " << error; | 346 VLOG(1) << "OnRecognitionError: " << error.code; |
| 347 | 347 |
| 348 base::AutoLock auto_lock(state_lock_); | 348 base::AutoLock auto_lock(state_lock_); |
| 349 if (state_ == kShutdown) | 349 if (state_ == kShutdown) |
| 350 return; | 350 return; |
| 351 | 351 |
| 352 // Release the recognizer object. | 352 // Release the recognizer object. |
| 353 GetSpeechInputExtensionInterface()->StopRecording(true); | 353 GetSpeechInputExtensionInterface()->StopRecording(true); |
| 354 | 354 |
| 355 std::string event_error_code; | 355 std::string event_error_code; |
| 356 bool report_to_event = true; | 356 bool report_to_event = true; |
| 357 | 357 |
| 358 switch (error) { | 358 switch (error.code) { |
| 359 case content::SPEECH_RECOGNITION_ERROR_NONE: | 359 case content::SPEECH_RECOGNITION_ERROR_NONE: |
| 360 break; | 360 break; |
| 361 | 361 |
| 362 case content::SPEECH_RECOGNITION_ERROR_AUDIO: | 362 case content::SPEECH_RECOGNITION_ERROR_AUDIO: |
| 363 if (state_ == kStarting) { | 363 if (state_ == kStarting) { |
| 364 event_error_code = kErrorUnableToStart; | 364 event_error_code = kErrorUnableToStart; |
| 365 report_to_event = false; | 365 report_to_event = false; |
| 366 } else { | 366 } else { |
| 367 event_error_code = kErrorCaptureError; | 367 event_error_code = kErrorCaptureError; |
| 368 } | 368 } |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 base::Bind(&SpeechInputExtensionManager::SetInputVolumeOnUIThread, | 721 base::Bind(&SpeechInputExtensionManager::SetInputVolumeOnUIThread, |
| 722 this, volume)); | 722 this, volume)); |
| 723 } | 723 } |
| 724 | 724 |
| 725 void SpeechInputExtensionManager::SetInputVolumeOnUIThread( | 725 void SpeechInputExtensionManager::SetInputVolumeOnUIThread( |
| 726 float volume) { | 726 float volume) { |
| 727 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 727 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 728 DCHECK(notification_.get()); | 728 DCHECK(notification_.get()); |
| 729 notification_->SetVUMeterVolume(volume); | 729 notification_->SetVUMeterVolume(volume); |
| 730 } | 730 } |
| OLD | NEW |