Index: chrome/browser/speech/extension_speech_input_manager.cc |
diff --git a/chrome/browser/extensions/speech_input/extension_speech_input_manager.cc b/chrome/browser/speech/extension_speech_input_manager.cc |
similarity index 92% |
rename from chrome/browser/extensions/speech_input/extension_speech_input_manager.cc |
rename to chrome/browser/speech/extension_speech_input_manager.cc |
index b8c6bf520686d37818b07b7c2e14781955cb29c5..6460657733ae838cc61d9febcefc285846d2c310 100644 |
--- a/chrome/browser/extensions/speech_input/extension_speech_input_manager.cc |
+++ b/chrome/browser/speech/extension_speech_input_manager.cc |
@@ -2,20 +2,24 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/browser/extensions/speech_input/extension_speech_input_manager.h" |
+#include "chrome/browser/speech/extension_speech_input_manager.h" |
#include "base/bind.h" |
#include "base/json/json_writer.h" |
#include "base/utf_string_conversions.h" |
#include "base/values.h" |
#include "chrome/browser/extensions/extension_event_router.h" |
-#include "chrome/browser/extensions/speech_input/extension_speech_input_api_constants.h" |
+#include "chrome/browser/extensions/extension_service.h" |
+#include "chrome/browser/prefs/pref_service.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/profiles/profile_dependency_manager.h" |
#include "chrome/browser/profiles/profile_keyed_service.h" |
#include "chrome/browser/profiles/profile_keyed_service_factory.h" |
+#include "chrome/browser/speech/extension_speech_input_api_constants.h" |
+#include "chrome/browser/speech/extension_speech_input_notification_ui.h" |
#include "chrome/common/chrome_notification_types.h" |
#include "chrome/common/extensions/extension.h" |
+#include "chrome/common/pref_names.h" |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/notification_service.h" |
@@ -118,7 +122,8 @@ ExtensionSpeechInterface::~ExtensionSpeechInterface() { |
ExtensionSpeechInputManager::ExtensionSpeechInputManager(Profile* profile) |
: profile_(profile), |
state_(kIdle), |
- speech_interface_(NULL) { |
+ speech_interface_(NULL), |
+ notification_(profile) { |
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
content::Source<Profile>(profile_)); |
} |
@@ -157,6 +162,7 @@ void ExtensionSpeechInputManager::ShutdownOnUIThread() { |
base::AutoLock auto_lock(state_lock_); |
DCHECK(state_ != kShutdown); |
if (state_ != kIdle) { |
+ notification_.Hide(); |
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
base::Bind(&ExtensionSpeechInputManager::ForceStopOnIOThread, this)); |
} |
@@ -273,6 +279,20 @@ void ExtensionSpeechInputManager::DidStartReceivingAudioOnUIThread() { |
VLOG(1) << "State changed to recording"; |
state_ = kRecording; |
+ const Extension* extension = profile_->GetExtensionService()-> |
+ GetExtensionById(extension_id_in_use_, true); |
+ DCHECK(extension); |
+ |
+ bool show_notification = !profile_->GetPrefs()->GetBoolean( |
+ prefs::kSpeechInputTrayNotificationShown); |
+ |
+ notification_.Show(extension, show_notification); |
+ |
+ if (show_notification) { |
+ profile_->GetPrefs()->SetBoolean( |
+ prefs::kSpeechInputTrayNotificationShown, true); |
+ } |
+ |
VLOG(1) << "Sending start notification"; |
content::NotificationService::current()->Notify( |
chrome::NOTIFICATION_EXTENSION_SPEECH_INPUT_RECORDING_STARTED, |
@@ -402,6 +422,9 @@ void ExtensionSpeechInputManager::DispatchError( |
if (state_ == kShutdown) |
return; |
+ if (state_ == kRecording) |
+ notification_.Hide(); |
+ |
extension_id = extension_id_in_use_; |
ResetToIdleState(); |
@@ -606,9 +629,27 @@ void ExtensionSpeechInputManager::StopSucceededOnUIThread() { |
std::string extension_id = extension_id_in_use_; |
ResetToIdleState(); |
+ notification_.Hide(); |
+ |
content::NotificationService::current()->Notify( |
chrome::NOTIFICATION_EXTENSION_SPEECH_INPUT_RECORDING_STOPPED, |
// Guarded by the state_ == kShutdown check. |
content::Source<Profile>(profile_), |
content::Details<std::string>(&extension_id)); |
} |
+ |
+void ExtensionSpeechInputManager::SetInputVolume(int caller_id, |
+ float volume, |
+ float noise_volume) { |
+ DCHECK_EQ(caller_id, kSpeechCallerId); |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
+ base::Bind(&ExtensionSpeechInputManager::SetInputVolumeOnUIThread, |
+ this, volume)); |
+} |
+ |
+void ExtensionSpeechInputManager::SetInputVolumeOnUIThread( |
+ float volume) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ notification_.SetVUMeterVolume(volume); |
+} |