#include "atom/browser/native_window_views.h"
-#if defined(OS_WIN)
-#include <shobjidl.h>
-#endif
-
#include <string>
#include <vector>
#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 {
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<ITaskbarList3> 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
}
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];
bool SetThumbarButtons(
HWND window, const std::vector<ThumbarButton>& 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);