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 named callbacks from objects that have internal fields: | |
323 // crbug.com/139933 | |
324 if (val->InternalFieldCount() > 0 && | |
325 val->HasRealNamedCallbackProperty(key->ToString())) | |
Aaron Boodman
2012/08/04 11:34:19
Please add braces since the if statement is more t
eaugusti
2012/08/04 19:10:37
Done.
| |
315 continue; | 326 continue; |
316 | 327 |
317 v8::String::Utf8Value name_utf8(key->ToString()); | 328 v8::String::Utf8Value name_utf8(key->ToString()); |
318 | 329 |
319 v8::TryCatch try_catch; | 330 v8::TryCatch try_catch; |
320 v8::Handle<v8::Value> child_v8 = val->Get(key); | 331 v8::Handle<v8::Value> child_v8 = val->Get(key); |
321 | 332 |
322 if (try_catch.HasCaught()) { | 333 if (try_catch.HasCaught()) { |
323 LOG(ERROR) << "Getter for property " << *name_utf8 | 334 LOG(ERROR) << "Getter for property " << *name_utf8 |
324 << " threw an exception."; | 335 << " threw an exception."; |
(...skipping 25 matching lines...) Expand all Loading... | |
350 // We can avoid all bugs related to this by stripping null. | 361 // We can avoid all bugs related to this by stripping null. |
351 if (strip_null_from_objects_ && child->IsType(Value::TYPE_NULL)) | 362 if (strip_null_from_objects_ && child->IsType(Value::TYPE_NULL)) |
352 continue; | 363 continue; |
353 | 364 |
354 result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()), | 365 result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()), |
355 child.release()); | 366 child.release()); |
356 } | 367 } |
357 | 368 |
358 return result.release(); | 369 return result.release(); |
359 } | 370 } |
OLD | NEW |