This commit is contained in:
Yury Solovyov 2016-10-29 14:02:33 +03:00 committed by Kevin Sawicki
parent c3c5470a7c
commit be5b907179
2 changed files with 12 additions and 0 deletions

View file

@ -301,6 +301,12 @@ gfx::Size NativeImage::GetSize() {
return image_.Size(); return image_.Size();
} }
void NativeImage::CreateFromFileIcon(v8::Isolate* isolate,
const base::FilePath& path,
const IconLoadedCallback& callback) {
callback.Run(CreateEmpty(isolate));
}
float NativeImage::GetAspectRatio() { float NativeImage::GetAspectRatio() {
gfx::Size size = GetSize(); gfx::Size size = GetSize();
if (size.IsEmpty()) if (size.IsEmpty())
@ -514,6 +520,8 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
mate::Dictionary dict(context->GetIsolate(), exports); mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("createEmpty", &atom::api::NativeImage::CreateEmpty); dict.SetMethod("createEmpty", &atom::api::NativeImage::CreateEmpty);
dict.SetMethod("createFromPath", &atom::api::NativeImage::CreateFromPath); dict.SetMethod("createFromPath", &atom::api::NativeImage::CreateFromPath);
dict.SetMethod("createFromFileIcon",
&atom::api::NativeImage::CreateFromFileIcon);
dict.SetMethod("createFromBuffer", &atom::api::NativeImage::CreateFromBuffer); dict.SetMethod("createFromBuffer", &atom::api::NativeImage::CreateFromBuffer);
dict.SetMethod("createFromDataURL", dict.SetMethod("createFromDataURL",
&atom::api::NativeImage::CreateFromDataURL); &atom::api::NativeImage::CreateFromDataURL);

View file

@ -38,6 +38,7 @@ namespace atom {
namespace api { namespace api {
class NativeImage : public mate::Wrappable<NativeImage> { class NativeImage : public mate::Wrappable<NativeImage> {
using IconLoadedCallback = base::Callback<void(mate::Handle<NativeImage>)>;
public: public:
static mate::Handle<NativeImage> CreateEmpty(v8::Isolate* isolate); static mate::Handle<NativeImage> CreateEmpty(v8::Isolate* isolate);
static mate::Handle<NativeImage> Create( static mate::Handle<NativeImage> Create(
@ -52,6 +53,9 @@ class NativeImage : public mate::Wrappable<NativeImage> {
mate::Arguments* args, v8::Local<v8::Value> buffer); mate::Arguments* args, v8::Local<v8::Value> buffer);
static mate::Handle<NativeImage> CreateFromDataURL( static mate::Handle<NativeImage> CreateFromDataURL(
v8::Isolate* isolate, const GURL& url); 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, static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype); v8::Local<v8::FunctionTemplate> prototype);