chore: remove native_mate (Part 9) (#20645)

* refactor: remove a few uses of native_mate/gfx_converter.h

* refactor: deprecate mate::EventEmitter

* refactor: add gin_helper::EventEmitter

* refactor: convert a few classes to use gin_helper::EventEmitter

* refactor: get rid of native_mate_converters/gfx_converter.h

* fix: follow native_mate on reporting errors

* fix: gin is weak at guessing parameter types

* fix: incorrect full class name

* fix: gin::Handle does not accept null
This commit is contained in:
Cheng Zhao 2019-10-21 16:05:40 +09:00 committed by GitHub
parent b155ebeeb3
commit eb0e55c514
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 532 additions and 326 deletions

View file

@ -9,20 +9,20 @@
#include <string>
#include <vector>
#include "native_mate/handle.h"
#include "gin/handle.h"
#include "shell/browser/api/trackable_object.h"
#include "shell/browser/ui/tray_icon.h"
#include "shell/browser/ui/tray_icon_observer.h"
#include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/event_emitter.h"
namespace gfx {
class Image;
}
namespace mate {
class Arguments;
namespace gin_helper {
class Dictionary;
} // namespace mate
}
namespace electron {
@ -33,17 +33,20 @@ namespace api {
class Menu;
class NativeImage;
class Tray : public mate::TrackableObject<Tray>, public TrayIconObserver {
class Tray : public mate::TrackableObject<
Tray,
gin_helper::EventEmitter<mate::Wrappable<Tray>>>,
public TrayIconObserver {
public:
static mate::WrappableBase* New(gin_helper::ErrorThrower thrower,
mate::Handle<NativeImage> image,
gin::Arguments* args);
gin::Handle<NativeImage> image,
gin_helper::Arguments* args);
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
protected:
Tray(mate::Handle<NativeImage> image, gin::Arguments* args);
Tray(gin::Handle<NativeImage> image, gin_helper::Arguments* args);
~Tray() override;
// TrayIconObserver:
@ -65,22 +68,24 @@ class Tray : public mate::TrackableObject<Tray>, public TrayIconObserver {
void OnMouseExited(const gfx::Point& location, int modifiers) override;
void OnMouseMoved(const gfx::Point& location, int modifiers) override;
void SetImage(v8::Isolate* isolate, mate::Handle<NativeImage> image);
void SetPressedImage(v8::Isolate* isolate, mate::Handle<NativeImage> image);
void SetImage(v8::Isolate* isolate, gin::Handle<NativeImage> image);
void SetPressedImage(v8::Isolate* isolate, gin::Handle<NativeImage> image);
void SetToolTip(const std::string& tool_tip);
void SetTitle(const std::string& title);
std::string GetTitle();
void SetIgnoreDoubleClickEvents(bool ignore);
bool GetIgnoreDoubleClickEvents();
void DisplayBalloon(mate::Arguments* args, const mate::Dictionary& options);
void DisplayBalloon(gin_helper::ErrorThrower thrower,
const gin_helper::Dictionary& options);
void RemoveBalloon();
void Focus();
void PopUpContextMenu(mate::Arguments* args);
void SetContextMenu(v8::Isolate* isolate, mate::Handle<Menu> menu);
void PopUpContextMenu(gin_helper::Arguments* args);
void SetContextMenu(gin_helper::ErrorThrower thrower,
v8::Local<v8::Value> arg);
gfx::Rect GetBounds();
private:
v8::Global<v8::Object> menu_;
v8::Global<v8::Value> menu_;
std::unique_ptr<TrayIcon> tray_icon_;
DISALLOW_COPY_AND_ASSIGN(Tray);