]> khamidou — GitHub mirrors - electron.git/commitdiff
mac: Add app.addRecentDocument API
authorCheng Zhao <zcbenz@gmail.com>
Mon, 17 Nov 2014 05:05:06 +0000 (13:05 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 17 Nov 2014 05:05:06 +0000 (13:05 +0800)
atom/browser/api/atom_api_app.cc
atom/browser/browser.h
atom/browser/browser_linux.cc
atom/browser/browser_mac.mm
atom/browser/browser_win.cc

index 829fed18901035e5bc4f662f2c7ccf85af892e3e..f42b1e0d0c8ff3faeebd854e19e5269be4fe6bc6 100644 (file)
@@ -158,6 +158,8 @@ mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder(
       .SetMethod("getName", base::Bind(&Browser::GetName, browser))
       .SetMethod("setName", base::Bind(&Browser::SetName, browser))
       .SetMethod("isReady", base::Bind(&Browser::is_ready, browser))
+      .SetMethod("addRecentDocument",
+                 base::Bind(&Browser::AddRecentDocument, browser))
       .SetMethod("getDataPath", &App::GetDataPath)
       .SetMethod("resolveProxy", &App::ResolveProxy)
       .SetMethod("setDesktopName", &App::SetDesktopName);
index 5cc05d1a4fccb2cef867a1bb191fc9bbfac16fd9..e058ec25e25101eecd5edd3839b20ce4d9805010 100644 (file)
 #include "atom/browser/browser_observer.h"
 #include "atom/browser/window_list_observer.h"
 
+namespace base {
+class FilePath;
+}
+
 namespace ui {
 class MenuModel;
 }
@@ -48,6 +52,9 @@ class Browser : public WindowListObserver {
   // Overrides the application name.
   void SetName(const std::string& name);
 
+  // Add the |path| to recent documents list.
+  void AddRecentDocument(const base::FilePath& path);
+
 #if defined(OS_MACOSX)
   // Bounce the dock icon.
   enum BounceType {
index 5ede610813b8bdfbc2d1239999eb613699456f5c..fceb127f20d0923f7b79a0edb06d6ef457960c28 100644 (file)
@@ -24,6 +24,9 @@ void Browser::Focus() {
   }
 }
 
+void Browser::AddRecentDocument(const base::FilePath& path) {
+}
+
 std::string Browser::GetExecutableFileVersion() const {
   return ATOM_VERSION_STRING;
 }
index 3d1b293d2ffc4decda962aaf332199655855fc9c..1cb1f6f8faab5e0cc9b1044b0a2d55e3804f5468 100644 (file)
@@ -9,6 +9,7 @@
 #include "atom/browser/native_window.h"
 #include "atom/browser/window_list.h"
 #import "base/mac/bundle_locations.h"
+#import "base/mac/foundation_util.h"
 #include "base/strings/sys_string_conversions.h"
 
 namespace atom {
@@ -17,6 +18,11 @@ void Browser::Focus() {
   [[AtomApplication sharedApplication] activateIgnoringOtherApps:YES];
 }
 
+void Browser::AddRecentDocument(const base::FilePath& path) {
+  NSURL* u = [NSURL fileURLWithPath:base::mac::FilePathToNSString(path)];
+  [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:u];
+}
+
 std::string Browser::GetExecutableFileVersion() const {
   NSDictionary* infoDictionary = base::mac::OuterBundle().infoDictionary;
   NSString *version = [infoDictionary objectForKey:@"CFBundleVersion"];
index 4cbf0f9647dd84ec7cbb79068437ba4ce7221dba..4d90933a9db162a9c8e676e838286f967b130e93 100644 (file)
@@ -39,6 +39,9 @@ void Browser::Focus() {
   EnumWindows(&WindowsEnumerationHandler, reinterpret_cast<LPARAM>(&pid));
 }
 
+void Browser::AddRecentDocument(const base::FilePath& path) {
+}
+
 std::string Browser::GetExecutableFileVersion() const {
   base::FilePath path;
   if (PathService::Get(base::FILE_EXE, &path)) {