summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_tts_api_util.cc
blob: b3ef18ce3a15296d459343cd2935d8affc2a9736 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/extensions/extension_tts_api_util.h"

namespace extension_tts_api_util {

const char kVoiceNameKey[] = "voiceName";
const char kLocaleKey[] = "locale";
const char kGenderKey[] = "gender";
const char kRateKey[] = "rate";
const char kPitchKey[] = "pitch";
const char kVolumeKey[] = "volume";
const char kEnqueueKey[] = "enqueue";

// Static.
bool ReadNumberByKey(DictionaryValue* dict,
                     const char* key,
                     double* ret_value) {
  Value* value;
  if (!dict->Get(key, &value))
    return false;

  if (value->IsType(Value::TYPE_INTEGER)) {
    int int_value;
    if (!dict->GetInteger(key, &int_value))
      return false;
    *ret_value = int_value;
  } else if (value->IsType(Value::TYPE_REAL)) {
    if (!dict->GetReal(key, ret_value))
      return false;
  } else {
    return false;
  }
  return true;
}

}  // namespace extension_tts_api_util.