Skip to content

Commit 1213d73

Browse files
committed
[WIN] badge feature, fix the indentation, add my name to Authors
1 parent caced49 commit 1213d73

File tree

2 files changed

+37
-38
lines changed

2 files changed

+37
-38
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ Fabrice Weinberg <fabrice@weinberg.me>
2525
Lv Kaiyang <kevinlui598@gmail.com>
2626
Lukas Benes <bender@false.cz>
2727
Lithare Emileit <litharemilit@gmail.com>
28+
Jefry Tedjokusumo <jtg_gg@yahoo.com.sg>

src/browser/native_window_win.cc

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -475,52 +475,50 @@ void NativeWindowWin::FlashFrame(bool flash) {
475475
}
476476

477477
HICON createBadgeIcon(const HWND hWnd, const TCHAR *value, const int sizeX, const int sizeY) {
478-
// canvas for the overlay icon
479-
gfx::Canvas canvas(gfx::Size(sizeX, sizeY), 1, false);
478+
// canvas for the overlay icon
479+
gfx::Canvas canvas(gfx::Size(sizeX, sizeY), 1, false);
480480

481-
// drawing red circle
482-
SkPaint paint;
483-
paint.setColor(SK_ColorRED);
484-
canvas.DrawCircle(gfx::Point(sizeX/2, sizeY/2), sizeX/2, paint);
481+
// drawing red circle
482+
SkPaint paint;
483+
paint.setColor(SK_ColorRED);
484+
canvas.DrawCircle(gfx::Point(sizeX / 2, sizeY / 2), sizeX / 2, paint);
485485

486-
// drawing the text
487-
gfx::PlatformFont *platform_font = gfx::PlatformFont::CreateDefault();
488-
const int fontSize = sizeY*0.65f;
489-
gfx::Font font(platform_font->GetFontName(), fontSize);
490-
platform_font->Release();
491-
platform_font = NULL;
492-
const int yMargin = (sizeY - fontSize) / 2;
493-
canvas.DrawStringRectWithFlags(value, gfx::FontList(font), SK_ColorWHITE, gfx::Rect(sizeX, fontSize+yMargin+1), gfx::Canvas::TEXT_ALIGN_CENTER);
486+
// drawing the text
487+
gfx::PlatformFont *platform_font = gfx::PlatformFont::CreateDefault();
488+
const int fontSize = sizeY*0.65f;
489+
gfx::Font font(platform_font->GetFontName(), fontSize);
490+
platform_font->Release();
491+
platform_font = NULL;
492+
const int yMargin = (sizeY - fontSize) / 2;
493+
canvas.DrawStringRectWithFlags(value, gfx::FontList(font), SK_ColorWHITE, gfx::Rect(sizeX, fontSize + yMargin + 1), gfx::Canvas::TEXT_ALIGN_CENTER);
494494

495-
// return the canvas as windows native icon handle
496-
return IconUtil::CreateHICONFromSkBitmap(canvas.ExtractImageRep().sk_bitmap());
495+
// return the canvas as windows native icon handle
496+
return IconUtil::CreateHICONFromSkBitmap(canvas.ExtractImageRep().sk_bitmap());
497497
}
498498

499499
void NativeWindowWin::SetBadgeLabel(const std::string& badge) {
500-
base::win::ScopedComPtr<ITaskbarList3> taskbar;
501-
HRESULT result = taskbar.CreateInstance(CLSID_TaskbarList, NULL,
502-
CLSCTX_INPROC_SERVER);
503-
504-
if (FAILED(result)) {
505-
VLOG(1) << "Failed creating a TaskbarList3 object: " << result;
506-
return;
507-
}
508-
509-
result = taskbar->HrInit();
510-
if (FAILED(result)) {
511-
LOG(ERROR) << "Failed initializing an ITaskbarList3 interface.";
512-
return;
513-
}
514-
515-
HICON icon = NULL;
516-
HWND hWnd = window_->GetNativeWindow();
517-
if (badge.size())
518-
icon = createBadgeIcon(hWnd, UTF8ToUTF16(badge).c_str(), 32, 32);
519-
520-
taskbar->SetOverlayIcon(hWnd, icon, _T("Status"));
521-
DestroyIcon(icon);
500+
base::win::ScopedComPtr<ITaskbarList3> taskbar;
501+
HRESULT result = taskbar.CreateInstance(CLSID_TaskbarList, NULL,
502+
CLSCTX_INPROC_SERVER);
503+
504+
if (FAILED(result)) {
505+
VLOG(1) << "Failed creating a TaskbarList3 object: " << result;
506+
return;
507+
}
508+
509+
result = taskbar->HrInit();
510+
if (FAILED(result)) {
511+
LOG(ERROR) << "Failed initializing an ITaskbarList3 interface.";
512+
return;
513+
}
522514

515+
HICON icon = NULL;
516+
HWND hWnd = window_->GetNativeWindow();
517+
if (badge.size())
518+
icon = createBadgeIcon(hWnd, UTF8ToUTF16(badge).c_str(), 32, 32);
523519

520+
taskbar->SetOverlayIcon(hWnd, icon, _T("Status"));
521+
DestroyIcon(icon);
524522
}
525523

526524
void NativeWindowWin::SetKiosk(bool kiosk) {

0 commit comments

Comments
 (0)