| 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/float_util.h" | 9 #include "base/float_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 // Don't consider DOM objects. This check matches isHostObject() in Blink's | 399 // Don't consider DOM objects. This check matches isHostObject() in Blink's |
| 400 // bindings/v8/V8Binding.h used in structured cloning. It reads: | 400 // bindings/v8/V8Binding.h used in structured cloning. It reads: |
| 401 // | 401 // |
| 402 // If the object has any internal fields, then we won't be able to serialize | 402 // If the object has any internal fields, then we won't be able to serialize |
| 403 // or deserialize them; conveniently, this is also a quick way to detect DOM | 403 // or deserialize them; conveniently, this is also a quick way to detect DOM |
| 404 // wrapper objects, because the mechanism for these relies on data stored in | 404 // wrapper objects, because the mechanism for these relies on data stored in |
| 405 // these fields. | 405 // these fields. |
| 406 // | 406 // |
| 407 // NOTE: check this after |strategy_| so that callers have a chance to | 407 // NOTE: check this after |strategy_| so that callers have a chance to |
| 408 // do something else, such as convert to the node's name rather than NULL. | 408 // do something else, such as convert to the node's name rather than NULL. |
| 409 // |
| 410 // ANOTHER NOTE: returning an empty dictionary here to minimise surprise. |
| 411 // See also http://crbug.com/330559. |
| 409 if (val->InternalFieldCount()) | 412 if (val->InternalFieldCount()) |
| 410 return NULL; | 413 return new base::DictionaryValue(); |
| 411 | 414 |
| 412 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); | 415 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
| 413 v8::Handle<v8::Array> property_names(val->GetOwnPropertyNames()); | 416 v8::Handle<v8::Array> property_names(val->GetOwnPropertyNames()); |
| 414 | 417 |
| 415 for (uint32 i = 0; i < property_names->Length(); ++i) { | 418 for (uint32 i = 0; i < property_names->Length(); ++i) { |
| 416 v8::Handle<v8::Value> key(property_names->Get(i)); | 419 v8::Handle<v8::Value> key(property_names->Get(i)); |
| 417 | 420 |
| 418 // Extend this test to cover more types as necessary and if sensible. | 421 // Extend this test to cover more types as necessary and if sensible. |
| 419 if (!key->IsString() && | 422 if (!key->IsString() && |
| 420 !key->IsNumber()) { | 423 !key->IsNumber()) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 continue; | 467 continue; |
| 465 | 468 |
| 466 result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()), | 469 result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()), |
| 467 child.release()); | 470 child.release()); |
| 468 } | 471 } |
| 469 | 472 |
| 470 return result.release(); | 473 return result.release(); |
| 471 } | 474 } |
| 472 | 475 |
| 473 } // namespace content | 476 } // namespace content |
| OLD | NEW |