mirror of
https://github.com/electron/electron.git
synced 2026-01-13 17:38:06 -05:00
* refactor: make api::Clipboard::GetClipboardBuffer() private * refactor: move GetClipboadBuffer() into anonymous namespace * refactor: use gin::Arguments in StopRecording() * refactor: use gin::Arguments in ImageView::New() * refactor: use gin::Arguments in AppendSwitch() * refactor: use gin::Arguments WebContentsView::New() * refactor: make gin::Arguments arg const in WrappableBase::InitWithArgs() This makes explicit that we are using it for wrapper + isolate, not the args values * refactor: remove gin_helper::Arguments arg from ExposeAPI() refactor: remove gin_helper::Arguments arg from ExposeAPIInWorld() * refactor: remove gin_helper::Arguments arg from ElectronBindings::GetSystemMemoryInfo() * refactor: remove gin_helper::Arguments arg from preload_utils::GetBinding() * refactor: use gin::Arguments in OpenExternal() * refactor: use gin::Arguments in ExecuteInWorld() * refactor: use gin::Arguments in ExecuteJavaScript() * refactor: use gin::Arguments in InvokeNew() * refactor: use gin::Arguments in ExecuteJavaScriptInIsolatedWorld() * refactor: remove unused GetNextArgument() marshaller for gin_helper::Arguments * refactor: remove unused #include gin_helper/arguments.h * chore: remove unused gin_helper::Arguments * fixup! refactor: use gin::Arguments in ExecuteJavaScriptInIsolatedWorld() Xref: https://github.com/electron/electron/pull/48447
62 lines
1.9 KiB
C++
62 lines
1.9 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 "shell/browser/api/views/electron_api_image_view.h"
|
|
|
|
#include "shell/browser/javascript_environment.h"
|
|
#include "shell/common/gin_converters/image_converter.h"
|
|
#include "shell/common/gin_helper/constructor.h"
|
|
#include "shell/common/gin_helper/dictionary.h"
|
|
#include "shell/common/gin_helper/object_template_builder.h"
|
|
#include "shell/common/node_includes.h"
|
|
#include "ui/gfx/image/image.h"
|
|
|
|
namespace electron::api {
|
|
|
|
ImageView::ImageView() : View(new views::ImageView()) {
|
|
view()->set_owned_by_client(views::View::OwnedByClientPassKey{});
|
|
}
|
|
|
|
ImageView::~ImageView() = default;
|
|
|
|
void ImageView::SetImage(const gfx::Image& image) {
|
|
image_view()->SetImage(ui::ImageModel::FromImage(image));
|
|
}
|
|
|
|
// static
|
|
gin_helper::WrappableBase* ImageView::New(gin::Arguments* const args) {
|
|
// Constructor call.
|
|
auto* view = new ImageView();
|
|
view->InitWithArgs(args);
|
|
return view;
|
|
}
|
|
|
|
// static
|
|
void ImageView::BuildPrototype(v8::Isolate* isolate,
|
|
v8::Local<v8::FunctionTemplate> prototype) {
|
|
prototype->SetClassName(gin::StringToV8(isolate, "ImageView"));
|
|
gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
|
.SetMethod("setImage", &ImageView::SetImage);
|
|
}
|
|
|
|
} // namespace electron::api
|
|
|
|
namespace {
|
|
|
|
using electron::api::ImageView;
|
|
|
|
void Initialize(v8::Local<v8::Object> exports,
|
|
v8::Local<v8::Value> unused,
|
|
v8::Local<v8::Context> context,
|
|
void* priv) {
|
|
v8::Isolate* const isolate = electron::JavascriptEnvironment::GetIsolate();
|
|
gin_helper::Dictionary dict{isolate, exports};
|
|
dict.Set("ImageView", gin_helper::CreateConstructor<ImageView>(
|
|
isolate, base::BindRepeating(&ImageView::New)));
|
|
}
|
|
|
|
} // namespace
|
|
|
|
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_image_view, Initialize)
|