diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 868ca5da1929..45697c96683c 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -4,10 +4,6 @@ #include "atom/browser/native_window_views.h" -#if defined(OS_WIN) -#include -#endif - #include #include @@ -46,13 +42,9 @@ #elif defined(OS_WIN) #include "atom/browser/ui/views/win_frame_view.h" #include "atom/browser/ui/win/atom_desktop_window_tree_host_win.h" -#include "base/win/scoped_comptr.h" -#include "base/win/windows_version.h" #include "ui/base/win/shell.h" -#include "ui/gfx/icon_util.h" #include "ui/gfx/win/dpi.h" #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" -#include "ui/views/win/hwnd_util.h" #endif namespace atom { @@ -632,22 +624,7 @@ void NativeWindowViews::SetProgressBar(double progress) { void NativeWindowViews::SetOverlayIcon(const gfx::Image& overlay, const std::string& description) { #if defined(OS_WIN) - if (base::win::GetVersion() < base::win::VERSION_WIN7) - return; - - base::win::ScopedComPtr taskbar; - if (FAILED(taskbar.CreateInstance(CLSID_TaskbarList, NULL, - CLSCTX_INPROC_SERVER) || - FAILED(taskbar->HrInit()))) { - return; - } - - HWND frame = views::HWNDForNativeWindow(GetNativeWindow()); - - std::wstring wstr = std::wstring(description.begin(), description.end()); - taskbar->SetOverlayIcon(frame, - IconUtil::CreateHICONFromSkBitmap(overlay.AsBitmap()), - wstr.c_str()); + taskbar_host_.SetOverlayIcon(GetAcceleratedWidget(), overlay, description); #endif } diff --git a/atom/browser/ui/win/taskbar_host.cc b/atom/browser/ui/win/taskbar_host.cc index 1ffc567f7b00..edbc78ce5c83 100644 --- a/atom/browser/ui/win/taskbar_host.cc +++ b/atom/browser/ui/win/taskbar_host.cc @@ -130,6 +130,17 @@ bool TaskbarHost::SetProgressBar(HWND window, double value) { return SUCCEEDED(r); } +bool TaskbarHost::SetOverlayIcon( + HWND window, const gfx::Image& overlay, const std::string& text) { + if (!InitailizeTaskbar()) + return false; + + base::win::ScopedHICON icon( + IconUtil::CreateHICONFromSkBitmap(overlay.AsBitmap())); + return SUCCEEDED( + taskbar_->SetOverlayIcon(window, icon, base::UTF8ToUTF16(text).c_str())); +} + bool TaskbarHost::HandleThumbarButtonEvent(int button_id) { if (ContainsKey(callback_map_, button_id)) { auto callback = callback_map_[button_id]; diff --git a/atom/browser/ui/win/taskbar_host.h b/atom/browser/ui/win/taskbar_host.h index 755f867eb132..185b88a6b5b6 100644 --- a/atom/browser/ui/win/taskbar_host.h +++ b/atom/browser/ui/win/taskbar_host.h @@ -33,9 +33,13 @@ class TaskbarHost { bool SetThumbarButtons( HWND window, const std::vector& buttons); - // Sets the progress state in taskbar. + // Set the progress state in taskbar. bool SetProgressBar(HWND window, double value); + // Set the overlay icon in taskbar. + bool SetOverlayIcon( + HWND window, const gfx::Image& overlay, const std::string& text); + // Called by the window that there is a button in thumbar clicked. bool HandleThumbarButtonEvent(int button_id);