| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This file contains definitions for CppVariant. | 5 // This file contains definitions for CppVariant. |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | |
| 9 #include "webkit/glue/cpp_variant.h" | |
| 10 #include "base/logging.h" | 8 #include "base/logging.h" |
| 11 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 12 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| 13 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
| 13 #include "webkit/renderer/cpp_variant.h" |
| 14 | 14 |
| 15 using WebKit::WebBindings; | 15 using WebKit::WebBindings; |
| 16 | 16 |
| 17 namespace webkit_glue { | 17 namespace webkit_glue { |
| 18 | 18 |
| 19 CppVariant::CppVariant() { | 19 CppVariant::CppVariant() { |
| 20 type = NPVariantType_Null; | 20 type = NPVariantType_Null; |
| 21 } | 21 } |
| 22 | 22 |
| 23 // Note that Set() performs a deep copy, which is necessary to safely | 23 // Note that Set() performs a deep copy, which is necessary to safely |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 return vector; | 249 return vector; |
| 250 } | 250 } |
| 251 | 251 |
| 252 bool CppVariant::Invoke(const std::string& method, const CppVariant* args, | 252 bool CppVariant::Invoke(const std::string& method, const CppVariant* args, |
| 253 uint32 arg_count, CppVariant& result) const { | 253 uint32 arg_count, CppVariant& result) const { |
| 254 DCHECK(isObject()); | 254 DCHECK(isObject()); |
| 255 NPIdentifier method_name = WebBindings::getStringIdentifier(method.c_str()); | 255 NPIdentifier method_name = WebBindings::getStringIdentifier(method.c_str()); |
| 256 NPObject* np_object = value.objectValue; | 256 NPObject* np_object = value.objectValue; |
| 257 if (WebBindings::hasMethod(NULL, np_object, method_name)) { | 257 if (WebBindings::hasMethod(NULL, np_object, method_name)) { |
| 258 NPVariant r; | 258 NPVariant r; |
| 259 bool status = WebBindings::invoke(NULL, np_object, method_name, args, arg_co
unt, &r); | 259 bool status = |
| 260 WebBindings::invoke(NULL, np_object, method_name, args, arg_count, &r); |
| 260 result.Set(r); | 261 result.Set(r); |
| 261 return status; | 262 return status; |
| 262 } else { | 263 } else { |
| 263 return false; | 264 return false; |
| 264 } | 265 } |
| 265 } | 266 } |
| 266 | 267 |
| 267 } // namespace webkit_glue | 268 } // namespace webkit_glue |
| OLD | NEW |