mac: Add APIs on setting icon in titlebar.

This commit is contained in:
Cheng Zhao 2014-05-27 14:15:34 +08:00
parent 2f5dfb1dc7
commit a7b730654c
7 changed files with 44 additions and 0 deletions

View file

@ -314,6 +314,14 @@ void Window::CapturePage(mate::Arguments* args) {
window_->CapturePage(rect, base::Bind(&OnCapturePageDone, callback)); window_->CapturePage(rect, base::Bind(&OnCapturePageDone, callback));
} }
void Window::SetRepresentedFilename(const std::string& filename) {
window_->SetRepresentedFilename(filename);
}
void Window::SetDocumentEdited(bool edited) {
window_->SetDocumentEdited(edited);
}
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());
} }
@ -360,6 +368,8 @@ void Window::BuildPrototype(v8::Isolate* isolate,
.SetMethod("flashFrame", &Window::FlashFrame) .SetMethod("flashFrame", &Window::FlashFrame)
.SetMethod("setKiosk", &Window::SetKiosk) .SetMethod("setKiosk", &Window::SetKiosk)
.SetMethod("isKiosk", &Window::IsKiosk) .SetMethod("isKiosk", &Window::IsKiosk)
.SetMethod("setRepresentedFilename", &Window::SetRepresentedFilename)
.SetMethod("setDocumentEdited", &Window::SetDocumentEdited)
.SetMethod("_openDevTools", &Window::OpenDevTools) .SetMethod("_openDevTools", &Window::OpenDevTools)
.SetMethod("closeDevTools", &Window::CloseDevTools) .SetMethod("closeDevTools", &Window::CloseDevTools)
.SetMethod("isDevToolsOpened", &Window::IsDevToolsOpened) .SetMethod("isDevToolsOpened", &Window::IsDevToolsOpened)

View file

@ -101,6 +101,8 @@ class Window : public mate::EventEmitter,
void BlurWebView(); void BlurWebView();
bool IsWebViewFocused(); bool IsWebViewFocused();
void CapturePage(mate::Arguments* args); void CapturePage(mate::Arguments* args);
void SetRepresentedFilename(const std::string& filename);
void SetDocumentEdited(bool edited);
// APIs for WebContents. // APIs for WebContents.
mate::Handle<WebContents> GetWebContents(v8::Isolate* isolate) const; mate::Handle<WebContents> GetWebContents(v8::Isolate* isolate) const;

View file

@ -191,6 +191,12 @@ void NativeWindow::InitFromOptions(base::DictionaryValue* options) {
Show(); Show();
} }
void NativeWindow::SetRepresentedFilename(const std::string& filename) {
}
void NativeWindow::SetDocumentEdited(bool edited) {
}
bool NativeWindow::HasModalDialog() { bool NativeWindow::HasModalDialog() {
return has_dialog_attached_; return has_dialog_attached_;
} }

View file

@ -129,6 +129,8 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
virtual void FlashFrame(bool flash) = 0; virtual void FlashFrame(bool flash) = 0;
virtual void SetKiosk(bool kiosk) = 0; virtual void SetKiosk(bool kiosk) = 0;
virtual bool IsKiosk() = 0; virtual bool IsKiosk() = 0;
virtual void SetRepresentedFilename(const std::string& filename);
virtual void SetDocumentEdited(bool edited);
virtual bool HasModalDialog(); virtual bool HasModalDialog();
virtual gfx::NativeWindow GetNativeWindow() = 0; virtual gfx::NativeWindow GetNativeWindow() = 0;

View file

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

View file

@ -432,6 +432,14 @@ bool NativeWindowMac::IsKiosk() {
return is_kiosk_; return is_kiosk_;
} }
void NativeWindowMac::SetRepresentedFilename(const std::string& filename) {
[window_ setRepresentedFilename:base::SysUTF8ToNSString(filename)];
}
void NativeWindowMac::SetDocumentEdited(bool edited) {
[window_ setDocumentEdited:edited];
}
bool NativeWindowMac::HasModalDialog() { bool NativeWindowMac::HasModalDialog() {
return [window_ attachedSheet] != nil; return [window_ attachedSheet] != nil;
} }

View file

@ -362,6 +362,20 @@ Enters or leaves the kiosk mode.
Returns whether the window is in kiosk mode. Returns whether the window is in kiosk mode.
### BrowserWindow.setRepresentedFilename(filename)
* `filename` String
__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.setDocumentEdited(edited)
* `edited` Boolean
__OS X Only__ Specifies whether the windows document has been edited, and the
icon in titlebar will become grey when set to `true`.
### BrowserWindow.openDevTools() ### BrowserWindow.openDevTools()
Opens the developer tools. Opens the developer tools.