Try my own class
This commit is contained in:
parent
8e4ed664d9
commit
d118fed5c2
7 changed files with 141 additions and 242 deletions
|
@ -17,7 +17,7 @@
|
|||
#include "base/files/file_util.h"
|
||||
#include "base/strings/pattern.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "chrome/browser/ui/webui/fileicon_source.h"
|
||||
#include "atom/common/fileicon_fetcher.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
#include "net/base/data_url.h"
|
||||
|
@ -306,7 +306,16 @@ gfx::Size NativeImage::GetSize() {
|
|||
void NativeImage::CreateFromFileIcon(v8::Isolate* isolate,
|
||||
const base::FilePath& path,
|
||||
const IconLoadedCallback& callback) {
|
||||
callback.Run(CreateEmpty(isolate));
|
||||
IconLoader::IconSize icon_size = IconLoader::IconSize::NORMAL;
|
||||
float scale_factor = 1.0f;
|
||||
auto onready = base::Bind(&NativeImage::OnIconLoaded, isolate, callback);
|
||||
FileIconFetcher::FetchFileIcon(path, scale_factor, icon_size, onready);
|
||||
}
|
||||
|
||||
void NativeImage::OnIconLoaded(v8::Isolate* isolate,
|
||||
const IconLoadedCallback& callback,
|
||||
gfx::Image& image) {
|
||||
callback.Run(Create(isolate, image));
|
||||
}
|
||||
|
||||
float NativeImage::GetAspectRatio() {
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace atom {
|
|||
namespace api {
|
||||
|
||||
class NativeImage : public mate::Wrappable<NativeImage> {
|
||||
using IconLoadedCallback = base::Callback<void(mate::Handle<NativeImage>)>;
|
||||
using IconLoadedCallback = base::Callback<void(mate::Handle<NativeImage>)>;
|
||||
public:
|
||||
static mate::Handle<NativeImage> CreateEmpty(v8::Isolate* isolate);
|
||||
static mate::Handle<NativeImage> Create(
|
||||
|
@ -90,6 +90,9 @@ using IconLoadedCallback = base::Callback<void(mate::Handle<NativeImage>)>;
|
|||
gfx::Size GetSize();
|
||||
float GetAspectRatio();
|
||||
|
||||
void OnIconLoaded(v8::Isolate* isolate,
|
||||
const IconLoadedCallback& callback,
|
||||
gfx::Image& image);
|
||||
// Mark the image as template image.
|
||||
void SetTemplateImage(bool setAsTemplate);
|
||||
// Determine if the image is a template image.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue