Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: chrome/browser/speech/speech_input_extension_manager.cc

Issue 9568002: Renamed speech input implementation from to speech_recognition_*. The namespace has been renamed fr… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "chrome/browser/extensions/extension_event_router.h" 11 #include "chrome/browser/extensions/extension_event_router.h"
12 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/prefs/pref_service.h" 13 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/profiles/profile_dependency_manager.h" 15 #include "chrome/browser/profiles/profile_dependency_manager.h"
16 #include "chrome/browser/profiles/profile_keyed_service.h" 16 #include "chrome/browser/profiles/profile_keyed_service.h"
17 #include "chrome/browser/profiles/profile_keyed_service_factory.h" 17 #include "chrome/browser/profiles/profile_keyed_service_factory.h"
18 #include "chrome/browser/speech/speech_input_extension_notification.h" 18 #include "chrome/browser/speech/speech_input_extension_notification.h"
19 #include "chrome/common/chrome_notification_types.h" 19 #include "chrome/common/chrome_notification_types.h"
20 #include "chrome/common/extensions/extension.h" 20 #include "chrome/common/extensions/extension.h"
21 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
22 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
23 #include "content/public/browser/notification_registrar.h" 23 #include "content/public/browser/notification_registrar.h"
24 #include "content/public/browser/notification_service.h" 24 #include "content/public/browser/notification_service.h"
25 #include "content/public/browser/speech_input_manager.h" 25 #include "content/public/browser/speech_recognition_manager.h"
26 #include "content/public/browser/speech_recognizer.h" 26 #include "content/public/browser/speech_recognizer.h"
27 #include "content/public/common/speech_input_result.h" 27 #include "content/public/common/speech_recognition_traits.h"
28 28
29 using content::BrowserThread; 29 using content::BrowserThread;
30 using content::SpeechInputManager; 30 using content::SpeechRecognitionManager;
31 31
32 namespace { 32 namespace {
33 33
34 const char kErrorNoRecordingDeviceFound[] = "noRecordingDeviceFound"; 34 const char kErrorNoRecordingDeviceFound[] = "noRecordingDeviceFound";
35 const char kErrorRecordingDeviceInUse[] = "recordingDeviceInUse"; 35 const char kErrorRecordingDeviceInUse[] = "recordingDeviceInUse";
36 const char kErrorUnableToStart[] = "unableToStart"; 36 const char kErrorUnableToStart[] = "unableToStart";
37 const char kErrorRequestDenied[] = "requestDenied"; 37 const char kErrorRequestDenied[] = "requestDenied";
38 const char kErrorRequestInProgress[] = "requestInProgress"; 38 const char kErrorRequestInProgress[] = "requestInProgress";
39 const char kErrorInvalidOperation[] = "invalidOperation"; 39 const char kErrorInvalidOperation[] = "invalidOperation";
40 40
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 return; 536 return;
537 537
538 if (!GetSpeechInputExtensionInterface()->HasAudioInputDevices()) { 538 if (!GetSpeechInputExtensionInterface()->HasAudioInputDevices()) {
539 BrowserThread::PostTask( 539 BrowserThread::PostTask(
540 BrowserThread::UI, FROM_HERE, 540 BrowserThread::UI, FROM_HERE,
541 base::Bind(&SpeechInputExtensionManager::DispatchError, this, 541 base::Bind(&SpeechInputExtensionManager::DispatchError, this,
542 std::string(kErrorNoRecordingDeviceFound), false)); 542 std::string(kErrorNoRecordingDeviceFound), false));
543 return; 543 return;
544 } 544 }
545 545
546 if (GetSpeechInputExtensionInterface()->IsRecordingInProcess()) { 546 if (GetSpeechInputExtensionInterface()->IsCapturingAudio()) {
547 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 547 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
548 base::Bind(&SpeechInputExtensionManager::DispatchError, this, 548 base::Bind(&SpeechInputExtensionManager::DispatchError, this,
549 std::string(kErrorRecordingDeviceInUse), false)); 549 std::string(kErrorRecordingDeviceInUse), false));
550 return; 550 return;
551 } 551 }
552 552
553 GetSpeechInputExtensionInterface()->StartRecording( 553 GetSpeechInputExtensionInterface()->StartRecording(
554 this, context_getter, kSpeechCallerId, language, grammar, 554 this, context_getter, kSpeechCallerId, language, grammar,
555 filter_profanities); 555 filter_profanities);
556 } 556 }
557 557
558 bool SpeechInputExtensionManager::HasAudioInputDevices() { 558 bool SpeechInputExtensionManager::HasAudioInputDevices() {
559 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 559 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
560 return SpeechInputManager::GetInstance()->HasAudioInputDevices(); 560 return SpeechRecognitionManager::GetInstance()->HasAudioInputDevices();
561 } 561 }
562 562
563 bool SpeechInputExtensionManager::IsRecordingInProcess() { 563 bool SpeechInputExtensionManager::IsCapturingAudio() {
564 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 564 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
565 return SpeechInputManager::GetInstance()->IsRecordingInProcess(); 565 return SpeechRecognitionManager::GetInstance()->IsCapturingAudio();
566 } 566 }
567 567
568 void SpeechInputExtensionManager::IsRecording( 568 void SpeechInputExtensionManager::IsRecording(
569 const IsRecordingCallback& callback) { 569 const IsRecordingCallback& callback) {
570 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 570 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
571 BrowserThread::PostTask( 571 BrowserThread::PostTask(
572 BrowserThread::IO, FROM_HERE, 572 BrowserThread::IO, FROM_HERE,
573 base::Bind(&SpeechInputExtensionManager::IsRecordingOnIOThread, 573 base::Bind(&SpeechInputExtensionManager::IsRecordingOnIOThread,
574 this, callback)); 574 this, callback));
575 } 575 }
576 576
577 void SpeechInputExtensionManager::IsRecordingOnIOThread( 577 void SpeechInputExtensionManager::IsRecordingOnIOThread(
578 const IsRecordingCallback& callback) { 578 const IsRecordingCallback& callback) {
579 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 579 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
580 580
581 bool result = GetSpeechInputExtensionInterface()->IsRecordingInProcess(); 581 bool result = GetSpeechInputExtensionInterface()->IsCapturingAudio();
582 BrowserThread::PostTask( 582 BrowserThread::PostTask(
583 BrowserThread::UI, FROM_HERE, 583 BrowserThread::UI, FROM_HERE,
584 base::Bind(&SpeechInputExtensionManager::IsRecordingOnUIThread, 584 base::Bind(&SpeechInputExtensionManager::IsRecordingOnUIThread,
585 this, callback, result)); 585 this, callback, result));
586 } 586 }
587 587
588 void SpeechInputExtensionManager::IsRecordingOnUIThread( 588 void SpeechInputExtensionManager::IsRecordingOnUIThread(
589 const IsRecordingCallback& callback, 589 const IsRecordingCallback& callback,
590 bool result) { 590 bool result) {
591 BrowserThread::CurrentlyOn(BrowserThread::UI); 591 BrowserThread::CurrentlyOn(BrowserThread::UI);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 base::Bind(&SpeechInputExtensionManager::SetInputVolumeOnUIThread, 708 base::Bind(&SpeechInputExtensionManager::SetInputVolumeOnUIThread,
709 this, volume)); 709 this, volume));
710 } 710 }
711 711
712 void SpeechInputExtensionManager::SetInputVolumeOnUIThread( 712 void SpeechInputExtensionManager::SetInputVolumeOnUIThread(
713 float volume) { 713 float volume) {
714 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 714 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
715 DCHECK(notification_.get()); 715 DCHECK(notification_.get());
716 notification_->SetVUMeterVolume(volume); 716 notification_->SetVUMeterVolume(volume);
717 } 717 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698