From 67d9ae27c36eafbd616ce5cb6e0e60ec1095a558 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 20 May 2016 16:18:38 +0900 Subject: [PATCH] Remove the JavaScript wrapper for setContextMenu --- atom/browser/api/atom_api_tray.cc | 5 +++-- atom/browser/api/atom_api_tray.h | 3 ++- lib/browser/api/tray.js | 7 ------- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/atom/browser/api/atom_api_tray.cc b/atom/browser/api/atom_api_tray.cc index a6d508068a00..973bc83dcf8e 100644 --- a/atom/browser/api/atom_api_tray.cc +++ b/atom/browser/api/atom_api_tray.cc @@ -142,7 +142,8 @@ void Tray::PopUpContextMenu(mate::Arguments* args) { tray_icon_->PopUpContextMenu(pos, menu.IsEmpty() ? nullptr : menu->model()); } -void Tray::SetContextMenu(Menu* menu) { +void Tray::SetContextMenu(v8::Isolate* isolate, mate::Handle menu) { + menu_.Reset(isolate, menu.ToV8()); tray_icon_->SetContextMenu(menu->model()); } @@ -168,7 +169,7 @@ void Tray::BuildPrototype(v8::Isolate* isolate, .SetMethod("setHighlightMode", &Tray::SetHighlightMode) .SetMethod("displayBalloon", &Tray::DisplayBalloon) .SetMethod("popUpContextMenu", &Tray::PopUpContextMenu) - .SetMethod("_setContextMenu", &Tray::SetContextMenu); + .SetMethod("setContextMenu", &Tray::SetContextMenu); } } // namespace api diff --git a/atom/browser/api/atom_api_tray.h b/atom/browser/api/atom_api_tray.h index 2a794b5dcc73..312185aed408 100644 --- a/atom/browser/api/atom_api_tray.h +++ b/atom/browser/api/atom_api_tray.h @@ -64,13 +64,14 @@ class Tray : public mate::TrackableObject, void SetHighlightMode(bool highlight); void DisplayBalloon(mate::Arguments* args, const mate::Dictionary& options); void PopUpContextMenu(mate::Arguments* args); - void SetContextMenu(Menu* menu); + void SetContextMenu(v8::Isolate* isolate, mate::Handle menu); private: v8::Local ModifiersToObject(v8::Isolate* isolate, int modifiers); v8::Global image_; v8::Global pressed_image_; + v8::Global menu_; scoped_ptr tray_icon_; DISALLOW_COPY_AND_ASSIGN(Tray); diff --git a/lib/browser/api/tray.js b/lib/browser/api/tray.js index 2afdb3643146..bc0a9d26f655 100644 --- a/lib/browser/api/tray.js +++ b/lib/browser/api/tray.js @@ -3,11 +3,4 @@ const {Tray} = process.atomBinding('tray') Object.setPrototypeOf(Tray.prototype, EventEmitter.prototype) -Tray.prototype.setContextMenu = function (menu) { - this._setContextMenu(menu) - - // Keep a strong reference of menu. - this.menu = menu -} - module.exports = Tray