mac: Add BrowserWindow.isDoucumentEdited API, fixes #459.

This commit is contained in:
Haojian Wu 2014-07-24 15:48:33 +08:00
parent acb8b7771e
commit 6f231d5860
7 changed files with 20 additions and 0 deletions

View file

@ -328,6 +328,10 @@ void Window::SetDocumentEdited(bool edited) {
window_->SetDocumentEdited(edited);
}
bool Window::IsDocumentEdited() {
return window_->IsDocumentEdited();
}
mate::Handle<WebContents> Window::GetWebContents(v8::Isolate* isolate) const {
return WebContents::Create(isolate, window_->GetWebContents());
}
@ -379,6 +383,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
.SetMethod("setRepresentedFilename", &Window::SetRepresentedFilename)
.SetMethod("getRepresentedFilename", &Window::GetRepresentedFilename)
.SetMethod("setDocumentEdited", &Window::SetDocumentEdited)
.SetMethod("IsDocumentEdited", &Window::IsDocumentEdited)
.SetMethod("_openDevTools", &Window::OpenDevTools)
.SetMethod("closeDevTools", &Window::CloseDevTools)
.SetMethod("isDevToolsOpened", &Window::IsDevToolsOpened)

View file

@ -100,6 +100,7 @@ class Window : public mate::EventEmitter,
void SetRepresentedFilename(const std::string& filename);
std::string GetRepresentedFilename();
void SetDocumentEdited(bool edited);
bool IsDocumentEdited();
// APIs for WebContents.
mate::Handle<WebContents> GetWebContents(v8::Isolate* isolate) const;

View file

@ -202,6 +202,10 @@ void NativeWindow::SetDocumentEdited(bool edited) {
void NativeWindow::SetMenu(ui::MenuModel* menu) {
}
bool NativeWindow::IsDocumentEdited() {
return false;
}
bool NativeWindow::HasModalDialog() {
return has_dialog_attached_;
}

View file

@ -138,6 +138,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
virtual std::string GetRepresentedFilename();
virtual void SetDocumentEdited(bool edited);
virtual void SetMenu(ui::MenuModel* menu);
virtual bool IsDocumentEdited();
virtual bool HasModalDialog();
virtual gfx::NativeWindow GetNativeWindow() = 0;

View file

@ -61,6 +61,7 @@ class NativeWindowMac : public NativeWindow {
virtual void SetRepresentedFilename(const std::string& filename) OVERRIDE;
virtual std::string GetRepresentedFilename() OVERRIDE;
virtual void SetDocumentEdited(bool edited) OVERRIDE;
virtual bool IsDocumentEdited() OVERRIDE;
virtual bool HasModalDialog() OVERRIDE;
virtual gfx::NativeWindow GetNativeWindow() OVERRIDE;

View file

@ -460,6 +460,10 @@ void NativeWindowMac::SetDocumentEdited(bool edited) {
[window_ setDocumentEdited:edited];
}
bool NativeWindowMac::IsDocumentEdited() {
return [window_ isDocumentEdited];
}
bool NativeWindowMac::HasModalDialog() {
return [window_ attachedSheet] != nil;
}

View file

@ -394,6 +394,10 @@ __OS X Only:__ Returns the pathname of the file the window represents.
__OS X Only:__ Specifies whether the windows document has been edited, and the
icon in titlebar will become grey when set to `true`.
### BrowserWindow.IsDocumentEdited()
__OS X Only:__ Whether the window's document has been edited.
### BrowserWindow.openDevTools()
Opens the developer tools.