diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 759249e5aa4e..868ca5da1929 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -621,24 +621,7 @@ gfx::NativeWindow NativeWindowViews::GetNativeWindow() { void NativeWindowViews::SetProgressBar(double progress) { #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()); - if (progress > 1.0) { - taskbar->SetProgressState(frame, TBPF_INDETERMINATE); - } else if (progress < 0) { - taskbar->SetProgressState(frame, TBPF_NOPROGRESS); - } else if (progress >= 0) { - taskbar->SetProgressValue(frame, - static_cast(progress * 100), - 100); - } + taskbar_host_.SetProgressBar(GetAcceleratedWidget(), progress); #elif defined(USE_X11) if (unity::IsRunning()) { unity::SetProgressFraction(progress); diff --git a/atom/browser/ui/win/taskbar_host.cc b/atom/browser/ui/win/taskbar_host.cc index a6ab44d0723d..e3ee3fcd47c6 100644 --- a/atom/browser/ui/win/taskbar_host.cc +++ b/atom/browser/ui/win/taskbar_host.cc @@ -123,6 +123,25 @@ bool TaskbarHost::SetThumbarButtons( return SUCCEEDED(r); } +bool TaskbarHost::SetProgressBar(HWND window, double value) { + base::win::ScopedComPtr taskbar; + if (FAILED(taskbar.CreateInstance(CLSID_TaskbarList, + nullptr, + CLSCTX_INPROC_SERVER)) || + FAILED(taskbar->HrInit())) { + return false; + } + + HRESULT r; + if (value > 1.0) + r = taskbar->SetProgressState(window, TBPF_INDETERMINATE); + else if (value < 0) + r = taskbar->SetProgressState(window, TBPF_NOPROGRESS); + else + r= taskbar->SetProgressValue(window, static_cast(value * 100), 100); + return SUCCEEDED(r); +} + 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 f3172902af11..22ea4cbb31a2 100644 --- a/atom/browser/ui/win/taskbar_host.h +++ b/atom/browser/ui/win/taskbar_host.h @@ -28,10 +28,13 @@ class TaskbarHost { TaskbarHost(); virtual ~TaskbarHost(); - // Add or update the buttons in thumbar + // Add or update the buttons in thumbar. bool SetThumbarButtons( HWND window, const std::vector& buttons); + // Sets the progress state in taskbar. + bool SetProgressBar(HWND window, double value); + // Called by the window that there is a button in thumbar clicked. bool HandleThumbarButtonEvent(int button_id);