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" |
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/browser/speech/speech_recognizer.h" | |
23 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
24 #include "content/public/browser/notification_registrar.h" | 23 #include "content/public/browser/notification_registrar.h" |
25 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
26 #include "content/public/browser/resource_context.h" | 25 #include "content/public/browser/resource_context.h" |
27 #include "content/public/common/speech_input_result.h" | 26 #include "content/public/common/speech_input_result.h" |
28 | 27 |
29 using content::BrowserThread; | 28 using content::BrowserThread; |
30 using speech_input::SpeechRecognizer; | 29 using speech_input::SpeechRecognizer; |
31 | 30 |
32 namespace { | 31 namespace { |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 } | 590 } |
592 | 591 |
593 void SpeechInputExtensionManager::IsRecordingOnUIThread( | 592 void SpeechInputExtensionManager::IsRecordingOnUIThread( |
594 const IsRecordingCallback& callback, | 593 const IsRecordingCallback& callback, |
595 bool result) { | 594 bool result) { |
596 BrowserThread::CurrentlyOn(BrowserThread::UI); | 595 BrowserThread::CurrentlyOn(BrowserThread::UI); |
597 callback.Run(result); | 596 callback.Run(result); |
598 } | 597 } |
599 | 598 |
600 void SpeechInputExtensionManager::StartRecording( | 599 void SpeechInputExtensionManager::StartRecording( |
601 content::SpeechRecognizerDelegate* delegate, | 600 speech_input::SpeechRecognizerDelegate* delegate, |
602 net::URLRequestContextGetter* context_getter, | 601 net::URLRequestContextGetter* context_getter, |
603 content::ResourceContext* resource_context, | 602 content::ResourceContext* resource_context, |
604 int caller_id, | 603 int caller_id, |
605 const std::string& language, | 604 const std::string& language, |
606 const std::string& grammar, | 605 const std::string& grammar, |
607 bool filter_profanities) { | 606 bool filter_profanities) { |
608 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 607 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
609 DCHECK(resource_context); | 608 DCHECK(resource_context); |
610 DCHECK(!recognizer_); | 609 DCHECK(!recognizer_); |
611 recognizer_ = new SpeechRecognizer(delegate, caller_id, language, grammar, | 610 recognizer_ = new SpeechRecognizer(delegate, caller_id, language, grammar, |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 base::Bind(&SpeechInputExtensionManager::SetInputVolumeOnUIThread, | 715 base::Bind(&SpeechInputExtensionManager::SetInputVolumeOnUIThread, |
717 this, volume)); | 716 this, volume)); |
718 } | 717 } |
719 | 718 |
720 void SpeechInputExtensionManager::SetInputVolumeOnUIThread( | 719 void SpeechInputExtensionManager::SetInputVolumeOnUIThread( |
721 float volume) { | 720 float volume) { |
722 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 721 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
723 DCHECK(notification_.get()); | 722 DCHECK(notification_.get()); |
724 notification_->SetVUMeterVolume(volume); | 723 notification_->SetVUMeterVolume(volume); |
725 } | 724 } |
OLD | NEW |