Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: chrome/browser/extensions/extension_tts_api_util.cc

Issue 6901084: Use new APIs in base/values.h: Value::GetAsNumber and DictionaryValue::GetNumber. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, 2010->2011 Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.
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. 17 } // namespace extension_tts_api_util.
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_tts_api_util.h ('k') | chrome/browser/printing/print_dialog_cloud.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698