This source file includes following definitions.
- FromV8Object
- FromV8Array
- FromV8ObjectInternal
#include "chrome/renderer/extensions/activity_log_converter_strategy.h"
#include "base/values.h"
namespace extensions {
bool ActivityLogConverterStrategy::FromV8Object(v8::Handle<v8::Object> value,
base::Value** out,
v8::Isolate* isolate) const {
return FromV8ObjectInternal(value, out, isolate);
}
bool ActivityLogConverterStrategy::FromV8Array(v8::Handle<v8::Array> value,
base::Value** out,
v8::Isolate* isolate) const {
return FromV8ObjectInternal(value, out, isolate);
}
bool ActivityLogConverterStrategy::FromV8ObjectInternal(
v8::Handle<v8::Object> value,
base::Value** out,
v8::Isolate* isolate) const {
v8::Handle<v8::String> name = v8::String::NewFromUtf8(isolate, "[");
if (value->IsFunction()) {
name =
v8::String::Concat(name, v8::String::NewFromUtf8(isolate, "Function"));
v8::Handle<v8::Value> fname =
v8::Handle<v8::Function>::Cast(value)->GetName();
if (fname->IsString() && v8::Handle<v8::String>::Cast(fname)->Length()) {
name = v8::String::Concat(name, v8::String::NewFromUtf8(isolate, " "));
name = v8::String::Concat(name, v8::Handle<v8::String>::Cast(fname));
name = v8::String::Concat(name, v8::String::NewFromUtf8(isolate, "()"));
}
} else {
name = v8::String::Concat(name, value->GetConstructorName());
}
name = v8::String::Concat(name, v8::String::NewFromUtf8(isolate, "]"));
*out = new base::StringValue(std::string(*v8::String::Utf8Value(name)));
return true;
}
}