Commit 692a806c authored by ncj674@motorola.com's avatar ncj674@motorola.com

Move TtsEngine manifest key parsing out of extension class.

BUG=159265
TEST=TtsEngineManifestTest, TtsApiTest
TBR=ben@chromium.org

Review URL: https://chromiumcodereview.appspot.com/11745009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176016 0039d316-1c4b-4281-b951-d872f2087c98
parent 3044046b
......@@ -27,8 +27,6 @@
#include "chrome/browser/extensions/system/system_api.h"
#include "chrome/browser/infobars/infobar_extension_api.h"
#include "chrome/browser/rlz/rlz_extension_api.h"
#include "chrome/browser/speech/extension_api/tts_engine_extension_api.h"
#include "chrome/browser/speech/extension_api/tts_extension_api.h"
#include "chrome/browser/speech/speech_input_extension_api.h"
#include "chrome/common/extensions/api/generated_api.h"
......@@ -160,13 +158,6 @@ void ExtensionFunctionRegistry::ResetFunctions() {
RegisterFunction<SetAccessibilityEnabledFunction>();
RegisterFunction<GetAlertsForTabFunction>();
// Text-to-speech.
RegisterFunction<ExtensionTtsEngineSendTtsEventFunction>();
RegisterFunction<ExtensionTtsGetVoicesFunction>();
RegisterFunction<ExtensionTtsIsSpeakingFunction>();
RegisterFunction<ExtensionTtsSpeakFunction>();
RegisterFunction<ExtensionTtsStopSpeakingFunction>();
// Commands.
RegisterFunction<GetAllCommandsFunction>();
......
......@@ -63,6 +63,7 @@
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/token_service_factory.h"
#include "chrome/browser/speech/chrome_speech_recognition_preferences.h"
#include "chrome/browser/speech/extension_api/tts_extension_api.h"
#include "chrome/browser/speech/speech_input_extension_manager.h"
#include "chrome/browser/spellchecker/spellcheck_factory.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
......@@ -272,6 +273,7 @@ void ProfileDependencyManager::AssertFactoriesBuilt() {
extensions::SuggestedLinksRegistryFactory::GetInstance();
extensions::TabCaptureRegistryFactory::GetInstance();
extensions::TabsWindowsAPI::GetFactoryInstance();
extensions::TtsAPI::GetFactoryInstance();
extensions::WebNavigationAPI::GetFactoryInstance();
#endif
FaviconServiceFactory::GetInstance();
......
......@@ -14,6 +14,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/speech/extension_api/tts_extension_api_constants.h"
#include "chrome/browser/speech/extension_api/tts_extension_api_controller.h"
#include "chrome/common/extensions/api/speech/tts_engine_manifest_handler.h"
#include "chrome/common/extensions/extension.h"
using extensions::Extension;
......@@ -55,10 +56,13 @@ void GetExtensionVoices(Profile* profile, ListValue* result_voices) {
continue;
}
const std::vector<Extension::TtsVoice>& tts_voices =
extension->tts_voices();
for (size_t i = 0; i < tts_voices.size(); ++i) {
const Extension::TtsVoice& voice = tts_voices[i];
const std::vector<extensions::TtsVoice>* tts_voices =
extensions::TtsVoice::GetTtsVoices(extension);
if (!tts_voices)
continue;
for (size_t i = 0; i < tts_voices->size(); ++i) {
const extensions::TtsVoice& voice = tts_voices->at(i);
DictionaryValue* result_voice = new DictionaryValue();
if (!voice.voice_name.empty())
result_voice->SetString(constants::kVoiceNameKey, voice.voice_name);
......@@ -135,10 +139,13 @@ bool GetMatchingExtensionVoice(
continue;
}
const std::vector<Extension::TtsVoice>& tts_voices =
extension->tts_voices();
for (size_t i = 0; i < tts_voices.size(); ++i) {
const Extension::TtsVoice& voice = tts_voices[i];
const std::vector<extensions::TtsVoice>* tts_voices =
extensions::TtsVoice::GetTtsVoices(extension);
if (!tts_voices)
continue;
for (size_t i = 0; i < tts_voices->size(); ++i) {
const extensions::TtsVoice& voice = tts_voices->at(i);
if (!voice.voice_name.empty() &&
!utterance->voice_name().empty() &&
voice.voice_name != utterance->voice_name()) {
......@@ -190,8 +197,12 @@ void ExtensionTtsEngineSpeak(Utterance* utterance,
// See if the engine supports the "end" event; if so, we can keep the
// utterance around and track it. If not, we're finished with this
// utterance now.
const std::set<std::string> event_types =
extension->tts_voices()[voice_index].event_types;
const std::vector<extensions::TtsVoice>* tts_voices =
extensions::TtsVoice::GetTtsVoices(extension);
std::set<std::string> event_types;
if (tts_voices)
event_types = tts_voices->at(voice_index).event_types;
bool sends_end_event =
(event_types.find(constants::kEventTypeEnd) != event_types.end());
......@@ -255,8 +266,15 @@ bool ExtensionTtsEngineSendTtsEventFunction::RunImpl() {
// Make sure the extension has included this event type in its manifest.
bool event_type_allowed = false;
const Extension* extension = GetExtension();
for (size_t i = 0; i < extension->tts_voices().size(); i++) {
const Extension::TtsVoice& voice = extension->tts_voices()[i];
const std::vector<extensions::TtsVoice>* tts_voices =
extensions::TtsVoice::GetTtsVoices(extension);
if (!tts_voices) {
error_ = constants::kErrorUndeclaredEventType;
return false;
}
for (size_t i = 0; i < tts_voices->size(); i++) {
const extensions::TtsVoice& voice = tts_voices->at(i);
if (voice.event_types.find(event_type) != voice.event_types.end()) {
event_type_allowed = true;
break;
......
......@@ -6,15 +6,22 @@
#include <string>
#include "base/lazy_instance.h"
#include "base/values.h"
#include "chrome/browser/extensions/extension_function_registry.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/speech/extension_api/tts_engine_extension_api.h"
#include "chrome/browser/speech/extension_api/tts_extension_api_constants.h"
#include "chrome/browser/speech/extension_api/tts_extension_api_controller.h"
#include "chrome/common/extensions/api/speech/tts_engine_manifest_handler.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
#include "ui/base/l10n/l10n_util.h"
namespace constants = tts_extension_api_constants;
bool ExtensionTtsSpeakFunction::RunImpl() {
namespace extensions {
bool TtsSpeakFunction::RunImpl() {
std::string text;
EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &text));
if (text.size() > 32768) {
......@@ -157,18 +164,47 @@ bool ExtensionTtsSpeakFunction::RunImpl() {
return true;
}
bool ExtensionTtsStopSpeakingFunction::RunImpl() {
bool TtsStopSpeakingFunction::RunImpl() {
ExtensionTtsController::GetInstance()->Stop();
return true;
}
bool ExtensionTtsIsSpeakingFunction::RunImpl() {
bool TtsIsSpeakingFunction::RunImpl() {
SetResult(Value::CreateBooleanValue(
ExtensionTtsController::GetInstance()->IsSpeaking()));
return true;
}
bool ExtensionTtsGetVoicesFunction::RunImpl() {
bool TtsGetVoicesFunction::RunImpl() {
SetResult(ExtensionTtsController::GetInstance()->GetVoices(profile()));
return true;
}
// static
TtsAPI* TtsAPI::Get(Profile* profile) {
return ProfileKeyedAPIFactory<TtsAPI>::GetForProfile(profile);
}
TtsAPI::TtsAPI(Profile* profile) {
ManifestHandler::Register(extension_manifest_keys::kTtsEngine,
new TtsEngineManifestHandler);
ExtensionFunctionRegistry* registry =
ExtensionFunctionRegistry::GetInstance();
registry->RegisterFunction<ExtensionTtsEngineSendTtsEventFunction>();
registry->RegisterFunction<TtsGetVoicesFunction>();
registry->RegisterFunction<TtsIsSpeakingFunction>();
registry->RegisterFunction<TtsSpeakFunction>();
registry->RegisterFunction<TtsStopSpeakingFunction>();
}
TtsAPI::~TtsAPI() {
}
static base::LazyInstance<ProfileKeyedAPIFactory<TtsAPI> >
g_factory = LAZY_INSTANCE_INITIALIZER;
ProfileKeyedAPIFactory<TtsAPI>* TtsAPI::GetFactoryInstance() {
return &g_factory.Get();
}
} // namespace extensions
......@@ -7,36 +7,64 @@
#include <string>
#include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
#include "chrome/browser/extensions/extension_function.h"
#include "chrome/browser/speech/extension_api/tts_extension_api_controller.h"
class ExtensionTtsSpeakFunction
class Profile;
namespace extensions {
class TtsSpeakFunction
: public AsyncExtensionFunction {
private:
virtual ~ExtensionTtsSpeakFunction() {}
virtual ~TtsSpeakFunction() {}
virtual bool RunImpl() OVERRIDE;
DECLARE_EXTENSION_FUNCTION_NAME("tts.speak")
};
class ExtensionTtsStopSpeakingFunction : public SyncExtensionFunction {
class TtsStopSpeakingFunction : public SyncExtensionFunction {
private:
virtual ~ExtensionTtsStopSpeakingFunction() {}
virtual ~TtsStopSpeakingFunction() {}
virtual bool RunImpl() OVERRIDE;
DECLARE_EXTENSION_FUNCTION_NAME("tts.stop")
};
class ExtensionTtsIsSpeakingFunction : public SyncExtensionFunction {
class TtsIsSpeakingFunction : public SyncExtensionFunction {
private:
virtual ~ExtensionTtsIsSpeakingFunction() {}
virtual ~TtsIsSpeakingFunction() {}
virtual bool RunImpl() OVERRIDE;
DECLARE_EXTENSION_FUNCTION_NAME("tts.isSpeaking")
};
class ExtensionTtsGetVoicesFunction : public SyncExtensionFunction {
class TtsGetVoicesFunction : public SyncExtensionFunction {
private:
virtual ~ExtensionTtsGetVoicesFunction() {}
virtual ~TtsGetVoicesFunction() {}
virtual bool RunImpl() OVERRIDE;
DECLARE_EXTENSION_FUNCTION_NAME("tts.getVoices")
};
class TtsAPI : public ProfileKeyedAPI {
public:
explicit TtsAPI(Profile* profile);
virtual ~TtsAPI();
// Convenience method to get the TtsAPI for a profile.
static TtsAPI* Get(Profile* profile);
// ProfileKeyedAPI implementation.
static ProfileKeyedAPIFactory<TtsAPI>* GetFactoryInstance();
private:
friend class ProfileKeyedAPIFactory<TtsAPI>;
// ProfileKeyedAPI implementation.
static const char* service_name() {
return "TtsAPI";
}
static const bool kServiceIsNULLWhileTesting = true;
};
} // namespace extensions
#endif // CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_EXTENSION_API_H_
......@@ -17,6 +17,7 @@
#include "chrome/browser/speech/extension_api/tts_extension_api_constants.h"
#include "chrome/browser/speech/extension_api/tts_extension_api_platform.h"
#include "chrome/browser/speech/extension_api/tts_engine_extension_api.h"
#include "chrome/common/extensions/api/speech/tts_engine_manifest_handler.h"
#include "chrome/common/extensions/extension.h"
namespace constants = tts_extension_api_constants;
......@@ -180,8 +181,11 @@ void ExtensionTtsController::SpeakNow(Utterance* utterance) {
ExtensionTtsEngineSpeak(utterance, extension, voice_index);
const std::set<std::string> event_types =
extension->tts_voices()[voice_index].event_types;
const std::vector<extensions::TtsVoice>* tts_voices =
extensions::TtsVoice::GetTtsVoices(extension);
std::set<std::string> event_types;
if (tts_voices)
event_types = tts_voices->at(voice_index).event_types;
bool sends_end_event =
(event_types.find(constants::kEventTypeEnd) != event_types.end());
if (!sends_end_event) {
......
......@@ -132,6 +132,8 @@
'common/extensions/api/input_ime/input_components_handler.h',
'common/extensions/api/omnibox/omnibox_handler.cc',
'common/extensions/api/omnibox/omnibox_handler.h',
'common/extensions/api/speech/tts_engine_manifest_handler.cc',
'common/extensions/api/speech/tts_engine_manifest_handler.h',
'common/extensions/command.cc',
'common/extensions/command.h',
'common/extensions/csp_validator.cc',
......
......@@ -1048,6 +1048,7 @@
'browser/signin/token_service_unittest.cc',
'browser/signin/token_service_unittest.h',
'browser/signin/ubertoken_fetcher_unittest.cc',
'browser/speech/extension_api/extension_manifests_tts_unittest.cc',
'browser/speech/extension_api/tts_extension_api_controller_unittest.cc',
'browser/speech/speech_recognition_bubble_controller_unittest.cc',
'browser/spellchecker/spellcheck_custom_dictionary_unittest.cc',
......@@ -1494,7 +1495,6 @@
'common/extensions/manifest_tests/extension_manifests_sandboxed_unittest.cc',
'common/extensions/manifest_tests/extension_manifests_scriptbadge_unittest.cc',
'common/extensions/manifest_tests/extension_manifests_storage_unittest.cc',
'common/extensions/manifest_tests/extension_manifests_tts_unittest.cc',
'common/extensions/manifest_tests/extension_manifests_ui_unittest.cc',
'common/extensions/manifest_tests/extension_manifests_update_unittest.cc',
'common/extensions/manifest_tests/extension_manifests_validapp_unittest.cc',
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/common/extensions/api/speech/tts_engine_manifest_handler.h"
#include "base/memory/scoped_ptr.h"
#include "base/string_number_conversions.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
#include "extensions/common/error_utils.h"
#include "ui/base/l10n/l10n_util.h"
namespace keys = extension_manifest_keys;
namespace errors = extension_manifest_errors;
namespace {
struct TtsVoices : public extensions::Extension::ManifestData {
TtsVoices() {}
virtual ~TtsVoices() {}
std::vector<extensions::TtsVoice> voices;
};
} // namespace
namespace extensions {
TtsVoice::TtsVoice() {}
TtsVoice::~TtsVoice() {}
// static
const std::vector<TtsVoice>* TtsVoice::GetTtsVoices(
const Extension* extension) {
TtsVoices* info = static_cast<TtsVoices*>(
extension->GetManifestData(keys::kTtsVoices));
return info ? &info->voices : NULL;
}
TtsEngineManifestHandler::TtsEngineManifestHandler() {
}
TtsEngineManifestHandler::~TtsEngineManifestHandler() {
}
bool TtsEngineManifestHandler::Parse(const base::Value* value,
Extension* extension, string16* error) {
scoped_ptr<TtsVoices> info(new TtsVoices);
const DictionaryValue* tts_dict = NULL;
if (!value->GetAsDictionary(&tts_dict)) {
*error = ASCIIToUTF16(errors::kInvalidTts);
return false;
}
if (!tts_dict->HasKey(keys::kTtsVoices))
return true;
const ListValue* tts_voices = NULL;
if (!tts_dict->GetList(keys::kTtsVoices, &tts_voices)) {
*error = ASCIIToUTF16(errors::kInvalidTtsVoices);
return false;
}
for (size_t i = 0; i < tts_voices->GetSize(); i++) {
const DictionaryValue* one_tts_voice = NULL;
if (!tts_voices->GetDictionary(i, &one_tts_voice)) {
*error = ASCIIToUTF16(errors::kInvalidTtsVoices);
return false;
}
TtsVoice voice_data;
if (one_tts_voice->HasKey(keys::kTtsVoicesVoiceName)) {
if (!one_tts_voice->GetString(
keys::kTtsVoicesVoiceName, &voice_data.voice_name)) {
*error = ASCIIToUTF16(errors::kInvalidTtsVoicesVoiceName);
return false;
}
}
if (one_tts_voice->HasKey(keys::kTtsVoicesLang)) {
if (!one_tts_voice->GetString(
keys::kTtsVoicesLang, &voice_data.lang) ||
!l10n_util::IsValidLocaleSyntax(voice_data.lang)) {
*error = ASCIIToUTF16(errors::kInvalidTtsVoicesLang);
return false;
}
}
if (one_tts_voice->HasKey(keys::kTtsVoicesGender)) {
if (!one_tts_voice->GetString(
keys::kTtsVoicesGender, &voice_data.gender) ||
(voice_data.gender != keys::kTtsGenderMale &&
voice_data.gender != keys::kTtsGenderFemale)) {
*error = ASCIIToUTF16(errors::kInvalidTtsVoicesGender);
return false;
}
}
if (one_tts_voice->HasKey(keys::kTtsVoicesEventTypes)) {
const ListValue* event_types_list;
if (!one_tts_voice->GetList(
keys::kTtsVoicesEventTypes,
&event_types_list)) {
*error = ASCIIToUTF16(
errors::kInvalidTtsVoicesEventTypes);
return false;
}
for (size_t i = 0; i < event_types_list->GetSize(); i++) {
std::string event_type;
if (!event_types_list->GetString(i, &event_type)) {
*error = ASCIIToUTF16(errors::kInvalidTtsVoicesEventTypes);
return false;
}
if (event_type != keys::kTtsVoicesEventTypeEnd &&
event_type != keys::kTtsVoicesEventTypeError &&
event_type != keys::kTtsVoicesEventTypeMarker &&
event_type != keys::kTtsVoicesEventTypeSentence &&
event_type != keys::kTtsVoicesEventTypeStart &&
event_type != keys::kTtsVoicesEventTypeWord) {
*error = ASCIIToUTF16(errors::kInvalidTtsVoicesEventTypes);
return false;
}
if (voice_data.event_types.find(event_type) !=
voice_data.event_types.end()) {
*error = ASCIIToUTF16(errors::kInvalidTtsVoicesEventTypes);
return false;
}
voice_data.event_types.insert(event_type);
}
}
info->voices.push_back(voice_data);
}
extension->SetManifestData(keys::kTtsVoices, info.release());
return true;
}
} // namespace extensions
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_COMMON_EXTENSIONS_API_SPEECH_TTS_ENGINE_MANIFEST_HANDLER_H_
#define CHROME_COMMON_EXTENSIONS_API_SPEECH_TTS_ENGINE_MANIFEST_HANDLER_H_
#include <set>
#include <string>
#include <vector>
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/manifest_handler.h"
namespace extensions {
struct TtsVoice {
TtsVoice();
~TtsVoice();
std::string voice_name;
std::string lang;
std::string gender;
std::set<std::string> event_types;
static const std::vector<TtsVoice>* GetTtsVoices(const Extension* extension);
};
// Parses the "tts_engine" manifest key.
class TtsEngineManifestHandler : public ManifestHandler {
public:
TtsEngineManifestHandler();
virtual ~TtsEngineManifestHandler();
virtual bool Parse(const base::Value* value, Extension* extension,
string16* error) OVERRIDE;
};
} // namespace extensions
#endif // CHROME_COMMON_EXTENSIONS_API_SPEECH_TTS_ENGINE_MANIFEST_HANDLER_H_
......@@ -343,9 +343,6 @@ Extension::Requirements::Requirements()
Extension::Requirements::~Requirements() {}
Extension::TtsVoice::TtsVoice() {}
Extension::TtsVoice::~TtsVoice() {}
Extension::OAuth2Info::OAuth2Info() {}
Extension::OAuth2Info::~OAuth2Info() {}
......@@ -2839,7 +2836,6 @@ bool Extension::LoadExtensionFeatures(APIPermissionSet* api_permissions,
!LoadSystemIndicator(api_permissions, error) ||
!LoadScriptBadge(error) ||
!LoadChromeURLOverrides(error) ||
!LoadTextToSpeechVoices(error) ||
!LoadIncognitoMode(error) ||
!LoadFileHandlers(error) ||
!LoadContentSecurityPolicy(error))
......@@ -3105,91 +3101,6 @@ bool Extension::LoadChromeURLOverrides(string16* error) {
return true;
}
bool Extension::LoadTextToSpeechVoices(string16* error) {
if (!manifest_->HasKey(keys::kTtsEngine))
return true;
DictionaryValue* tts_dict = NULL;
if (!manifest_->GetDictionary(keys::kTtsEngine, &tts_dict)) {
*error = ASCIIToUTF16(errors::kInvalidTts);
return false;
}
if (tts_dict->HasKey(keys::kTtsVoices)) {
ListValue* tts_voices = NULL;
if (!tts_dict->GetList(keys::kTtsVoices, &tts_voices)) {
*error = ASCIIToUTF16(errors::kInvalidTtsVoices);
return false;
}
for (size_t i = 0; i < tts_voices->GetSize(); i++) {
DictionaryValue* one_tts_voice = NULL;
if (!tts_voices->GetDictionary(i, &one_tts_voice)) {
*error = ASCIIToUTF16(errors::kInvalidTtsVoices);
return false;
}
TtsVoice voice_data;
if (one_tts_voice->HasKey(keys::kTtsVoicesVoiceName)) {
if (!one_tts_voice->GetString(
keys::kTtsVoicesVoiceName, &voice_data.voice_name)) {
*error = ASCIIToUTF16(errors::kInvalidTtsVoicesVoiceName);
return false;
}
}
if (one_tts_voice->HasKey(keys::kTtsVoicesLang)) {
if (!one_tts_voice->GetString(
keys::kTtsVoicesLang, &voice_data.lang) ||
!l10n_util::IsValidLocaleSyntax(voice_data.lang)) {
*error = ASCIIToUTF16(errors::kInvalidTtsVoicesLang);
return false;
}
}
if (one_tts_voice->HasKey(keys::kTtsVoicesGender)) {
if (!one_tts_voice->GetString(
keys::kTtsVoicesGender, &voice_data.gender) ||
(voice_data.gender != keys::kTtsGenderMale &&
voice_data.gender != keys::kTtsGenderFemale)) {
*error = ASCIIToUTF16(errors::kInvalidTtsVoicesGender);
return false;
}
}
if (one_tts_voice->HasKey(keys::kTtsVoicesEventTypes)) {
ListValue* event_types_list;
if (!one_tts_voice->GetList(
keys::kTtsVoicesEventTypes, &event_types_list)) {
*error = ASCIIToUTF16(errors::kInvalidTtsVoicesEventTypes);
return false;
}
for (size_t i = 0; i < event_types_list->GetSize(); i++) {
std::string event_type;
if (!event_types_list->GetString(i, &event_type)) {
*error = ASCIIToUTF16(errors::kInvalidTtsVoicesEventTypes);
return false;
}
if (event_type != keys::kTtsVoicesEventTypeEnd &&
event_type != keys::kTtsVoicesEventTypeError &&
event_type != keys::kTtsVoicesEventTypeMarker &&
event_type != keys::kTtsVoicesEventTypeSentence &&
event_type != keys::kTtsVoicesEventTypeStart &&
event_type != keys::kTtsVoicesEventTypeWord) {
*error = ASCIIToUTF16(errors::kInvalidTtsVoicesEventTypes);
return false;
}
if (voice_data.event_types.find(event_type) !=
voice_data.event_types.end()) {
*error = ASCIIToUTF16(errors::kInvalidTtsVoicesEventTypes);
return false;
}
voice_data.event_types.insert(event_type);
}
}
tts_voices_.push_back(voice_data);
}
}
return true;
}
bool Extension::LoadIncognitoMode(string16* error) {
// Apps default to split mode, extensions default to spanning.
incognito_split_mode_ = is_app();
......
......@@ -175,17 +175,6 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
std::string mime_type;
};
struct TtsVoice {
// Define out of line constructor/destructor to please Clang.
TtsVoice();
~TtsVoice();
std::string voice_name;
std::string lang;
std::string gender;
std::set<std::string> event_types;
};
// OAuth2 info included in the extension.
struct OAuth2Info {
OAuth2Info();
......@@ -742,7 +731,6 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
}
bool incognito_split_mode() const { return incognito_split_mode_; }
bool offline_enabled() const { return offline_enabled_; }
const std::vector<TtsVoice>& tts_voices() const { return tts_voices_; }
const OAuth2Info& oauth2_info() const { return oauth2_info_; }
const std::vector<webkit_glue::WebIntentServiceData>&
intents_services() const {
......@@ -1209,9 +1197,6 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
// Should this app be shown in the browser New Tab Page.
bool display_in_new_tab_page_;
// List of text-to-speech voices that this extension provides, if any.
std::vector<TtsVoice> tts_voices_;
// The OAuth2 client id and scopes, if specified by the extension.
OAuth2Info oauth2_info_;
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace errors = extension_manifest_errors;
TEST_F(ExtensionManifestTest, TtsEngine) {
Testcase testcases[] = {
Testcase("tts_engine_invalid_1.json",
errors::kInvalidTts),
Testcase("tts_engine_invalid_2.json",
errors::kInvalidTtsVoices),
Testcase("tts_engine_invalid_3.json",
errors::kInvalidTtsVoices),
Testcase("tts_engine_invalid_4.json",
errors::kInvalidTtsVoicesVoiceName),
Testcase("tts_engine_invalid_5.json",
errors::kInvalidTtsVoicesLang),
Testcase("tts_engine_invalid_6.json",
errors::kInvalidTtsVoicesLang),
Testcase("tts_engine_invalid_7.json",
errors::kInvalidTtsVoicesGender),
Testcase("tts_engine_invalid_8.json",
errors::kInvalidTtsVoicesEventTypes),
Testcase("tts_engine_invalid_9.json",
errors::kInvalidTtsVoicesEventTypes)
};
RunTestcases(testcases, arraysize(testcases),
EXPECT_TYPE_ERROR);
scoped_refptr<extensions::Extension> extension(
LoadAndExpectSuccess("tts_engine_valid.json"));
ASSERT_EQ(1u, extension->tts_voices().size());
EXPECT_EQ("name", extension->tts_voices()[0].voice_name);
EXPECT_EQ("en-US", extension->tts_voices()[0].lang);
EXPECT_EQ("female", extension->tts_voices()[0].gender);
EXPECT_EQ(3U, extension->tts_voices()[0].event_types.size());
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment