OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/WebKit/chromium/public/WebBindings.h" | 8 #include "third_party/WebKit/WebKit/chromium/public/WebBindings.h" |
9 #include "webkit/glue/cpp_variant.h" | 9 #include "webkit/glue/cpp_variant.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 NPVariant length_value; | 221 NPVariant length_value; |
222 if (WebBindings::getProperty(NULL, np_value, length_id, &length_value)) { | 222 if (WebBindings::getProperty(NULL, np_value, length_id, &length_value)) { |
223 int length = 0; | 223 int length = 0; |
224 // The length is a double in some cases. | 224 // The length is a double in some cases. |
225 if (NPVARIANT_IS_DOUBLE(length_value)) | 225 if (NPVARIANT_IS_DOUBLE(length_value)) |
226 length = static_cast<int>(NPVARIANT_TO_DOUBLE(length_value)); | 226 length = static_cast<int>(NPVARIANT_TO_DOUBLE(length_value)); |
227 else if (NPVARIANT_IS_INT32(length_value)) | 227 else if (NPVARIANT_IS_INT32(length_value)) |
228 length = NPVARIANT_TO_INT32(length_value); | 228 length = NPVARIANT_TO_INT32(length_value); |
229 WebBindings::releaseVariantValue(&length_value); | 229 WebBindings::releaseVariantValue(&length_value); |
230 | 230 |
231 // For sanity, only allow 100 items. | 231 // For sanity, only allow 60000 items. |
232 length = std::min(100, length); | 232 length = std::min(60000, length); |
233 for (int i = 0; i < length; ++i) { | 233 for (int i = 0; i < length; ++i) { |
234 // Get each of the items. | 234 // Get each of the items. |
235 std::string index = StringPrintf("%d", i); | 235 std::string index = StringPrintf("%d", i); |
236 NPIdentifier index_id = WebBindings::getStringIdentifier(index.c_str()); | 236 NPIdentifier index_id = WebBindings::getStringIdentifier(index.c_str()); |
237 if (WebBindings::hasProperty(NULL, np_value, index_id)) { | 237 if (WebBindings::hasProperty(NULL, np_value, index_id)) { |
238 NPVariant index_value; | 238 NPVariant index_value; |
239 if (WebBindings::getProperty(NULL, np_value, index_id, &index_value))
{ | 239 if (WebBindings::getProperty(NULL, np_value, index_id, &index_value))
{ |
240 if (NPVARIANT_IS_STRING(index_value)) { | 240 if (NPVARIANT_IS_STRING(index_value)) { |
241 std::string string( | 241 std::string string( |
242 NPVARIANT_TO_STRING(index_value).UTF8Characters, | 242 NPVARIANT_TO_STRING(index_value).UTF8Characters, |
(...skipping 16 matching lines...) Expand all Loading... |
259 NPObject* np_object = value.objectValue; | 259 NPObject* np_object = value.objectValue; |
260 if (WebBindings::hasMethod(NULL, np_object, method_name)) { | 260 if (WebBindings::hasMethod(NULL, np_object, method_name)) { |
261 NPVariant r; | 261 NPVariant r; |
262 bool status = WebBindings::invoke(NULL, np_object, method_name, args, arg_co
unt, &r); | 262 bool status = WebBindings::invoke(NULL, np_object, method_name, args, arg_co
unt, &r); |
263 result.Set(r); | 263 result.Set(r); |
264 return status; | 264 return status; |
265 } else { | 265 } else { |
266 return false; | 266 return false; |
267 } | 267 } |
268 } | 268 } |
OLD | NEW |