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 #include "content/renderer/v8_value_converter_impl.h" | 5 #include "content/renderer/v8_value_converter_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 | 304 |
305 scoped_ptr<DictionaryValue> result(new DictionaryValue()); | 305 scoped_ptr<DictionaryValue> result(new DictionaryValue()); |
306 v8::Handle<v8::Array> property_names(val->GetPropertyNames()); | 306 v8::Handle<v8::Array> property_names(val->GetPropertyNames()); |
307 | 307 |
308 if (unique_set) | 308 if (unique_set) |
309 unique_set->insert(val->GetIdentityHash()); | 309 unique_set->insert(val->GetIdentityHash()); |
310 | 310 |
311 for (uint32 i = 0; i < property_names->Length(); ++i) { | 311 for (uint32 i = 0; i < property_names->Length(); ++i) { |
312 v8::Handle<v8::Value> key(property_names->Get(i)); | 312 v8::Handle<v8::Value> key(property_names->Get(i)); |
313 | 313 |
314 if (!key->IsString() || !val->HasRealNamedProperty(key->ToString())) | 314 // base::DictionaryValue can only have string properties. |
| 315 if (!key->IsString()) |
| 316 continue; |
| 317 |
| 318 // Ensure that the property actually exists. |
| 319 if (!val->HasRealNamedProperty(key->ToString())) |
| 320 continue; |
| 321 |
| 322 // Skip all callbacks: crbug.com/139933 |
| 323 if (val->HasRealNamedCallbackProperty(key->ToString())) |
315 continue; | 324 continue; |
316 | 325 |
317 v8::String::Utf8Value name_utf8(key->ToString()); | 326 v8::String::Utf8Value name_utf8(key->ToString()); |
318 | 327 |
319 v8::TryCatch try_catch; | 328 v8::TryCatch try_catch; |
320 v8::Handle<v8::Value> child_v8 = val->Get(key); | 329 v8::Handle<v8::Value> child_v8 = val->Get(key); |
321 | 330 |
322 if (try_catch.HasCaught()) { | 331 if (try_catch.HasCaught()) { |
323 LOG(ERROR) << "Getter for property " << *name_utf8 | 332 LOG(ERROR) << "Getter for property " << *name_utf8 |
324 << " threw an exception."; | 333 << " threw an exception."; |
(...skipping 25 matching lines...) Expand all Loading... |
350 // We can avoid all bugs related to this by stripping null. | 359 // We can avoid all bugs related to this by stripping null. |
351 if (strip_null_from_objects_ && child->IsType(Value::TYPE_NULL)) | 360 if (strip_null_from_objects_ && child->IsType(Value::TYPE_NULL)) |
352 continue; | 361 continue; |
353 | 362 |
354 result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()), | 363 result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()), |
355 child.release()); | 364 child.release()); |
356 } | 365 } |
357 | 366 |
358 return result.release(); | 367 return result.release(); |
359 } | 368 } |
OLD | NEW |