Home | History | Annotate | Download | only in extensions
      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
      3 // found in the LICENSE file.
      4 
      5 #include "chrome/browser/extensions/extension_tts_api_util.h"
      6 
      7 namespace extension_tts_api_util {
      8 
      9 const char kVoiceNameKey[] = "voiceName";
     10 const char kLocaleKey[] = "locale";
     11 const char kGenderKey[] = "gender";
     12 const char kRateKey[] = "rate";
     13 const char kPitchKey[] = "pitch";
     14 const char kVolumeKey[] = "volume";
     15 const char kEnqueueKey[] = "enqueue";
     16 
     17 // Static.
     18 bool ReadNumberByKey(DictionaryValue* dict,
     19                      const char* key,
     20                      double* ret_value) {
     21   Value* value;
     22   if (!dict->Get(key, &value))
     23     return false;
     24 
     25   if (value->IsType(Value::TYPE_INTEGER)) {
     26     int int_value;
     27     if (!dict->GetInteger(key, &int_value))
     28       return false;
     29     *ret_value = int_value;
     30   } else if (value->IsType(Value::TYPE_DOUBLE)) {
     31     if (!dict->GetDouble(key, ret_value))
     32       return false;
     33   } else {
     34     return false;
     35   }
     36   return true;
     37 }
     38 
     39 }  // namespace extension_tts_api_util.
     40