![electron-roller[bot]](/assets/img/avatar_default.png)
* chore: bump chromium in DEPS to 137.0.7144.0
* chore: bump chromium in DEPS to 137.0.7145.0
* chore: bump chromium in DEPS to 137.0.7147.0
* chore: update patches
* Remove deprecated GetVar(std::string_view, std::string*) overload
Refs 6468873
* fixup! Remove deprecated GetVar(std::string_view, std::string*) overload
* fixup! Remove deprecated GetVar(std::string_view, std::string*) overload
* chore: bump chromium in DEPS to 137.0.7149.0
---------
Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
40 lines
1.2 KiB
C++
40 lines
1.2 KiB
C++
// Copyright (c) 2020 GitHub, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "base/environment.h"
|
|
#include "shell/common/gin_helper/dictionary.h"
|
|
#include "shell/common/node_includes.h"
|
|
|
|
namespace {
|
|
|
|
v8::Local<v8::Value> GetVar(v8::Isolate* isolate, const std::string& name) {
|
|
if (std::optional<std::string> value =
|
|
base::Environment::Create()->GetVar(name)) {
|
|
return gin::StringToV8(isolate, *value);
|
|
} else {
|
|
return v8::Null(isolate);
|
|
}
|
|
}
|
|
|
|
bool HasVar(const std::string& name) {
|
|
return base::Environment::Create()->HasVar(name);
|
|
}
|
|
|
|
bool SetVar(const std::string& name, const std::string& value) {
|
|
return base::Environment::Create()->SetVar(name, value);
|
|
}
|
|
|
|
void Initialize(v8::Local<v8::Object> exports,
|
|
v8::Local<v8::Value> unused,
|
|
v8::Local<v8::Context> context,
|
|
void* priv) {
|
|
gin_helper::Dictionary dict(context->GetIsolate(), exports);
|
|
dict.SetMethod("getVar", &GetVar);
|
|
dict.SetMethod("hasVar", &HasVar);
|
|
dict.SetMethod("setVar", &SetVar);
|
|
}
|
|
|
|
} // namespace
|
|
|
|
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_common_environment, Initialize)
|