| 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/common/extensions/api/speech/tts_engine_manifest_handler.h" | 5 #include "chrome/common/extensions/api/speech/tts_engine_manifest_handler.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 struct TtsVoices : public Extension::ManifestData { | 23 struct TtsVoices : public Extension::ManifestData { |
| 24 TtsVoices() {} | 24 TtsVoices() {} |
| 25 virtual ~TtsVoices() {} | 25 virtual ~TtsVoices() {} |
| 26 | 26 |
| 27 std::vector<extensions::TtsVoice> voices; | 27 std::vector<extensions::TtsVoice> voices; |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 } // namespace | 30 } // namespace |
| 31 | 31 |
| 32 TtsVoice::TtsVoice() {} | 32 TtsVoice::TtsVoice() : remote(false) {} |
| 33 |
| 33 TtsVoice::~TtsVoice() {} | 34 TtsVoice::~TtsVoice() {} |
| 34 | 35 |
| 35 // static | 36 // static |
| 36 const std::vector<TtsVoice>* TtsVoice::GetTtsVoices( | 37 const std::vector<TtsVoice>* TtsVoice::GetTtsVoices( |
| 37 const Extension* extension) { | 38 const Extension* extension) { |
| 38 TtsVoices* info = static_cast<TtsVoices*>( | 39 TtsVoices* info = static_cast<TtsVoices*>( |
| 39 extension->GetManifestData(keys::kTtsVoices)); | 40 extension->GetManifestData(keys::kTtsVoices)); |
| 40 return info ? &info->voices : NULL; | 41 return info ? &info->voices : NULL; |
| 41 } | 42 } |
| 42 | 43 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 } | 89 } |
| 89 if (one_tts_voice->HasKey(keys::kTtsVoicesGender)) { | 90 if (one_tts_voice->HasKey(keys::kTtsVoicesGender)) { |
| 90 if (!one_tts_voice->GetString( | 91 if (!one_tts_voice->GetString( |
| 91 keys::kTtsVoicesGender, &voice_data.gender) || | 92 keys::kTtsVoicesGender, &voice_data.gender) || |
| 92 (voice_data.gender != keys::kTtsGenderMale && | 93 (voice_data.gender != keys::kTtsGenderMale && |
| 93 voice_data.gender != keys::kTtsGenderFemale)) { | 94 voice_data.gender != keys::kTtsGenderFemale)) { |
| 94 *error = ASCIIToUTF16(errors::kInvalidTtsVoicesGender); | 95 *error = ASCIIToUTF16(errors::kInvalidTtsVoicesGender); |
| 95 return false; | 96 return false; |
| 96 } | 97 } |
| 97 } | 98 } |
| 99 if (one_tts_voice->HasKey(keys::kTtsVoicesRemote)) { |
| 100 if (!one_tts_voice->GetBoolean( |
| 101 keys::kTtsVoicesRemote, &voice_data.remote)) { |
| 102 *error = ASCIIToUTF16(errors::kInvalidTtsVoicesRemote); |
| 103 return false; |
| 104 } |
| 105 } |
| 98 if (one_tts_voice->HasKey(keys::kTtsVoicesEventTypes)) { | 106 if (one_tts_voice->HasKey(keys::kTtsVoicesEventTypes)) { |
| 99 const base::ListValue* event_types_list; | 107 const base::ListValue* event_types_list; |
| 100 if (!one_tts_voice->GetList( | 108 if (!one_tts_voice->GetList( |
| 101 keys::kTtsVoicesEventTypes, | 109 keys::kTtsVoicesEventTypes, |
| 102 &event_types_list)) { | 110 &event_types_list)) { |
| 103 *error = ASCIIToUTF16( | 111 *error = ASCIIToUTF16( |
| 104 errors::kInvalidTtsVoicesEventTypes); | 112 errors::kInvalidTtsVoicesEventTypes); |
| 105 return false; | 113 return false; |
| 106 } | 114 } |
| 107 for (size_t i = 0; i < event_types_list->GetSize(); i++) { | 115 for (size_t i = 0; i < event_types_list->GetSize(); i++) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 133 | 141 |
| 134 extension->SetManifestData(keys::kTtsVoices, info.release()); | 142 extension->SetManifestData(keys::kTtsVoices, info.release()); |
| 135 return true; | 143 return true; |
| 136 } | 144 } |
| 137 | 145 |
| 138 const std::vector<std::string> TtsEngineManifestHandler::Keys() const { | 146 const std::vector<std::string> TtsEngineManifestHandler::Keys() const { |
| 139 return SingleKey(keys::kTtsEngine); | 147 return SingleKey(keys::kTtsEngine); |
| 140 } | 148 } |
| 141 | 149 |
| 142 } // namespace extensions | 150 } // namespace extensions |
| OLD | NEW |