mac: Add APIs on setting icon in titlebar.
authorCheng Zhao <zcbenz@gmail.com>
Tue, 27 May 2014 06:15:34 +0000 (14:15 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 27 May 2014 06:15:34 +0000 (14:15 +0800)
atom/browser/api/atom_api_window.cc
atom/browser/api/atom_api_window.h
atom/browser/native_window.cc
atom/browser/native_window.h
atom/browser/native_window_mac.h
atom/browser/native_window_mac.mm
docs/api/browser-window.md

index c30e299f4fb8af4f48fa9e8d1a064268903f92c0..7f433321b430a42fa2bc0a743c642b55e04f4357 100644 (file)
@@ -314,6 +314,14 @@ void Window::CapturePage(mate::Arguments* args) {
   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 {
   return WebContents::Create(isolate, window_->GetWebContents());
 }
@@ -360,6 +368,8 @@ void Window::BuildPrototype(v8::Isolate* isolate,
       .SetMethod("flashFrame", &Window::FlashFrame)
       .SetMethod("setKiosk", &Window::SetKiosk)
       .SetMethod("isKiosk", &Window::IsKiosk)
+      .SetMethod("setRepresentedFilename", &Window::SetRepresentedFilename)
+      .SetMethod("setDocumentEdited", &Window::SetDocumentEdited)
       .SetMethod("_openDevTools", &Window::OpenDevTools)
       .SetMethod("closeDevTools", &Window::CloseDevTools)
       .SetMethod("isDevToolsOpened", &Window::IsDevToolsOpened)
index be74f14b95a3c238c095ac18f11360832debe1c9..1aa9cee96917c201f5f85e664a571ab96db90bbd 100644 (file)
@@ -101,6 +101,8 @@ class Window : public mate::EventEmitter,
   void BlurWebView();
   bool IsWebViewFocused();
   void CapturePage(mate::Arguments* args);
+  void SetRepresentedFilename(const std::string& filename);
+  void SetDocumentEdited(bool edited);
 
   // APIs for WebContents.
   mate::Handle<WebContents> GetWebContents(v8::Isolate* isolate) const;
index b4214a1fcd36049d5f840bd015821aa682b36b64..949dff1caeeff5bf96f417976b19d7c2a23925ca 100644 (file)
@@ -191,6 +191,12 @@ void NativeWindow::InitFromOptions(base::DictionaryValue* options) {
     Show();
 }
 
+void NativeWindow::SetRepresentedFilename(const std::string& filename) {
+}
+
+void NativeWindow::SetDocumentEdited(bool edited) {
+}
+
 bool NativeWindow::HasModalDialog() {
   return has_dialog_attached_;
 }
index f9c490e5b184c7166888c47a2f4f692ed331ba6a..a29b8285b52e316b4491f7bc2eac374fe2442de5 100644 (file)
@@ -129,6 +129,8 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
   virtual void FlashFrame(bool flash) = 0;
   virtual void SetKiosk(bool kiosk) = 0;
   virtual bool IsKiosk() = 0;
+  virtual void SetRepresentedFilename(const std::string& filename);
+  virtual void SetDocumentEdited(bool edited);
   virtual bool HasModalDialog();
   virtual gfx::NativeWindow GetNativeWindow() = 0;
 
index d60da8df7629bb27fb342231f998e72df4f59174..5dc8aa6b8f693df456b59876b6282dd1e2084fc8 100644 (file)
@@ -56,6 +56,8 @@ class NativeWindowMac : public NativeWindow {
   virtual void FlashFrame(bool flash) OVERRIDE;
   virtual void SetKiosk(bool kiosk) OVERRIDE;
   virtual bool IsKiosk() OVERRIDE;
+  virtual void SetRepresentedFilename(const std::string& filename) OVERRIDE;
+  virtual void SetDocumentEdited(bool edited) OVERRIDE;
   virtual bool HasModalDialog() OVERRIDE;
   virtual gfx::NativeWindow GetNativeWindow() OVERRIDE;
 
index a34ec9c7df9c97f014bc8de351d8f7eff4b80fd9..634b052cb015988ac3710e92ed5abe36a80d1868 100644 (file)
@@ -432,6 +432,14 @@ bool NativeWindowMac::IsKiosk() {
   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() {
   return [window_ attachedSheet] != nil;
 }
index c25d3bf8576e7c3a422ce38db627502730297fa9..ae0c8fe7e367accfe7d2aa8a105e1e1eac38a895 100644 (file)
@@ -362,6 +362,20 @@ Enters or leaves the 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 window’s document has been edited, and the
+icon in titlebar will become grey when set to `true`.
+
 ### BrowserWindow.openDevTools()
 
 Opens the developer tools.