Merge pull request #6788 from electron/felix-progress-enum

Use enum to declare ProgressState
This commit is contained in:
Cheng Zhao 2016-08-18 14:35:00 +09:00 committed by GitHub
commit 06d2dfe119
8 changed files with 36 additions and 13 deletions

View file

@ -12,6 +12,7 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/display/win/screen_win.h"
#include "ui/gfx/icon_util.h"
#include "atom/browser/native_window.h"
namespace atom {
@ -127,23 +128,23 @@ void TaskbarHost::RestoreThumbarButtons(HWND window) {
}
bool TaskbarHost::SetProgressBar(
HWND window, double value, const std::string& mode) {
HWND window, double value, const NativeWindow::ProgressState state) {
if (!InitializeTaskbar())
return false;
bool success;
if (value > 1.0 || mode == "indeterminate") {
if (value > 1.0 || state == NativeWindow::PROGRESS_INDETERMINATE) {
success = SUCCEEDED(taskbar_->SetProgressState(window, TBPF_INDETERMINATE));
} else if (value < 0 || mode == "none") {
} else if (value < 0 || state == NativeWindow::PROGRESS_NONE) {
success = SUCCEEDED(taskbar_->SetProgressState(window, TBPF_NOPROGRESS));
} else {
// Unless SetProgressState set a blocking state (TBPF_ERROR, TBPF_PAUSED)
// for the window, a call to SetProgressValue assumes the TBPF_NORMAL
// state even if it is not explicitly set.
// SetProgressValue overrides and clears the TBPF_INDETERMINATE state.
if (mode == "error") {
if (state == NativeWindow::PROGRESS_ERROR) {
success = SUCCEEDED(taskbar_->SetProgressState(window, TBPF_ERROR));
} else if (mode == "paused") {
} else if (state == NativeWindow::PROGRESS_PAUSED) {
success = SUCCEEDED(taskbar_->SetProgressState(window, TBPF_PAUSED));
} else {
success = SUCCEEDED(taskbar_->SetProgressState(window, TBPF_NORMAL));

View file

@ -15,6 +15,7 @@
#include "base/win/scoped_comptr.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/image/image.h"
#include "atom/browser/native_window.h"
namespace atom {
@ -37,7 +38,8 @@ class TaskbarHost {
void RestoreThumbarButtons(HWND window);
// Set the progress state in taskbar.
bool SetProgressBar(HWND window, double value, const std::string& mode);
bool SetProgressBar(
HWND window, double value, const NativeWindow::ProgressState state);
// Set the overlay icon in taskbar.
bool SetOverlayIcon(