Merge branch 'master' into native-window-open
This commit is contained in:
commit
7ac93045b7
157 changed files with 2239 additions and 1058 deletions
|
@ -6,17 +6,17 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
#include "atom_natives.h" // NOLINT: This file is generated with coffee2c.
|
||||
|
||||
#include "atom/common/asar/archive.h"
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "native_mate/arguments.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
#include "native_mate/wrappable.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "atom_natives.h" // NOLINT: This file is generated with js2c.
|
||||
|
||||
namespace {
|
||||
|
||||
class Archive : public mate::Wrappable<Archive> {
|
||||
|
@ -130,7 +130,7 @@ class Archive : public mate::Wrappable<Archive> {
|
|||
void InitAsarSupport(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> process,
|
||||
v8::Local<v8::Value> require) {
|
||||
// Evaluate asar_init.coffee.
|
||||
// Evaluate asar_init.js.
|
||||
const char* asar_init_native = reinterpret_cast<const char*>(
|
||||
static_cast<const unsigned char*>(node::asar_init_data));
|
||||
v8::Local<v8::Script> asar_init = v8::Script::Compile(v8::String::NewFromUtf8(
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/process/process_metrics.h"
|
||||
#include "base/sys_info.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
|
||||
namespace atom {
|
||||
|
@ -23,51 +23,6 @@ namespace {
|
|||
// Dummy class type that used for crashing the program.
|
||||
struct DummyClass { bool crash; };
|
||||
|
||||
void Hang() {
|
||||
for (;;)
|
||||
base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1));
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> GetProcessMemoryInfo(v8::Isolate* isolate) {
|
||||
std::unique_ptr<base::ProcessMetrics> metrics(
|
||||
base::ProcessMetrics::CreateCurrentProcessMetrics());
|
||||
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("workingSetSize",
|
||||
static_cast<double>(metrics->GetWorkingSetSize() >> 10));
|
||||
dict.Set("peakWorkingSetSize",
|
||||
static_cast<double>(metrics->GetPeakWorkingSetSize() >> 10));
|
||||
|
||||
size_t private_bytes, shared_bytes;
|
||||
if (metrics->GetMemoryBytes(&private_bytes, &shared_bytes)) {
|
||||
dict.Set("privateBytes", static_cast<double>(private_bytes >> 10));
|
||||
dict.Set("sharedBytes", static_cast<double>(shared_bytes >> 10));
|
||||
}
|
||||
|
||||
return dict.GetHandle();
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> GetSystemMemoryInfo(v8::Isolate* isolate,
|
||||
mate::Arguments* args) {
|
||||
base::SystemMemoryInfoKB mem_info;
|
||||
if (!base::GetSystemMemoryInfo(&mem_info)) {
|
||||
args->ThrowError("Unable to retrieve system memory information");
|
||||
return v8::Undefined(isolate);
|
||||
}
|
||||
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("total", mem_info.total);
|
||||
dict.Set("free", mem_info.free);
|
||||
|
||||
// NB: These return bogus values on macOS
|
||||
#if !defined(OS_MACOSX)
|
||||
dict.Set("swapTotal", mem_info.swap_total);
|
||||
dict.Set("swapFree", mem_info.swap_free);
|
||||
#endif
|
||||
|
||||
return dict.GetHandle();
|
||||
}
|
||||
|
||||
// Called when there is a fatal error in V8, we just crash the process here so
|
||||
// we can get the stack trace.
|
||||
void FatalErrorCallback(const char* location, const char* message) {
|
||||
|
@ -81,6 +36,7 @@ void FatalErrorCallback(const char* location, const char* message) {
|
|||
AtomBindings::AtomBindings(uv_loop_t* loop) {
|
||||
uv_async_init(loop, &call_next_tick_async_, OnCallNextTick);
|
||||
call_next_tick_async_.data = this;
|
||||
metrics_ = base::ProcessMetrics::CreateCurrentProcessMetrics();
|
||||
}
|
||||
|
||||
AtomBindings::~AtomBindings() {
|
||||
|
@ -97,6 +53,9 @@ void AtomBindings::BindTo(v8::Isolate* isolate,
|
|||
dict.SetMethod("log", &Log);
|
||||
dict.SetMethod("getProcessMemoryInfo", &GetProcessMemoryInfo);
|
||||
dict.SetMethod("getSystemMemoryInfo", &GetSystemMemoryInfo);
|
||||
dict.SetMethod("getCPUUsage",
|
||||
base::Bind(&AtomBindings::GetCPUUsage, base::Unretained(this)));
|
||||
dict.SetMethod("getIOCounters", &GetIOCounters);
|
||||
#if defined(OS_POSIX)
|
||||
dict.SetMethod("setFdLimit", &base::SetFdLimit);
|
||||
#endif
|
||||
|
@ -168,4 +127,81 @@ void AtomBindings::Crash() {
|
|||
static_cast<DummyClass*>(nullptr)->crash = true;
|
||||
}
|
||||
|
||||
// static
|
||||
void AtomBindings::Hang() {
|
||||
for (;;)
|
||||
base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1));
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Local<v8::Value> AtomBindings::GetProcessMemoryInfo(v8::Isolate* isolate) {
|
||||
std::unique_ptr<base::ProcessMetrics> metrics(
|
||||
base::ProcessMetrics::CreateCurrentProcessMetrics());
|
||||
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("workingSetSize",
|
||||
static_cast<double>(metrics->GetWorkingSetSize() >> 10));
|
||||
dict.Set("peakWorkingSetSize",
|
||||
static_cast<double>(metrics->GetPeakWorkingSetSize() >> 10));
|
||||
|
||||
size_t private_bytes, shared_bytes;
|
||||
if (metrics->GetMemoryBytes(&private_bytes, &shared_bytes)) {
|
||||
dict.Set("privateBytes", static_cast<double>(private_bytes >> 10));
|
||||
dict.Set("sharedBytes", static_cast<double>(shared_bytes >> 10));
|
||||
}
|
||||
|
||||
return dict.GetHandle();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Local<v8::Value> AtomBindings::GetSystemMemoryInfo(v8::Isolate* isolate,
|
||||
mate::Arguments* args) {
|
||||
base::SystemMemoryInfoKB mem_info;
|
||||
if (!base::GetSystemMemoryInfo(&mem_info)) {
|
||||
args->ThrowError("Unable to retrieve system memory information");
|
||||
return v8::Undefined(isolate);
|
||||
}
|
||||
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("total", mem_info.total);
|
||||
dict.Set("free", mem_info.free);
|
||||
|
||||
// NB: These return bogus values on macOS
|
||||
#if !defined(OS_MACOSX)
|
||||
dict.Set("swapTotal", mem_info.swap_total);
|
||||
dict.Set("swapFree", mem_info.swap_free);
|
||||
#endif
|
||||
|
||||
return dict.GetHandle();
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> AtomBindings::GetCPUUsage(v8::Isolate* isolate) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
int processor_count = base::SysInfo::NumberOfProcessors();
|
||||
dict.Set("percentCPUUsage",
|
||||
metrics_->GetPlatformIndependentCPUUsage() / processor_count);
|
||||
dict.Set("idleWakeupsPerSecond", metrics_->GetIdleWakeupsPerSecond());
|
||||
|
||||
return dict.GetHandle();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Local<v8::Value> AtomBindings::GetIOCounters(v8::Isolate* isolate) {
|
||||
std::unique_ptr<base::ProcessMetrics> metrics(
|
||||
base::ProcessMetrics::CreateCurrentProcessMetrics());
|
||||
base::IoCounters io_counters;
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
|
||||
if (metrics->GetIOCounters(&io_counters)) {
|
||||
dict.Set("readOperationCount", io_counters.ReadOperationCount);
|
||||
dict.Set("writeOperationCount", io_counters.WriteOperationCount);
|
||||
dict.Set("otherOperationCount", io_counters.OtherOperationCount);
|
||||
dict.Set("readTransferCount", io_counters.ReadTransferCount);
|
||||
dict.Set("writeTransferCount", io_counters.WriteTransferCount);
|
||||
dict.Set("otherTransferCount", io_counters.OtherTransferCount);
|
||||
}
|
||||
|
||||
return dict.GetHandle();
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
#include <list>
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/process/process_metrics.h"
|
||||
#include "base/strings/string16.h"
|
||||
#include "native_mate/arguments.h"
|
||||
#include "v8/include/v8.h"
|
||||
#include "vendor/node/deps/uv/include/uv.h"
|
||||
|
||||
|
@ -32,6 +34,12 @@ class AtomBindings {
|
|||
|
||||
static void Log(const base::string16& message);
|
||||
static void Crash();
|
||||
static void Hang();
|
||||
static v8::Local<v8::Value> GetProcessMemoryInfo(v8::Isolate* isolate);
|
||||
static v8::Local<v8::Value> GetSystemMemoryInfo(v8::Isolate* isolate,
|
||||
mate::Arguments* args);
|
||||
v8::Local<v8::Value> GetCPUUsage(v8::Isolate* isolate);
|
||||
static v8::Local<v8::Value> GetIOCounters(v8::Isolate* isolate);
|
||||
|
||||
private:
|
||||
void ActivateUVLoop(v8::Isolate* isolate);
|
||||
|
@ -40,6 +48,7 @@ class AtomBindings {
|
|||
|
||||
uv_async_t call_next_tick_async_;
|
||||
std::list<node::Environment*> pending_next_ticks_;
|
||||
std::unique_ptr<base::ProcessMetrics> metrics_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomBindings);
|
||||
};
|
||||
|
|
|
@ -12,8 +12,7 @@ namespace atom {
|
|||
|
||||
ObjectLifeMonitor::ObjectLifeMonitor(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> target)
|
||||
: context_(isolate, isolate->GetCurrentContext()),
|
||||
target_(isolate, target),
|
||||
: target_(isolate, target),
|
||||
weak_ptr_factory_(this) {
|
||||
target_.SetWeak(this, OnObjectGC, v8::WeakCallbackType::kParameter);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ class ObjectLifeMonitor {
|
|||
static void OnObjectGC(const v8::WeakCallbackInfo<ObjectLifeMonitor>& data);
|
||||
static void Free(const v8::WeakCallbackInfo<ObjectLifeMonitor>& data);
|
||||
|
||||
v8::Global<v8::Context> context_;
|
||||
v8::Global<v8::Object> target_;
|
||||
|
||||
base::WeakPtrFactory<ObjectLifeMonitor> weak_ptr_factory_;
|
||||
|
|
|
@ -181,7 +181,7 @@ bool Archive::Init() {
|
|||
std::string error;
|
||||
base::JSONReader reader;
|
||||
std::unique_ptr<base::Value> value(reader.ReadToValue(header));
|
||||
if (!value || !value->IsType(base::Value::TYPE_DICTIONARY)) {
|
||||
if (!value || !value->IsType(base::Value::Type::DICTIONARY)) {
|
||||
LOG(ERROR) << "Failed to parse header: " << error;
|
||||
return false;
|
||||
}
|
||||
|
@ -269,8 +269,9 @@ bool Archive::Realpath(const base::FilePath& path, base::FilePath* realpath) {
|
|||
}
|
||||
|
||||
bool Archive::CopyFileOut(const base::FilePath& path, base::FilePath* out) {
|
||||
if (external_files_.contains(path)) {
|
||||
*out = external_files_.get(path)->path();
|
||||
auto it = external_files_.find(path.value());
|
||||
if (it != external_files_.end()) {
|
||||
*out = it->second->path();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -296,7 +297,7 @@ bool Archive::CopyFileOut(const base::FilePath& path, base::FilePath* out) {
|
|||
#endif
|
||||
|
||||
*out = temp_file->path();
|
||||
external_files_.set(path, std::move(temp_file));
|
||||
external_files_[path.value()] = std::move(temp_file);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
#define ATOM_COMMON_ASAR_ARCHIVE_H_
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "base/containers/scoped_ptr_hash_map.h"
|
||||
#include "base/files/file.h"
|
||||
#include "base/files/file_path.h"
|
||||
|
||||
|
@ -75,8 +75,8 @@ class Archive {
|
|||
std::unique_ptr<base::DictionaryValue> header_;
|
||||
|
||||
// Cached external temporary files.
|
||||
base::ScopedPtrHashMap<base::FilePath, std::unique_ptr<ScopedTemporaryFile>>
|
||||
external_files_;
|
||||
std::unordered_map<base::FilePath::StringType,
|
||||
std::unique_ptr<ScopedTemporaryFile>> external_files_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Archive);
|
||||
};
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
#define ATOM_COMMON_ATOM_VERSION_H_
|
||||
|
||||
#define ATOM_MAJOR_VERSION 1
|
||||
#define ATOM_MINOR_VERSION 6
|
||||
#define ATOM_PATCH_VERSION 7
|
||||
#define ATOM_MINOR_VERSION 7
|
||||
#define ATOM_PATCH_VERSION 0
|
||||
|
||||
#define ATOM_VERSION_IS_RELEASE 1
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef ATOM_COMMON_CHROME_VERSION_H_
|
||||
#define ATOM_COMMON_CHROME_VERSION_H_
|
||||
|
||||
#define CHROME_VERSION_STRING "56.0.2924.87"
|
||||
#define CHROME_VERSION_STRING "58.0.3029.110"
|
||||
#define CHROME_VERSION "v" CHROME_VERSION_STRING
|
||||
|
||||
#endif // ATOM_COMMON_CHROME_VERSION_H_
|
||||
|
|
|
@ -31,4 +31,3 @@ namespace IPC {
|
|||
namespace IPC {
|
||||
#include "atom/common/common_message_generator.h"
|
||||
} // namespace IPC
|
||||
|
||||
|
|
|
@ -9,4 +9,5 @@
|
|||
#include "chrome/common/tts_messages.h"
|
||||
#include "chrome/common/widevine_cdm_messages.h"
|
||||
#include "chrome/common/chrome_utility_messages.h"
|
||||
#include "chrome/common/chrome_utility_printing_messages.h"
|
||||
#include "components/pdf/common/pdf_messages.h"
|
||||
|
|
|
@ -43,11 +43,16 @@ void CrashReporterMac::InitBreakpad(const std::string& product_name,
|
|||
base::FilePath handler_path =
|
||||
framework_bundle_path.Append("Resources").Append("crashpad_handler");
|
||||
|
||||
std::vector<std::string> args = {
|
||||
"--no-rate-limit",
|
||||
"--no-upload-gzip", // not all servers accept gzip
|
||||
};
|
||||
|
||||
crashpad::CrashpadClient crashpad_client;
|
||||
crashpad_client.StartHandler(handler_path, crashes_dir, crashes_dir,
|
||||
submit_url,
|
||||
StringMap(),
|
||||
std::vector<std::string>(),
|
||||
args,
|
||||
true,
|
||||
false);
|
||||
} // @autoreleasepool
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
#include "content/public/browser/native_web_keyboard_event.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "third_party/WebKit/public/platform/WebInputEvent.h"
|
||||
#include "third_party/WebKit/public/web/WebCache.h"
|
||||
#include "third_party/WebKit/public/platform/WebMouseEvent.h"
|
||||
#include "third_party/WebKit/public/platform/WebMouseWheelEvent.h"
|
||||
#include "third_party/WebKit/public/web/WebDeviceEmulationParams.h"
|
||||
#include "third_party/WebKit/public/web/WebFindOptions.h"
|
||||
#include "ui/base/clipboard/clipboard.h"
|
||||
|
@ -149,12 +150,14 @@ bool Converter<blink::WebInputEvent>::FromV8(
|
|||
mate::Dictionary dict;
|
||||
if (!ConvertFromV8(isolate, val, &dict))
|
||||
return false;
|
||||
if (!dict.Get("type", &out->type))
|
||||
blink::WebInputEvent::Type type;
|
||||
if (!dict.Get("type", &type))
|
||||
return false;
|
||||
out->setType(type);
|
||||
std::vector<blink::WebInputEvent::Modifiers> modifiers;
|
||||
if (dict.Get("modifiers", &modifiers))
|
||||
out->modifiers = VectorToBitArray(modifiers);
|
||||
out->timeStampSeconds = base::Time::Now().ToDoubleT();
|
||||
out->setModifiers(VectorToBitArray(modifiers));
|
||||
out->setTimeStampSeconds(base::Time::Now().ToDoubleT());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -175,19 +178,19 @@ bool Converter<blink::WebKeyboardEvent>::FromV8(
|
|||
ui::KeyboardCode keyCode = atom::KeyboardCodeFromStr(str, &shifted);
|
||||
out->windowsKeyCode = keyCode;
|
||||
if (shifted)
|
||||
out->modifiers |= blink::WebInputEvent::ShiftKey;
|
||||
out->setModifiers(out->modifiers() | blink::WebInputEvent::ShiftKey);
|
||||
|
||||
ui::DomCode domCode = ui::UsLayoutKeyboardCodeToDomCode(keyCode);
|
||||
out->domCode = static_cast<int>(domCode);
|
||||
|
||||
ui::DomKey domKey;
|
||||
ui::KeyboardCode dummy_code;
|
||||
int flags = atom::WebEventModifiersToEventFlags(out->modifiers);
|
||||
int flags = atom::WebEventModifiersToEventFlags(out->modifiers());
|
||||
if (ui::DomCodeToUsLayoutDomKey(domCode, flags, &domKey, &dummy_code))
|
||||
out->domKey = static_cast<int>(domKey);
|
||||
|
||||
if ((out->type == blink::WebInputEvent::Char ||
|
||||
out->type == blink::WebInputEvent::RawKeyDown)) {
|
||||
if ((out->type() == blink::WebInputEvent::Char ||
|
||||
out->type() == blink::WebInputEvent::RawKeyDown)) {
|
||||
// Make sure to not read beyond the buffer in case some bad code doesn't
|
||||
// NULL-terminate it (this is called from plugins).
|
||||
size_t text_length_cap = blink::WebKeyboardEvent::textLengthCap;
|
||||
|
@ -219,20 +222,20 @@ v8::Local<v8::Value> Converter<content::NativeWebKeyboardEvent>::ToV8(
|
|||
v8::Isolate* isolate, const content::NativeWebKeyboardEvent& in) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
|
||||
if (in.type == blink::WebInputEvent::Type::RawKeyDown)
|
||||
if (in.type() == blink::WebInputEvent::Type::RawKeyDown)
|
||||
dict.Set("type", "keyDown");
|
||||
else if (in.type == blink::WebInputEvent::Type::KeyUp)
|
||||
else if (in.type() == blink::WebInputEvent::Type::KeyUp)
|
||||
dict.Set("type", "keyUp");
|
||||
dict.Set("key", ui::KeycodeConverter::DomKeyToKeyString(in.domKey));
|
||||
dict.Set("code", ui::KeycodeConverter::DomCodeToCodeString(
|
||||
static_cast<ui::DomCode>(in.domCode)));
|
||||
|
||||
using Modifiers = blink::WebInputEvent::Modifiers;
|
||||
dict.Set("isAutoRepeat", (in.modifiers & Modifiers::IsAutoRepeat) != 0);
|
||||
dict.Set("shift", (in.modifiers & Modifiers::ShiftKey) != 0);
|
||||
dict.Set("control", (in.modifiers & Modifiers::ControlKey) != 0);
|
||||
dict.Set("alt", (in.modifiers & Modifiers::AltKey) != 0);
|
||||
dict.Set("meta", (in.modifiers & Modifiers::MetaKey) != 0);
|
||||
dict.Set("isAutoRepeat", (in.modifiers() & Modifiers::IsAutoRepeat) != 0);
|
||||
dict.Set("shift", (in.modifiers() & Modifiers::ShiftKey) != 0);
|
||||
dict.Set("control", (in.modifiers() & Modifiers::ControlKey) != 0);
|
||||
dict.Set("alt", (in.modifiers() & Modifiers::AltKey) != 0);
|
||||
dict.Set("meta", (in.modifiers() & Modifiers::MetaKey) != 0);
|
||||
|
||||
return dict.GetHandle();
|
||||
}
|
||||
|
@ -277,7 +280,7 @@ bool Converter<blink::WebMouseWheelEvent>::FromV8(
|
|||
bool can_scroll = true;
|
||||
if (dict.Get("canScroll", &can_scroll) && !can_scroll) {
|
||||
out->hasPreciseScrollingDeltas = false;
|
||||
out->modifiers &= ~blink::WebInputEvent::ControlKey;
|
||||
out->setModifiers(out->modifiers() & ~blink::WebInputEvent::ControlKey);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
|
@ -444,7 +447,7 @@ v8::Local<v8::Value> Converter<blink::WebCache::ResourceTypeStat>::ToV8(
|
|||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("count", static_cast<uint32_t>(stat.count));
|
||||
dict.Set("size", static_cast<double>(stat.size));
|
||||
dict.Set("liveSize", static_cast<double>(stat.liveSize));
|
||||
dict.Set("liveSize", static_cast<double>(stat.decodedSize));
|
||||
return dict.GetHandle();
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#define ATOM_COMMON_NATIVE_MATE_CONVERTERS_BLINK_CONVERTER_H_
|
||||
|
||||
#include "native_mate/converter.h"
|
||||
#include "third_party/WebKit/public/web/WebCache.h"
|
||||
#include "third_party/WebKit/public/platform/WebCache.h"
|
||||
#include "third_party/WebKit/public/web/WebContextMenuData.h"
|
||||
|
||||
namespace blink {
|
||||
|
|
|
@ -167,42 +167,42 @@ base::Value* V8ValueConverter::FromV8Value(
|
|||
v8::Local<v8::Value> V8ValueConverter::ToV8ValueImpl(
|
||||
v8::Isolate* isolate, const base::Value* value) const {
|
||||
switch (value->GetType()) {
|
||||
case base::Value::TYPE_NULL:
|
||||
case base::Value::Type::NONE:
|
||||
return v8::Null(isolate);
|
||||
|
||||
case base::Value::TYPE_BOOLEAN: {
|
||||
case base::Value::Type::BOOLEAN: {
|
||||
bool val = false;
|
||||
value->GetAsBoolean(&val);
|
||||
return v8::Boolean::New(isolate, val);
|
||||
}
|
||||
|
||||
case base::Value::TYPE_INTEGER: {
|
||||
case base::Value::Type::INTEGER: {
|
||||
int val = 0;
|
||||
value->GetAsInteger(&val);
|
||||
return v8::Integer::New(isolate, val);
|
||||
}
|
||||
|
||||
case base::Value::TYPE_DOUBLE: {
|
||||
case base::Value::Type::DOUBLE: {
|
||||
double val = 0.0;
|
||||
value->GetAsDouble(&val);
|
||||
return v8::Number::New(isolate, val);
|
||||
}
|
||||
|
||||
case base::Value::TYPE_STRING: {
|
||||
case base::Value::Type::STRING: {
|
||||
std::string val;
|
||||
value->GetAsString(&val);
|
||||
return v8::String::NewFromUtf8(
|
||||
isolate, val.c_str(), v8::String::kNormalString, val.length());
|
||||
}
|
||||
|
||||
case base::Value::TYPE_LIST:
|
||||
case base::Value::Type::LIST:
|
||||
return ToV8Array(isolate, static_cast<const base::ListValue*>(value));
|
||||
|
||||
case base::Value::TYPE_DICTIONARY:
|
||||
case base::Value::Type::DICTIONARY:
|
||||
return ToV8Object(isolate,
|
||||
static_cast<const base::DictionaryValue*>(value));
|
||||
|
||||
case base::Value::TYPE_BINARY:
|
||||
case base::Value::Type::BINARY:
|
||||
return ToArrayBuffer(isolate,
|
||||
static_cast<const base::BinaryValue*>(value));
|
||||
|
||||
|
@ -314,13 +314,13 @@ base::Value* V8ValueConverter::FromV8ValueImpl(
|
|||
return base::Value::CreateNullValue().release();
|
||||
|
||||
if (val->IsBoolean())
|
||||
return new base::FundamentalValue(val->ToBoolean()->Value());
|
||||
return new base::Value(val->ToBoolean()->Value());
|
||||
|
||||
if (val->IsInt32())
|
||||
return new base::FundamentalValue(val->ToInt32()->Value());
|
||||
return new base::Value(val->ToInt32()->Value());
|
||||
|
||||
if (val->IsNumber())
|
||||
return new base::FundamentalValue(val->ToNumber()->Value());
|
||||
return new base::Value(val->ToNumber()->Value());
|
||||
|
||||
if (val->IsString()) {
|
||||
v8::String::Utf8Value utf8(val->ToString());
|
||||
|
@ -490,7 +490,7 @@ base::Value* V8ValueConverter::FromV8Object(
|
|||
// there *is* a "windowId" property, but since it should be an int, code
|
||||
// on the browser which doesn't additionally check for null will fail.
|
||||
// We can avoid all bugs related to this by stripping null.
|
||||
if (strip_null_from_objects_ && child->IsType(base::Value::TYPE_NULL))
|
||||
if (strip_null_from_objects_ && child->IsType(base::Value::Type::NONE))
|
||||
continue;
|
||||
|
||||
result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()),
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
#include "v8/include/v8.h"
|
||||
|
||||
namespace base {
|
||||
class BinaryValue;
|
||||
class DictionaryValue;
|
||||
class ListValue;
|
||||
class Value;
|
||||
using BinaryValue = Value;
|
||||
}
|
||||
|
||||
namespace atom {
|
||||
|
|
|
@ -15,7 +15,7 @@ bool Converter<base::DictionaryValue>::FromV8(v8::Isolate* isolate,
|
|||
std::unique_ptr<atom::V8ValueConverter> converter(new atom::V8ValueConverter);
|
||||
std::unique_ptr<base::Value> value(converter->FromV8Value(
|
||||
val, isolate->GetCurrentContext()));
|
||||
if (value && value->IsType(base::Value::TYPE_DICTIONARY)) {
|
||||
if (value && value->IsType(base::Value::Type::DICTIONARY)) {
|
||||
out->Swap(static_cast<base::DictionaryValue*>(value.get()));
|
||||
return true;
|
||||
} else {
|
||||
|
@ -36,7 +36,7 @@ bool Converter<base::ListValue>::FromV8(v8::Isolate* isolate,
|
|||
std::unique_ptr<atom::V8ValueConverter> converter(new atom::V8ValueConverter);
|
||||
std::unique_ptr<base::Value> value(converter->FromV8Value(
|
||||
val, isolate->GetCurrentContext()));
|
||||
if (value->IsType(base::Value::TYPE_LIST)) {
|
||||
if (value->IsType(base::Value::Type::LIST)) {
|
||||
out->Swap(static_cast<base::ListValue*>(value.get()));
|
||||
return true;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue