Add BrowserWindow.print() method.
This commit is contained in:
parent
87d5b72b76
commit
11b9a06639
4 changed files with 33 additions and 19 deletions
|
@ -303,6 +303,22 @@ bool Window::IsWebViewFocused() {
|
||||||
return window_->IsWebViewFocused();
|
return window_->IsWebViewFocused();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::SetRepresentedFilename(const std::string& filename) {
|
||||||
|
window_->SetRepresentedFilename(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Window::GetRepresentedFilename() {
|
||||||
|
return window_->GetRepresentedFilename();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Window::SetDocumentEdited(bool edited) {
|
||||||
|
window_->SetDocumentEdited(edited);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Window::IsDocumentEdited() {
|
||||||
|
return window_->IsDocumentEdited();
|
||||||
|
}
|
||||||
|
|
||||||
void Window::CapturePage(mate::Arguments* args) {
|
void Window::CapturePage(mate::Arguments* args) {
|
||||||
gfx::Rect rect;
|
gfx::Rect rect;
|
||||||
base::Callback<void(v8::Handle<v8::Value>)> callback;
|
base::Callback<void(v8::Handle<v8::Value>)> callback;
|
||||||
|
@ -318,20 +334,8 @@ void Window::CapturePage(mate::Arguments* args) {
|
||||||
rect, base::Bind(&OnCapturePageDone, args->isolate(), callback));
|
rect, base::Bind(&OnCapturePageDone, args->isolate(), callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::SetRepresentedFilename(const std::string& filename) {
|
void Window::Print() {
|
||||||
window_->SetRepresentedFilename(filename);
|
window_->Print();
|
||||||
}
|
|
||||||
|
|
||||||
std::string Window::GetRepresentedFilename() {
|
|
||||||
return window_->GetRepresentedFilename();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Window::SetDocumentEdited(bool edited) {
|
|
||||||
window_->SetDocumentEdited(edited);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Window::IsDocumentEdited() {
|
|
||||||
return window_->IsDocumentEdited();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mate::Handle<WebContents> Window::GetWebContents(v8::Isolate* isolate) const {
|
mate::Handle<WebContents> Window::GetWebContents(v8::Isolate* isolate) const {
|
||||||
|
@ -386,7 +390,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
||||||
.SetMethod("setRepresentedFilename", &Window::SetRepresentedFilename)
|
.SetMethod("setRepresentedFilename", &Window::SetRepresentedFilename)
|
||||||
.SetMethod("getRepresentedFilename", &Window::GetRepresentedFilename)
|
.SetMethod("getRepresentedFilename", &Window::GetRepresentedFilename)
|
||||||
.SetMethod("setDocumentEdited", &Window::SetDocumentEdited)
|
.SetMethod("setDocumentEdited", &Window::SetDocumentEdited)
|
||||||
.SetMethod("IsDocumentEdited", &Window::IsDocumentEdited)
|
.SetMethod("isDocumentEdited", &Window::IsDocumentEdited)
|
||||||
.SetMethod("_openDevTools", &Window::OpenDevTools)
|
.SetMethod("_openDevTools", &Window::OpenDevTools)
|
||||||
.SetMethod("closeDevTools", &Window::CloseDevTools)
|
.SetMethod("closeDevTools", &Window::CloseDevTools)
|
||||||
.SetMethod("isDevToolsOpened", &Window::IsDevToolsOpened)
|
.SetMethod("isDevToolsOpened", &Window::IsDevToolsOpened)
|
||||||
|
@ -395,6 +399,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
||||||
.SetMethod("blurWebView", &Window::BlurWebView)
|
.SetMethod("blurWebView", &Window::BlurWebView)
|
||||||
.SetMethod("isWebViewFocused", &Window::IsWebViewFocused)
|
.SetMethod("isWebViewFocused", &Window::IsWebViewFocused)
|
||||||
.SetMethod("capturePage", &Window::CapturePage)
|
.SetMethod("capturePage", &Window::CapturePage)
|
||||||
|
.SetMethod("print", &Window::Print)
|
||||||
.SetMethod("_getWebContents", &Window::GetWebContents)
|
.SetMethod("_getWebContents", &Window::GetWebContents)
|
||||||
.SetMethod("_getDevToolsWebContents", &Window::GetDevToolsWebContents);
|
.SetMethod("_getDevToolsWebContents", &Window::GetDevToolsWebContents);
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,11 +97,12 @@ class Window : public mate::EventEmitter,
|
||||||
void FocusOnWebView();
|
void FocusOnWebView();
|
||||||
void BlurWebView();
|
void BlurWebView();
|
||||||
bool IsWebViewFocused();
|
bool IsWebViewFocused();
|
||||||
void CapturePage(mate::Arguments* args);
|
|
||||||
void SetRepresentedFilename(const std::string& filename);
|
void SetRepresentedFilename(const std::string& filename);
|
||||||
std::string GetRepresentedFilename();
|
std::string GetRepresentedFilename();
|
||||||
void SetDocumentEdited(bool edited);
|
void SetDocumentEdited(bool edited);
|
||||||
bool IsDocumentEdited();
|
bool IsDocumentEdited();
|
||||||
|
void CapturePage(mate::Arguments* args);
|
||||||
|
void Print();
|
||||||
|
|
||||||
// APIs for WebContents.
|
// APIs for WebContents.
|
||||||
mate::Handle<WebContents> GetWebContents(v8::Isolate* isolate) const;
|
mate::Handle<WebContents> GetWebContents(v8::Isolate* isolate) const;
|
||||||
|
|
|
@ -195,11 +195,16 @@ std::string NativeWindow::GetRepresentedFilename() {
|
||||||
void NativeWindow::SetDocumentEdited(bool edited) {
|
void NativeWindow::SetDocumentEdited(bool edited) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NativeWindow::IsDocumentEdited() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void NativeWindow::SetMenu(ui::MenuModel* menu) {
|
void NativeWindow::SetMenu(ui::MenuModel* menu) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NativeWindow::IsDocumentEdited() {
|
void NativeWindow::Print() {
|
||||||
return false;
|
printing::PrintViewManagerBasic::FromWebContents(GetWebContents())->
|
||||||
|
PrintNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NativeWindow::HasModalDialog() {
|
bool NativeWindow::HasModalDialog() {
|
||||||
|
|
|
@ -136,8 +136,8 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||||
virtual void SetRepresentedFilename(const std::string& filename);
|
virtual void SetRepresentedFilename(const std::string& filename);
|
||||||
virtual std::string GetRepresentedFilename();
|
virtual std::string GetRepresentedFilename();
|
||||||
virtual void SetDocumentEdited(bool edited);
|
virtual void SetDocumentEdited(bool edited);
|
||||||
virtual void SetMenu(ui::MenuModel* menu);
|
|
||||||
virtual bool IsDocumentEdited();
|
virtual bool IsDocumentEdited();
|
||||||
|
virtual void SetMenu(ui::MenuModel* menu);
|
||||||
virtual bool HasModalDialog();
|
virtual bool HasModalDialog();
|
||||||
virtual gfx::NativeWindow GetNativeWindow() = 0;
|
virtual gfx::NativeWindow GetNativeWindow() = 0;
|
||||||
|
|
||||||
|
@ -156,6 +156,9 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||||
virtual void CapturePage(const gfx::Rect& rect,
|
virtual void CapturePage(const gfx::Rect& rect,
|
||||||
const CapturePageCallback& callback);
|
const CapturePageCallback& callback);
|
||||||
|
|
||||||
|
// Print current page.
|
||||||
|
virtual void Print();
|
||||||
|
|
||||||
// The same with closing a tab in a real browser.
|
// The same with closing a tab in a real browser.
|
||||||
//
|
//
|
||||||
// Should be called by platform code when user want to close the window.
|
// Should be called by platform code when user want to close the window.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue