| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/browser/extensions/extension_tts_api_util.h" | 5 #include "chrome/browser/extensions/extension_tts_api_util.h" |
| 6 | 6 |
| 7 namespace extension_tts_api_util { | 7 namespace extension_tts_api_util { |
| 8 | 8 |
| 9 const char kVoiceNameKey[] = "voiceName"; | 9 const char kVoiceNameKey[] = "voiceName"; |
| 10 const char kLocaleKey[] = "locale"; | 10 const char kLocaleKey[] = "locale"; |
| 11 const char kGenderKey[] = "gender"; | 11 const char kGenderKey[] = "gender"; |
| 12 const char kRateKey[] = "rate"; | 12 const char kRateKey[] = "rate"; |
| 13 const char kPitchKey[] = "pitch"; | 13 const char kPitchKey[] = "pitch"; |
| 14 const char kVolumeKey[] = "volume"; | 14 const char kVolumeKey[] = "volume"; |
| 15 const char kEnqueueKey[] = "enqueue"; | 15 const char kEnqueueKey[] = "enqueue"; |
| 16 | 16 |
| 17 // Static. | 17 // Static. |
| 18 bool ReadNumberByKey(DictionaryValue* dict, | 18 bool ReadNumberByKey(DictionaryValue* dict, |
| 19 const char* key, | 19 const char* key, |
| 20 double* ret_value) { | 20 double* ret_value) { |
| 21 Value* value; | 21 Value* value; |
| 22 if (!dict->Get(key, &value)) | 22 if (!dict->Get(key, &value)) |
| 23 return false; | 23 return false; |
| 24 | 24 |
| 25 if (value->IsType(Value::TYPE_INTEGER)) { | 25 if (value->IsType(Value::TYPE_INTEGER)) { |
| 26 int int_value; | 26 int int_value; |
| 27 if (!dict->GetInteger(key, &int_value)) | 27 if (!dict->GetInteger(key, &int_value)) |
| 28 return false; | 28 return false; |
| 29 *ret_value = int_value; | 29 *ret_value = int_value; |
| 30 } else if (value->IsType(Value::TYPE_REAL)) { | 30 } else if (value->IsType(Value::TYPE_DOUBLE)) { |
| 31 if (!dict->GetReal(key, ret_value)) | 31 if (!dict->GetDouble(key, ret_value)) |
| 32 return false; | 32 return false; |
| 33 } else { | 33 } else { |
| 34 return false; | 34 return false; |
| 35 } | 35 } |
| 36 return true; | 36 return true; |
| 37 } | 37 } |
| 38 | 38 |
| 39 } // namespace extension_tts_api_util. | 39 } // namespace extension_tts_api_util. |
| OLD | NEW |