Move SetOverlayIcon to TaskbarHost

This commit is contained in:
Cheng Zhao 2015-08-06 13:07:00 +08:00
parent 8da7803f3e
commit 6e75af5c0f
3 changed files with 17 additions and 25 deletions

View file

@ -4,10 +4,6 @@
#include "atom/browser/native_window_views.h"
#if defined(OS_WIN)
#include <shobjidl.h>
#endif
#include <string>
#include <vector>
@ -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<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
}

View file

@ -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];

View file

@ -33,9 +33,13 @@ class TaskbarHost {
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);