feat: flesh out the api for //extensions (#21587)

This commit is contained in:
Jeremy Apthorp 2020-01-13 14:56:28 -08:00 committed by GitHub
parent 8bc0c92137
commit fa42b5980e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 159 additions and 13 deletions

View file

@ -0,0 +1,21 @@
// Copyright (c) 2019 Slack Technologies, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/common/gin_converters/extension_converter.h"
#include "extensions/common/extension.h"
#include "gin/dictionary.h"
namespace gin {
// static
v8::Local<v8::Value> Converter<const extensions::Extension*>::ToV8(
v8::Isolate* isolate,
const extensions::Extension* extension) {
auto dict = gin::Dictionary::CreateEmpty(isolate);
dict.Set("id", extension->id());
return gin::ConvertToV8(isolate, dict);
}
} // namespace gin

View file

@ -0,0 +1,26 @@
// Copyright (c) 2019 Slack Technologies, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef SHELL_COMMON_GIN_CONVERTERS_EXTENSION_CONVERTER_H_
#define SHELL_COMMON_GIN_CONVERTERS_EXTENSION_CONVERTER_H_
#include <string>
#include "gin/converter.h"
namespace extensions {
class Extension;
} // namespace extensions
namespace gin {
template <>
struct Converter<const extensions::Extension*> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const extensions::Extension* val);
};
} // namespace gin
#endif // SHELL_COMMON_GIN_CONVERTERS_EXTENSION_CONVERTER_H_