]> khamidou — GitHub mirrors - electron.git/commitdiff
Move SetOverlayIcon to TaskbarHost
authorCheng Zhao <zcbenz@gmail.com>
Thu, 6 Aug 2015 05:07:00 +0000 (13:07 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 6 Aug 2015 05:07:00 +0000 (13:07 +0800)
atom/browser/native_window_views.cc
atom/browser/ui/win/taskbar_host.cc
atom/browser/ui/win/taskbar_host.h

index 868ca5da19291e081dd6c24eeb5c9b5795a69224..45697c96683c402ddbdfbe432e9e68e9563438d2 100644 (file)
@@ -4,10 +4,6 @@
 
 #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 {
@@ -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
 }
 
index 1ffc567f7b000665c341389e7dd7fe965617b8d5..edbc78ce5c83310e6073e13b8223e5beb162050b 100644 (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];
index 755f867eb13283950ad56dfea48528161a1eb855..185b88a6b5b6f0570ce55c82d8db6b9c2a608073 100644 (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);