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