]> khamidou — GitHub mirrors - electron.git/commitdiff
mac: Add BrowserWindow.getRepresentedFilename API, fixes #460.
authorHaojian Wu <hokein.wu@gmail.com>
Fri, 18 Jul 2014 13:42:26 +0000 (21:42 +0800)
committerHaojian Wu <hokein.wu@gmail.com>
Thu, 24 Jul 2014 07:59:35 +0000 (15:59 +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 c6b28af5585c12a1f90289fc1204ebea7eed6284..668aa1a55c2cd49d06adfdf48e19b31136583049 100644 (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)
index 91f9d333adb492c7e4f92f33c039daacb85a7201..d47a66f1dfae079f26dd29a84e2c192320bcddb8 100644 (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.
index f99f783f160594b89f7f6eaf68ff298360bb669a..5027114915ffa1bbb091533f6a6a40e3b012a57f 100644 (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) {
 }
 
index fdb7fa676f8ad1b89dba0c8ea5bfd1dd5383a679..896e0dbc10e090b3abaa29bfd0ed6f88a670bdbc 100644 (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();
index 16092065f230b957b208a450c955e919614cacb8..5df01f91a1d2cccfe35340970f0b6bccbecdee90 100644 (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;
index 794f4a8af13cc14d5433a9fd1a890d477bab69ae..b524a8acf46e27f0b6cf5ff99e658f19cd760a43 100644 (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];
 }
index 57b89202400d3d3953d978e7990bea44acb786f2..8facd14f0f30d2edd513cf0e42e587c98f2550fd 100644 (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