Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / ios / public / provider / web / web_ui_ios_message_handler.cc
blobb4b473e012c33cc62075d58e3fa8f0518bfe2446
1 // Copyright 2014 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.
5 #include "ios/public/provider/web/web_ui_ios_message_handler.h"
7 #include "base/logging.h"
8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h"
12 namespace web {
14 bool WebUIIOSMessageHandler::ExtractIntegerValue(const base::ListValue* value,
15 int* out_int) {
16 std::string string_value;
17 if (value->GetString(0, &string_value))
18 return base::StringToInt(string_value, out_int);
19 double double_value;
20 if (value->GetDouble(0, &double_value)) {
21 *out_int = static_cast<int>(double_value);
22 return true;
24 NOTREACHED();
25 return false;
28 bool WebUIIOSMessageHandler::ExtractDoubleValue(const base::ListValue* value,
29 double* out_value) {
30 std::string string_value;
31 if (value->GetString(0, &string_value))
32 return base::StringToDouble(string_value, out_value);
33 if (value->GetDouble(0, out_value))
34 return true;
35 NOTREACHED();
36 return false;
39 base::string16 WebUIIOSMessageHandler::ExtractStringValue(
40 const base::ListValue* value) {
41 base::string16 string16_value;
42 if (value->GetString(0, &string16_value))
43 return string16_value;
44 NOTREACHED();
45 return base::string16();
48 } // namespace web