| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 146 |
| 147 return result; | 147 return result; |
| 148 } | 148 } |
| 149 | 149 |
| 150 v8::Handle<v8::Value> V8ValueConverterImpl::ToV8Object( | 150 v8::Handle<v8::Value> V8ValueConverterImpl::ToV8Object( |
| 151 const DictionaryValue* val) const { | 151 const DictionaryValue* val) const { |
| 152 v8::Handle<v8::Object> result(v8::Object::New()); | 152 v8::Handle<v8::Object> result(v8::Object::New()); |
| 153 | 153 |
| 154 for (DictionaryValue::key_iterator iter = val->begin_keys(); | 154 for (DictionaryValue::key_iterator iter = val->begin_keys(); |
| 155 iter != val->end_keys(); ++iter) { | 155 iter != val->end_keys(); ++iter) { |
| 156 Value* child = NULL; | 156 const Value* child = NULL; |
| 157 CHECK(val->GetWithoutPathExpansion(*iter, &child)); | 157 CHECK(val->GetWithoutPathExpansion(*iter, &child)); |
| 158 | 158 |
| 159 const std::string& key = *iter; | 159 const std::string& key = *iter; |
| 160 v8::Handle<v8::Value> child_v8 = ToV8ValueImpl(child); | 160 v8::Handle<v8::Value> child_v8 = ToV8ValueImpl(child); |
| 161 CHECK(!child_v8.IsEmpty()); | 161 CHECK(!child_v8.IsEmpty()); |
| 162 | 162 |
| 163 v8::TryCatch try_catch; | 163 v8::TryCatch try_catch; |
| 164 result->Set(v8::String::New(key.c_str(), key.length()), child_v8); | 164 result->Set(v8::String::New(key.c_str(), key.length()), child_v8); |
| 165 if (try_catch.HasCaught()) { | 165 if (try_catch.HasCaught()) { |
| 166 LOG(ERROR) << "Setter for property " << key.c_str() << " threw an " | 166 LOG(ERROR) << "Setter for property " << key.c_str() << " threw an " |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 // We can avoid all bugs related to this by stripping null. | 350 // We can avoid all bugs related to this by stripping null. |
| 351 if (strip_null_from_objects_ && child->IsType(Value::TYPE_NULL)) | 351 if (strip_null_from_objects_ && child->IsType(Value::TYPE_NULL)) |
| 352 continue; | 352 continue; |
| 353 | 353 |
| 354 result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()), | 354 result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()), |
| 355 child.release()); | 355 child.release()); |
| 356 } | 356 } |
| 357 | 357 |
| 358 return result.release(); | 358 return result.release(); |
| 359 } | 359 } |
| OLD | NEW |