feat: flesh out the api for //extensions (#21587)
This commit is contained in:
parent
8bc0c92137
commit
fa42b5980e
10 changed files with 159 additions and 13 deletions
21
shell/common/gin_converters/extension_converter.cc
Normal file
21
shell/common/gin_converters/extension_converter.cc
Normal 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
|
26
shell/common/gin_converters/extension_converter.h
Normal file
26
shell/common/gin_converters/extension_converter.h
Normal 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_
|
Loading…
Add table
Add a link
Reference in a new issue