win: Implement SetProgressBar API.
This commit is contained in:
parent
0f714c81cd
commit
b5e82dac6f
5 changed files with 31 additions and 0 deletions
|
@ -366,6 +366,10 @@ void Window::Print(mate::Arguments* args) {
|
||||||
window_->Print(settings.silent, settings.print_backgournd);
|
window_->Print(settings.silent, settings.print_backgournd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::SetProgressBar(double progress) {
|
||||||
|
window_->SetProgressBar(progress);
|
||||||
|
}
|
||||||
|
|
||||||
mate::Handle<WebContents> Window::GetWebContents(v8::Isolate* isolate) const {
|
mate::Handle<WebContents> Window::GetWebContents(v8::Isolate* isolate) const {
|
||||||
return WebContents::Create(isolate, window_->GetWebContents());
|
return WebContents::Create(isolate, window_->GetWebContents());
|
||||||
}
|
}
|
||||||
|
@ -428,6 +432,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
||||||
.SetMethod("isWebViewFocused", &Window::IsWebViewFocused)
|
.SetMethod("isWebViewFocused", &Window::IsWebViewFocused)
|
||||||
.SetMethod("capturePage", &Window::CapturePage)
|
.SetMethod("capturePage", &Window::CapturePage)
|
||||||
.SetMethod("print", &Window::Print)
|
.SetMethod("print", &Window::Print)
|
||||||
|
.SetMethod("setProgressBar", &Window::SetProgressBar)
|
||||||
.SetMethod("_getWebContents", &Window::GetWebContents)
|
.SetMethod("_getWebContents", &Window::GetWebContents)
|
||||||
.SetMethod("_getDevToolsWebContents", &Window::GetDevToolsWebContents);
|
.SetMethod("_getDevToolsWebContents", &Window::GetDevToolsWebContents);
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,6 +103,7 @@ class Window : public mate::EventEmitter,
|
||||||
bool IsDocumentEdited();
|
bool IsDocumentEdited();
|
||||||
void CapturePage(mate::Arguments* args);
|
void CapturePage(mate::Arguments* args);
|
||||||
void Print(mate::Arguments* args);
|
void Print(mate::Arguments* args);
|
||||||
|
void SetProgressBar(double progress);
|
||||||
|
|
||||||
// APIs for WebContents.
|
// APIs for WebContents.
|
||||||
mate::Handle<WebContents> GetWebContents(v8::Isolate* isolate) const;
|
mate::Handle<WebContents> GetWebContents(v8::Isolate* isolate) const;
|
||||||
|
|
|
@ -140,6 +140,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||||
virtual void SetMenu(ui::MenuModel* menu);
|
virtual void SetMenu(ui::MenuModel* menu);
|
||||||
virtual bool HasModalDialog();
|
virtual bool HasModalDialog();
|
||||||
virtual gfx::NativeWindow GetNativeWindow() = 0;
|
virtual gfx::NativeWindow GetNativeWindow() = 0;
|
||||||
|
virtual void SetProgressBar(double progress) = 0;
|
||||||
|
|
||||||
virtual bool IsClosed() const { return is_closed_; }
|
virtual bool IsClosed() const { return is_closed_; }
|
||||||
virtual void OpenDevTools();
|
virtual void OpenDevTools();
|
||||||
|
|
|
@ -43,7 +43,9 @@
|
||||||
#elif defined(OS_WIN)
|
#elif defined(OS_WIN)
|
||||||
#include "atom/browser/ui/views/win_frame_view.h"
|
#include "atom/browser/ui/views/win_frame_view.h"
|
||||||
#include "base/win/scoped_comptr.h"
|
#include "base/win/scoped_comptr.h"
|
||||||
|
#include "base/win/windows_version.h"
|
||||||
#include "ui/base/win/shell.h"
|
#include "ui/base/win/shell.h"
|
||||||
|
#include "ui/views/win/hwnd_util.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
@ -479,6 +481,27 @@ gfx::NativeWindow NativeWindowViews::GetNativeWindow() {
|
||||||
return window_->GetNativeWindow();
|
return window_->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), progress);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
gfx::AcceleratedWidget NativeWindowViews::GetAcceleratedWidget() {
|
gfx::AcceleratedWidget NativeWindowViews::GetAcceleratedWidget() {
|
||||||
return GetNativeWindow()->GetHost()->GetAcceleratedWidget();
|
return GetNativeWindow()->GetHost()->GetAcceleratedWidget();
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,7 @@ class NativeWindowViews : public NativeWindow,
|
||||||
virtual bool IsKiosk() OVERRIDE;
|
virtual bool IsKiosk() OVERRIDE;
|
||||||
virtual void SetMenu(ui::MenuModel* menu_model) OVERRIDE;
|
virtual void SetMenu(ui::MenuModel* menu_model) OVERRIDE;
|
||||||
virtual gfx::NativeWindow GetNativeWindow() OVERRIDE;
|
virtual gfx::NativeWindow GetNativeWindow() OVERRIDE;
|
||||||
|
virtual void SetProgressBar(double value) OVERRIDE;
|
||||||
|
|
||||||
gfx::AcceleratedWidget GetAcceleratedWidget();
|
gfx::AcceleratedWidget GetAcceleratedWidget();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue