diff options
author | reillyg <reillyg@chromium.org> | 2015-09-10 17:25:54 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-11 00:26:37 +0000 |
commit | 259c0a3f44bdd8130c5d835e9f596624a079fbd1 (patch) | |
tree | 8c69523a7745aa71e6d67cdedad5b5ce0336b4a9 /extensions/renderer/guest_view | |
parent | 9a1461f5cbacfc7d5c40ac2cd2cc0ec104e9b39c (diff) | |
download | chromium_src-259c0a3f44bdd8130c5d835e9f596624a079fbd1.zip chromium_src-259c0a3f44bdd8130c5d835e9f596624a079fbd1.tar.gz chromium_src-259c0a3f44bdd8130c5d835e9f596624a079fbd1.tar.bz2 |
Add scoped_ptr-safe base::Value to Dictionary/List conversion functions.
This change adds two static From() functions to the DictionaryValue and
ListValue classes which take a scoped_ptr to a Value and either convert
it to a scoped_ptr to a DictionaryValue or ListValue, or return nullptr.
These are intended to replace the existing pattern,
make_scoped_ptr(static_cast<base::DictionaryValue*>(value.release()))
with the shorter and safer alternative,
base::DictionaryValue::From(value.Pass())
Instances of this pattern in //extensions have been converted as
examples.
Review URL: https://codereview.chromium.org/1308013005
Cr-Commit-Position: refs/heads/master@{#348294}
Diffstat (limited to 'extensions/renderer/guest_view')
-rw-r--r-- | extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc b/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc index 3b5ce79..7eb1292 100644 --- a/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc +++ b/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc @@ -151,9 +151,8 @@ void GuestViewInternalCustomBindings::AttachGuest( scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); scoped_ptr<base::Value> params_as_value( converter->FromV8Value(args[2], context()->v8_context())); - CHECK(params_as_value->IsType(base::Value::TYPE_DICTIONARY)); - params.reset( - static_cast<base::DictionaryValue*>(params_as_value.release())); + params = base::DictionaryValue::From(params_as_value.Pass()); + CHECK(params); } // Add flag to |params| to indicate that the element size is specified in @@ -226,9 +225,8 @@ void GuestViewInternalCustomBindings::AttachIframeGuest( scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); scoped_ptr<base::Value> params_as_value( converter->FromV8Value(args[2], context()->v8_context())); - CHECK(params_as_value->IsType(base::Value::TYPE_DICTIONARY)); - params.reset( - static_cast<base::DictionaryValue*>(params_as_value.release())); + params = base::DictionaryValue::From(params_as_value.Pass()); + CHECK(params); } // Add flag to |params| to indicate that the element size is specified in |