mac: Add app.addRecentDocument API

This commit is contained in:
Cheng Zhao 2014-11-17 13:05:06 +08:00
parent 6aa69a06c8
commit c23ba7b504
5 changed files with 21 additions and 0 deletions

View file

@ -158,6 +158,8 @@ mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder(
.SetMethod("getName", base::Bind(&Browser::GetName, browser)) .SetMethod("getName", base::Bind(&Browser::GetName, browser))
.SetMethod("setName", base::Bind(&Browser::SetName, browser)) .SetMethod("setName", base::Bind(&Browser::SetName, browser))
.SetMethod("isReady", base::Bind(&Browser::is_ready, browser)) .SetMethod("isReady", base::Bind(&Browser::is_ready, browser))
.SetMethod("addRecentDocument",
base::Bind(&Browser::AddRecentDocument, browser))
.SetMethod("getDataPath", &App::GetDataPath) .SetMethod("getDataPath", &App::GetDataPath)
.SetMethod("resolveProxy", &App::ResolveProxy) .SetMethod("resolveProxy", &App::ResolveProxy)
.SetMethod("setDesktopName", &App::SetDesktopName); .SetMethod("setDesktopName", &App::SetDesktopName);

View file

@ -13,6 +13,10 @@
#include "atom/browser/browser_observer.h" #include "atom/browser/browser_observer.h"
#include "atom/browser/window_list_observer.h" #include "atom/browser/window_list_observer.h"
namespace base {
class FilePath;
}
namespace ui { namespace ui {
class MenuModel; class MenuModel;
} }
@ -48,6 +52,9 @@ class Browser : public WindowListObserver {
// Overrides the application name. // Overrides the application name.
void SetName(const std::string& name); void SetName(const std::string& name);
// Add the |path| to recent documents list.
void AddRecentDocument(const base::FilePath& path);
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
// Bounce the dock icon. // Bounce the dock icon.
enum BounceType { enum BounceType {

View file

@ -24,6 +24,9 @@ void Browser::Focus() {
} }
} }
void Browser::AddRecentDocument(const base::FilePath& path) {
}
std::string Browser::GetExecutableFileVersion() const { std::string Browser::GetExecutableFileVersion() const {
return ATOM_VERSION_STRING; return ATOM_VERSION_STRING;
} }

View file

@ -9,6 +9,7 @@
#include "atom/browser/native_window.h" #include "atom/browser/native_window.h"
#include "atom/browser/window_list.h" #include "atom/browser/window_list.h"
#import "base/mac/bundle_locations.h" #import "base/mac/bundle_locations.h"
#import "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
namespace atom { namespace atom {
@ -17,6 +18,11 @@ void Browser::Focus() {
[[AtomApplication sharedApplication] activateIgnoringOtherApps:YES]; [[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 { std::string Browser::GetExecutableFileVersion() const {
NSDictionary* infoDictionary = base::mac::OuterBundle().infoDictionary; NSDictionary* infoDictionary = base::mac::OuterBundle().infoDictionary;
NSString *version = [infoDictionary objectForKey:@"CFBundleVersion"]; NSString *version = [infoDictionary objectForKey:@"CFBundleVersion"];

View file

@ -39,6 +39,9 @@ void Browser::Focus() {
EnumWindows(&WindowsEnumerationHandler, reinterpret_cast<LPARAM>(&pid)); EnumWindows(&WindowsEnumerationHandler, reinterpret_cast<LPARAM>(&pid));
} }
void Browser::AddRecentDocument(const base::FilePath& path) {
}
std::string Browser::GetExecutableFileVersion() const { std::string Browser::GetExecutableFileVersion() const {
base::FilePath path; base::FilePath path;
if (PathService::Get(base::FILE_EXE, &path)) { if (PathService::Get(base::FILE_EXE, &path)) {