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
7namespace extension_tts_api_util {
8
9const char kVoiceNameKey[] = "voiceName";
10const char kLocaleKey[] = "locale";
11const char kGenderKey[] = "gender";
12const char kRateKey[] = "rate";
13const char kPitchKey[] = "pitch";
14const char kVolumeKey[] = "volume";
15const char kEnqueueKey[] = "enqueue";
16
17// Static.
18bool 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