Move SetProgressBar to TaskbarHost
This commit is contained in:
parent
958658513c
commit
2d6f8350cb
3 changed files with 24 additions and 19 deletions
|
@ -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<ITaskbarList3> 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<int>(progress * 100),
|
||||
100);
|
||||
}
|
||||
taskbar_host_.SetProgressBar(GetAcceleratedWidget(), progress);
|
||||
#elif defined(USE_X11)
|
||||
if (unity::IsRunning()) {
|
||||
unity::SetProgressFraction(progress);
|
||||
|
|
|
@ -123,6 +123,25 @@ bool TaskbarHost::SetThumbarButtons(
|
|||
return SUCCEEDED(r);
|
||||
}
|
||||
|
||||
bool TaskbarHost::SetProgressBar(HWND window, double value) {
|
||||
base::win::ScopedComPtr<ITaskbarList3> 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<int>(value * 100), 100);
|
||||
return SUCCEEDED(r);
|
||||
}
|
||||
|
||||
bool TaskbarHost::HandleThumbarButtonEvent(int button_id) {
|
||||
if (ContainsKey(callback_map_, button_id)) {
|
||||
auto callback = callback_map_[button_id];
|
||||
|
|
|
@ -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<ThumbarButton>& 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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue