Index: chrome/browser/speech/speech_input_extension_api.cc |
diff --git a/chrome/browser/extensions/speech_input/extension_speech_input_api.cc b/chrome/browser/speech/speech_input_extension_api.cc |
similarity index 70% |
rename from chrome/browser/extensions/speech_input/extension_speech_input_api.cc |
rename to chrome/browser/speech/speech_input_extension_api.cc |
index 48cf173d3338d524d8b88abf652a3eea5e8556fd..ec45c61f77bcfd5bec7aaf0c7a70efcd6b9229f4 100644 |
--- a/chrome/browser/extensions/speech_input/extension_speech_input_api.cc |
+++ b/chrome/browser/speech/speech_input_extension_api.cc |
@@ -2,18 +2,26 @@ |
// 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_api.h" |
+#include "chrome/browser/speech/speech_input_extension_api.h" |
#include "base/values.h" |
#include "chrome/browser/browser_process.h" |
-#include "chrome/browser/extensions/speech_input/extension_speech_input_api_constants.h" |
-#include "chrome/browser/extensions/speech_input/extension_speech_input_manager.h" |
#include "chrome/browser/profiles/profile.h" |
+#include "chrome/browser/speech/speech_input_extension_manager.h" |
#include "chrome/common/chrome_notification_types.h" |
#include "content/public/browser/notification_details.h" |
#include "content/public/browser/notification_source.h" |
-namespace constants = extension_speech_input_api_constants; |
+namespace { |
+ |
+const char kLanguageKey[] = "language"; |
+const char kGrammarKey[] = "grammar"; |
+const char kFilterProfanitiesKey[] = "filterProfanities"; |
+ |
+const char kDefaultGrammar[] = "builtin:dictation"; |
+const bool kDefaultFilterProfanities = true; |
+ |
+} // anonymous namespace |
SpeechInputAsyncFunction::SpeechInputAsyncFunction( |
int start_state, |
@@ -40,13 +48,13 @@ void SpeechInputAsyncFunction::Run() { |
return; |
} |
- ExtensionSpeechInputManager::State state = |
- ExtensionSpeechInputManager::GetForProfile(profile())->state(); |
+ SpeechInputExtensionManager::State state = |
+ SpeechInputExtensionManager::GetForProfile(profile())->state(); |
// RunImpl should be always called once independently of the state we're in, |
// otherwise we might miss requestDenied error situations. |
if (!expecting_transition_) { |
- ExtensionSpeechInputManager::State state_before_call = state; |
+ SpeechInputExtensionManager::State state_before_call = state; |
// Register before RunImpl to ensure it's received if generated. |
if (state_before_call == start_state_) { |
@@ -65,7 +73,7 @@ void SpeechInputAsyncFunction::Run() { |
// when called in a state different to the start one. |
DCHECK_EQ(state_before_call, start_state_); |
- state = ExtensionSpeechInputManager::GetForProfile(profile())->state(); |
+ state = SpeechInputExtensionManager::GetForProfile(profile())->state(); |
DCHECK_EQ(state, transition_state_); |
expecting_transition_ = true; |
} |
@@ -85,8 +93,8 @@ void SpeechInputAsyncFunction::Observe( |
DCHECK_EQ(profile(), content::Source<Profile>(source).ptr()); |
if (type == chrome::NOTIFICATION_EXTENSION_SPEECH_INPUT_FAILED) { |
- ExtensionSpeechInputManager::ExtensionError* error_details = |
- content::Details<ExtensionSpeechInputManager::ExtensionError>( |
+ SpeechInputExtensionManager::ExtensionError* error_details = |
+ content::Details<SpeechInputExtensionManager::ExtensionError>( |
details).ptr(); |
if (error_details->extension_id_ != extension_id()) |
return; |
@@ -105,16 +113,16 @@ void SpeechInputAsyncFunction::Observe( |
} |
StartSpeechInputFunction::StartSpeechInputFunction() |
- : SpeechInputAsyncFunction(ExtensionSpeechInputManager::kIdle, |
- ExtensionSpeechInputManager::kStarting, |
- ExtensionSpeechInputManager::kRecording, |
+ : SpeechInputAsyncFunction(SpeechInputExtensionManager::kIdle, |
+ SpeechInputExtensionManager::kStarting, |
+ SpeechInputExtensionManager::kRecording, |
chrome::NOTIFICATION_EXTENSION_SPEECH_INPUT_RECORDING_STARTED) { |
} |
bool StartSpeechInputFunction::RunImpl() { |
std::string language; |
- std::string grammar = constants::kDefaultGrammar; |
- bool filter_profanities = constants::kDefaultFilterProfanities; |
+ std::string grammar = kDefaultGrammar; |
+ bool filter_profanities = kDefaultFilterProfanities; |
if (!args_->empty()) { |
DictionaryValue *options; |
@@ -122,13 +130,13 @@ bool StartSpeechInputFunction::RunImpl() { |
return false; |
DCHECK(options); |
- if (options->HasKey(constants::kLanguageKey)) |
- options->GetString(constants::kLanguageKey, &language); |
- if (options->HasKey(constants::kGrammarKey)) |
- options->GetString(constants::kGrammarKey, &grammar); |
+ if (options->HasKey(kLanguageKey)) |
+ options->GetString(kLanguageKey, &language); |
+ if (options->HasKey(kGrammarKey)) |
+ options->GetString(kGrammarKey, &grammar); |
- if (options->HasKey(constants::kFilterProfanitiesKey)) { |
- options->GetBoolean(constants::kFilterProfanitiesKey, |
+ if (options->HasKey(kFilterProfanitiesKey)) { |
+ options->GetBoolean(kFilterProfanitiesKey, |
&filter_profanities); |
} |
} |
@@ -139,19 +147,19 @@ bool StartSpeechInputFunction::RunImpl() { |
VLOG(1) << "Language not specified. Using application locale " << language; |
} |
- return ExtensionSpeechInputManager::GetForProfile(profile())->Start( |
+ return SpeechInputExtensionManager::GetForProfile(profile())->Start( |
extension_id(), language, grammar, filter_profanities, &error_); |
} |
StopSpeechInputFunction::StopSpeechInputFunction() |
- : SpeechInputAsyncFunction(ExtensionSpeechInputManager::kRecording, |
- ExtensionSpeechInputManager::kStopping, |
- ExtensionSpeechInputManager::kIdle, |
+ : SpeechInputAsyncFunction(SpeechInputExtensionManager::kRecording, |
+ SpeechInputExtensionManager::kStopping, |
+ SpeechInputExtensionManager::kIdle, |
chrome::NOTIFICATION_EXTENSION_SPEECH_INPUT_RECORDING_STOPPED) { |
} |
bool StopSpeechInputFunction::RunImpl() { |
- return ExtensionSpeechInputManager::GetForProfile( |
+ return SpeechInputExtensionManager::GetForProfile( |
profile())->Stop(extension_id(), &error_); |
} |
@@ -159,6 +167,6 @@ bool IsRecordingSpeechInputFunction::RunImpl() { |
// Do not access the AudioManager directly here to ensure the proper |
// IsRecording behaviour in the API tests. |
result_.reset(Value::CreateBooleanValue( |
- ExtensionSpeechInputManager::GetForProfile(profile())->IsRecording())); |
+ SpeechInputExtensionManager::GetForProfile(profile())->IsRecording())); |
return true; |
} |