Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(896)

Side by Side Diff: extensions/renderer/argument_spec.cc

Issue 2847853002: [Extensions Bindings] Add errors to signature parsing (Closed)
Patch Set: Rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/renderer/api_signature_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « extensions/renderer/api_signature_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698