From be5b90717961ba0bbd7dac0762b791a2b7c1b2af Mon Sep 17 00:00:00 2001 From: Yury Solovyov Date: Sat, 29 Oct 2016 14:02:33 +0300 Subject: [PATCH] WIP --- atom/common/api/atom_api_native_image.cc | 8 ++++++++ atom/common/api/atom_api_native_image.h | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/atom/common/api/atom_api_native_image.cc b/atom/common/api/atom_api_native_image.cc index 0c174941dbf5..30d4b124a10d 100644 --- a/atom/common/api/atom_api_native_image.cc +++ b/atom/common/api/atom_api_native_image.cc @@ -301,6 +301,12 @@ gfx::Size NativeImage::GetSize() { return image_.Size(); } +void NativeImage::CreateFromFileIcon(v8::Isolate* isolate, + const base::FilePath& path, + const IconLoadedCallback& callback) { + callback.Run(CreateEmpty(isolate)); +} + float NativeImage::GetAspectRatio() { gfx::Size size = GetSize(); if (size.IsEmpty()) @@ -514,6 +520,8 @@ void Initialize(v8::Local exports, v8::Local unused, mate::Dictionary dict(context->GetIsolate(), exports); dict.SetMethod("createEmpty", &atom::api::NativeImage::CreateEmpty); dict.SetMethod("createFromPath", &atom::api::NativeImage::CreateFromPath); + dict.SetMethod("createFromFileIcon", + &atom::api::NativeImage::CreateFromFileIcon); dict.SetMethod("createFromBuffer", &atom::api::NativeImage::CreateFromBuffer); dict.SetMethod("createFromDataURL", &atom::api::NativeImage::CreateFromDataURL); diff --git a/atom/common/api/atom_api_native_image.h b/atom/common/api/atom_api_native_image.h index ee1b5f5d4b81..251776b893da 100644 --- a/atom/common/api/atom_api_native_image.h +++ b/atom/common/api/atom_api_native_image.h @@ -38,6 +38,7 @@ namespace atom { namespace api { class NativeImage : public mate::Wrappable { +using IconLoadedCallback = base::Callback)>; public: static mate::Handle CreateEmpty(v8::Isolate* isolate); static mate::Handle Create( @@ -52,6 +53,9 @@ class NativeImage : public mate::Wrappable { mate::Arguments* args, v8::Local buffer); static mate::Handle CreateFromDataURL( v8::Isolate* isolate, const GURL& url); + static void CreateFromFileIcon(v8::Isolate* isolate, + const base::FilePath& path, + const IconLoadedCallback& callback); static void BuildPrototype(v8::Isolate* isolate, v8::Local prototype);