OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "extensions/renderer/argument_spec.h" | 5 #include "extensions/renderer/argument_spec.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/strings/string_piece.h" | 8 #include "base/strings/string_piece.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "content/public/child/v8_value_converter.h" | 10 #include "content/public/child/v8_value_converter.h" |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 | 413 |
414 v8::Local<v8::Value> prop_value; | 414 v8::Local<v8::Value> prop_value; |
415 // Fun: It's possible that a previous getter has removed the property from | 415 // Fun: It's possible that a previous getter has removed the property from |
416 // the object. This isn't that big of a deal, since it would only manifest | 416 // the object. This isn't that big of a deal, since it would only manifest |
417 // in the case of some reasonably-crazy script objects, and it's probably | 417 // in the case of some reasonably-crazy script objects, and it's probably |
418 // not worth optimizing for the uncommon case to the detriment of the | 418 // not worth optimizing for the uncommon case to the detriment of the |
419 // common (and either should be totally safe). We can always add a | 419 // common (and either should be totally safe). We can always add a |
420 // HasOwnProperty() check here in the future, if we desire. | 420 // HasOwnProperty() check here in the future, if we desire. |
421 // See also comment in ParseArgumentToArray() about passing in custom | 421 // See also comment in ParseArgumentToArray() about passing in custom |
422 // crazy values here. | 422 // crazy values here. |
423 if (!object->Get(context, key).ToLocal(&prop_value)) | 423 if (!object->Get(context, key).ToLocal(&prop_value)) { |
| 424 *error = api_errors::ScriptThrewError(); |
424 return false; | 425 return false; |
| 426 } |
425 | 427 |
426 // Note: We don't serialize undefined or null values. | 428 // Note: We don't serialize undefined or null values. |
427 // TODO(devlin): This matches current behavior, but it is correct? | 429 // TODO(devlin): This matches current behavior, but it is correct? |
428 if (prop_value->IsUndefined() || prop_value->IsNull()) { | 430 if (prop_value->IsUndefined() || prop_value->IsNull()) { |
429 if (!property_spec->optional_) { | 431 if (!property_spec->optional_) { |
430 *error = api_errors::MissingRequiredProperty(*utf8_key); | 432 *error = api_errors::MissingRequiredProperty(*utf8_key); |
431 return false; | 433 return false; |
432 } | 434 } |
433 continue; | 435 continue; |
434 } | 436 } |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 break; | 597 break; |
596 case ArgumentType::CHOICES: | 598 case ArgumentType::CHOICES: |
597 case ArgumentType::ANY: | 599 case ArgumentType::ANY: |
598 NOTREACHED(); | 600 NOTREACHED(); |
599 } | 601 } |
600 | 602 |
601 return api_errors::InvalidType(expected_type, GetV8ValueTypeString(value)); | 603 return api_errors::InvalidType(expected_type, GetV8ValueTypeString(value)); |
602 } | 604 } |
603 | 605 |
604 } // namespace extensions | 606 } // namespace extensions |
OLD | NEW |