refactor: ginify DownloadItem (#22924)
This commit is contained in:
parent
6159066c26
commit
0a78ab4b98
9 changed files with 153 additions and 101 deletions
|
@ -170,7 +170,7 @@ bool Tray::IsDestroyed() {
|
|||
}
|
||||
|
||||
void Tray::SetImage(gin::Handle<NativeImage> image) {
|
||||
if (!CheckDestroyed())
|
||||
if (!CheckAlive())
|
||||
return;
|
||||
#if defined(OS_WIN)
|
||||
tray_icon_->SetImage(image->GetHICON(GetSystemMetrics(SM_CXSMICON)));
|
||||
|
@ -180,7 +180,7 @@ void Tray::SetImage(gin::Handle<NativeImage> image) {
|
|||
}
|
||||
|
||||
void Tray::SetPressedImage(gin::Handle<NativeImage> image) {
|
||||
if (!CheckDestroyed())
|
||||
if (!CheckAlive())
|
||||
return;
|
||||
#if defined(OS_WIN)
|
||||
tray_icon_->SetPressedImage(image->GetHICON(GetSystemMetrics(SM_CXSMICON)));
|
||||
|
@ -190,13 +190,13 @@ void Tray::SetPressedImage(gin::Handle<NativeImage> image) {
|
|||
}
|
||||
|
||||
void Tray::SetToolTip(const std::string& tool_tip) {
|
||||
if (!CheckDestroyed())
|
||||
if (!CheckAlive())
|
||||
return;
|
||||
tray_icon_->SetToolTip(tool_tip);
|
||||
}
|
||||
|
||||
void Tray::SetTitle(const std::string& title) {
|
||||
if (!CheckDestroyed())
|
||||
if (!CheckAlive())
|
||||
return;
|
||||
#if defined(OS_MACOSX)
|
||||
tray_icon_->SetTitle(title);
|
||||
|
@ -204,7 +204,7 @@ void Tray::SetTitle(const std::string& title) {
|
|||
}
|
||||
|
||||
std::string Tray::GetTitle() {
|
||||
if (!CheckDestroyed())
|
||||
if (!CheckAlive())
|
||||
return std::string();
|
||||
#if defined(OS_MACOSX)
|
||||
return tray_icon_->GetTitle();
|
||||
|
@ -214,7 +214,7 @@ std::string Tray::GetTitle() {
|
|||
}
|
||||
|
||||
void Tray::SetIgnoreDoubleClickEvents(bool ignore) {
|
||||
if (!CheckDestroyed())
|
||||
if (!CheckAlive())
|
||||
return;
|
||||
#if defined(OS_MACOSX)
|
||||
tray_icon_->SetIgnoreDoubleClickEvents(ignore);
|
||||
|
@ -222,7 +222,7 @@ void Tray::SetIgnoreDoubleClickEvents(bool ignore) {
|
|||
}
|
||||
|
||||
bool Tray::GetIgnoreDoubleClickEvents() {
|
||||
if (!CheckDestroyed())
|
||||
if (!CheckAlive())
|
||||
return false;
|
||||
#if defined(OS_MACOSX)
|
||||
return tray_icon_->GetIgnoreDoubleClickEvents();
|
||||
|
@ -233,7 +233,7 @@ bool Tray::GetIgnoreDoubleClickEvents() {
|
|||
|
||||
void Tray::DisplayBalloon(gin_helper::ErrorThrower thrower,
|
||||
const gin_helper::Dictionary& options) {
|
||||
if (!CheckDestroyed())
|
||||
if (!CheckAlive())
|
||||
return;
|
||||
TrayIcon::BalloonOptions balloon_options;
|
||||
|
||||
|
@ -263,19 +263,19 @@ void Tray::DisplayBalloon(gin_helper::ErrorThrower thrower,
|
|||
}
|
||||
|
||||
void Tray::RemoveBalloon() {
|
||||
if (!CheckDestroyed())
|
||||
if (!CheckAlive())
|
||||
return;
|
||||
tray_icon_->RemoveBalloon();
|
||||
}
|
||||
|
||||
void Tray::Focus() {
|
||||
if (!CheckDestroyed())
|
||||
if (!CheckAlive())
|
||||
return;
|
||||
tray_icon_->Focus();
|
||||
}
|
||||
|
||||
void Tray::PopUpContextMenu(gin::Arguments* args) {
|
||||
if (!CheckDestroyed())
|
||||
if (!CheckAlive())
|
||||
return;
|
||||
gin::Handle<Menu> menu;
|
||||
gfx::Point pos;
|
||||
|
@ -298,14 +298,14 @@ void Tray::PopUpContextMenu(gin::Arguments* args) {
|
|||
}
|
||||
|
||||
void Tray::CloseContextMenu() {
|
||||
if (!CheckDestroyed())
|
||||
if (!CheckAlive())
|
||||
return;
|
||||
tray_icon_->CloseContextMenu();
|
||||
}
|
||||
|
||||
void Tray::SetContextMenu(gin_helper::ErrorThrower thrower,
|
||||
v8::Local<v8::Value> arg) {
|
||||
if (!CheckDestroyed())
|
||||
if (!CheckAlive())
|
||||
return;
|
||||
gin::Handle<Menu> menu;
|
||||
if (arg->IsNull()) {
|
||||
|
@ -320,12 +320,12 @@ void Tray::SetContextMenu(gin_helper::ErrorThrower thrower,
|
|||
}
|
||||
|
||||
gfx::Rect Tray::GetBounds() {
|
||||
if (!CheckDestroyed())
|
||||
if (!CheckAlive())
|
||||
return gfx::Rect();
|
||||
return tray_icon_->GetBounds();
|
||||
}
|
||||
|
||||
bool Tray::CheckDestroyed() {
|
||||
bool Tray::CheckAlive() {
|
||||
if (!tray_icon_) {
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
v8::Locker locker(isolate);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue