diff options
author | bashi <bashi@chromium.org> | 2015-06-29 22:44:20 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-30 05:45:07 +0000 |
commit | facd48b87e81813aabcb7bccd7ae98d6db089cd6 (patch) | |
tree | 66becb105cf71f4ea01a129932ea197479e35ae5 /extensions/renderer/console.cc | |
parent | 309e0545fa27c4469a673d4057a8d4e280bbdda1 (diff) | |
download | chromium_src-facd48b87e81813aabcb7bccd7ae98d6db089cd6.zip chromium_src-facd48b87e81813aabcb7bccd7ae98d6db089cd6.tar.gz chromium_src-facd48b87e81813aabcb7bccd7ae98d6db089cd6.tar.bz2 |
extensions: Use V8 Maybe version of GetFunction()
Also use As<v8::Object>() for return value of gin::CreateHandle()
because it should always be an object.
BUG=479065
Review URL: https://codereview.chromium.org/1208333002
Cr-Commit-Position: refs/heads/master@{#336731}
Diffstat (limited to 'extensions/renderer/console.cc')
-rw-r--r-- | extensions/renderer/console.cc | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/extensions/renderer/console.cc b/extensions/renderer/console.cc index c2dc09b..b763e8e 100644 --- a/extensions/renderer/console.cc +++ b/extensions/renderer/console.cc @@ -14,10 +14,13 @@ #include "extensions/renderer/extension_frame_helper.h" #include "extensions/renderer/script_context.h" #include "extensions/renderer/script_context_set.h" +#include "extensions/renderer/v8_helpers.h" namespace extensions { namespace console { +using namespace v8_helpers; + namespace { // Writes |message| to stack to show up in minidump, then crashes. @@ -62,7 +65,16 @@ void BindLogMethod(v8::Isolate* isolate, isolate, &BoundLogMethodCallback, v8::External::New(isolate, reinterpret_cast<void*>(log_method))); - target->Set(v8::String::NewFromUtf8(isolate, name.c_str()), + v8::Local<v8::Function> function; + if (!tmpl->GetFunction(isolate->GetCurrentContext()).ToLocal(&function)) { + LOG(FATAL) << "Could not create log function \"" << name << "\""; + return; + } + v8::Local<v8::String> v8_name = ToV8StringUnsafe(isolate, name); + if (!SetProperty(isolate->GetCurrentContext(), target, v8_name, function)) { + LOG(WARNING) << "Could not bind log method \"" << name << "\""; + } + SetProperty(isolate->GetCurrentContext(), target, v8_name, tmpl->GetFunction()); } |