Skip to content

Commit 08891af

Browse files
committed
osx icon badge support - setBadgeLabel
1 parent 2574ce7 commit 08891af

File tree

8 files changed

+24
-0
lines changed

8 files changed

+24
-0
lines changed

src/api/window/window.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ void Window::Call(const std::string& method,
257257
bool flash;
258258
if (arguments.GetBoolean(0, &flash))
259259
shell_->window()->FlashFrame(flash);
260+
} else if (method == "SetBadgeLabel") {
261+
std::string label;
262+
if (arguments.GetString(0, &label))
263+
shell_->window()->SetBadgeLabel(label);
260264
} else if (method == "SetMenu") {
261265
int id;
262266
if (arguments.GetInteger(0, &id))

src/api/window_bindings.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,11 @@ Window.prototype.requestAttention = function(flash) {
405405
CallObjectMethod(this, 'RequestAttention', [ flash ]);
406406
}
407407

408+
Window.prototype.setBadgeLabel = function(label) {
409+
label = "" + label;
410+
CallObjectMethod(this, 'SetBadgeLabel', [ label ]);
411+
}
412+
408413
Window.prototype.setPosition = function(position) {
409414
if (position != 'center' && position != 'mouse')
410415
throw new String('Invalid postion');

src/browser/native_window.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class NativeWindow {
9292
virtual gfx::Point GetPosition() = 0;
9393
virtual void SetTitle(const std::string& title) = 0;
9494
virtual void FlashFrame(bool flash) = 0;
95+
virtual void SetBadgeLabel(const std::string& badge) = 0;
9596
virtual void SetKiosk(bool kiosk) = 0;
9697
virtual bool IsKiosk() = 0;
9798
virtual void SetMenu(nwapi::Menu* menu) = 0;

src/browser/native_window_gtk.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,10 @@ void NativeWindowGtk::FlashFrame(bool flash) {
295295
gtk_window_set_urgency_hint(window_, flash);
296296
}
297297

298+
void NativeWindowGtk::SetBadgeLabel(const std::string& badge) {
299+
// TODO
300+
}
301+
298302
void NativeWindowGtk::SetKiosk(bool kiosk) {
299303
SetFullscreen(kiosk);
300304
}

src/browser/native_window_mac.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class NativeWindowCocoa : public NativeWindow {
6464
virtual gfx::Point GetPosition() OVERRIDE;
6565
virtual void SetTitle(const std::string& title) OVERRIDE;
6666
virtual void FlashFrame(bool flash) OVERRIDE;
67+
virtual void SetBadgeLabel(const std::string& badge) OVERRIDE;
6768
virtual void SetKiosk(bool kiosk) OVERRIDE;
6869
virtual bool IsKiosk() OVERRIDE;
6970
virtual void SetMenu(nwapi::Menu* menu) OVERRIDE;

src/browser/native_window_mac.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,10 @@ - (NSRect)contentRectForFrameRect:(NSRect)frameRect {
643643
}
644644
}
645645

646+
void NativeWindowCocoa::SetBadgeLabel(const std::string& badge) {
647+
[[NSApp dockTile] setBadgeLabel:base::SysUTF8ToNSString(badge)];
648+
}
649+
646650
void NativeWindowCocoa::SetKiosk(bool kiosk) {
647651
if (kiosk) {
648652
NSApplicationPresentationOptions options =

src/browser/native_window_win.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,10 @@ void NativeWindowWin::FlashFrame(bool flash) {
457457
window_->FlashFrame(flash);
458458
}
459459

460+
void NativeWindowWin::SetBadgeLabel(const std::string& badge) {
461+
// TODO
462+
}
463+
460464
void NativeWindowWin::SetKiosk(bool kiosk) {
461465
SetFullscreen(kiosk);
462466
}

src/browser/native_window_win.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class NativeWindowWin : public NativeWindow,
7777
virtual void SetTitle(const std::string& title) OVERRIDE;
7878
virtual void FlashFrame(bool flash) OVERRIDE;
7979
virtual void SetKiosk(bool kiosk) OVERRIDE;
80+
virtual void SetBadgeLabel(const std::string& badge) OVERRIDE;
8081
virtual bool IsKiosk() OVERRIDE;
8182
virtual void SetMenu(nwapi::Menu* menu) OVERRIDE;
8283
virtual void SetToolbarButtonEnabled(TOOLBAR_BUTTON button,

0 commit comments

Comments
 (0)