mac: Add BrowserWindow.getRepresentedFilename API, fixes #460.

This commit is contained in:
Haojian Wu 2014-07-18 21:42:26 +08:00
parent 301706b7d6
commit acb8b7771e
7 changed files with 20 additions and 0 deletions

View file

@ -320,6 +320,10 @@ 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);
}
@ -373,6 +377,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
.SetMethod("setKiosk", &Window::SetKiosk)
.SetMethod("isKiosk", &Window::IsKiosk)
.SetMethod("setRepresentedFilename", &Window::SetRepresentedFilename)
.SetMethod("getRepresentedFilename", &Window::GetRepresentedFilename)
.SetMethod("setDocumentEdited", &Window::SetDocumentEdited)
.SetMethod("_openDevTools", &Window::OpenDevTools)
.SetMethod("closeDevTools", &Window::CloseDevTools)

View file

@ -98,6 +98,7 @@ class Window : public mate::EventEmitter,
bool IsWebViewFocused();
void CapturePage(mate::Arguments* args);
void SetRepresentedFilename(const std::string& filename);
std::string GetRepresentedFilename();
void SetDocumentEdited(bool edited);
// APIs for WebContents.

View file

@ -192,6 +192,10 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) {
void NativeWindow::SetRepresentedFilename(const std::string& filename) {
}
std::string NativeWindow::GetRepresentedFilename() {
return "";
}
void NativeWindow::SetDocumentEdited(bool edited) {
}

View file

@ -135,6 +135,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
virtual void SetKiosk(bool kiosk) = 0;
virtual bool IsKiosk() = 0;
virtual void SetRepresentedFilename(const std::string& filename);
virtual std::string GetRepresentedFilename();
virtual void SetDocumentEdited(bool edited);
virtual void SetMenu(ui::MenuModel* menu);
virtual bool HasModalDialog();

View file

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

View file

@ -452,6 +452,10 @@ void NativeWindowMac::SetRepresentedFilename(const std::string& filename) {
[window_ setRepresentedFilename:base::SysUTF8ToNSString(filename)];
}
std::string NativeWindowMac::GetRepresentedFilename() {
return base::SysNSStringToUTF8([window_ representedFilename]);
}
void NativeWindowMac::SetDocumentEdited(bool edited) {
[window_ setDocumentEdited:edited];
}

View file

@ -383,6 +383,10 @@ Returns whether the window is in kiosk mode.
__OS X Only:__ Sets the pathname of the file the window represents, and the icon
of the file will show in window's title bar.
### BrowserWindow.getRepresentedFilename()
__OS X Only:__ Returns the pathname of the file the window represents.
### BrowserWindow.setDocumentEdited(edited)
* `edited` Boolean