From 48412769df0a9cdae3cdde67b86159feb2f6a9a2 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 17 Nov 2014 16:13:47 +0800 Subject: [PATCH] win: Add app.clearRecentDocuments API --- atom/browser/api/atom_api_app.cc | 2 ++ atom/browser/browser.h | 3 +++ atom/browser/browser_linux.cc | 3 +++ atom/browser/browser_mac.mm | 3 +++ atom/browser/browser_win.cc | 10 ++++++++++ 5 files changed, 21 insertions(+) diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index f42b1e0d0c8..8305b6a320e 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -160,6 +160,8 @@ mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder( .SetMethod("isReady", base::Bind(&Browser::is_ready, browser)) .SetMethod("addRecentDocument", base::Bind(&Browser::AddRecentDocument, browser)) + .SetMethod("clearRecentDocuments", + base::Bind(&Browser::ClearRecentDocuments, browser)) .SetMethod("getDataPath", &App::GetDataPath) .SetMethod("resolveProxy", &App::ResolveProxy) .SetMethod("setDesktopName", &App::SetDesktopName); diff --git a/atom/browser/browser.h b/atom/browser/browser.h index aa3b3c07aa5..6fed3eec0c6 100644 --- a/atom/browser/browser.h +++ b/atom/browser/browser.h @@ -59,6 +59,9 @@ class Browser : public WindowListObserver { // Add the |path| to recent documents list. void AddRecentDocument(const base::FilePath& path); + // Clear the recent documents list. + void ClearRecentDocuments(); + #if defined(OS_MACOSX) // Bounce the dock icon. enum BounceType { diff --git a/atom/browser/browser_linux.cc b/atom/browser/browser_linux.cc index fceb127f20d..7534aa2182d 100644 --- a/atom/browser/browser_linux.cc +++ b/atom/browser/browser_linux.cc @@ -27,6 +27,9 @@ void Browser::Focus() { void Browser::AddRecentDocument(const base::FilePath& path) { } +void Browser::ClearRecentDocuments() { +} + std::string Browser::GetExecutableFileVersion() const { return ATOM_VERSION_STRING; } diff --git a/atom/browser/browser_mac.mm b/atom/browser/browser_mac.mm index 1cb1f6f8faa..797c560728f 100644 --- a/atom/browser/browser_mac.mm +++ b/atom/browser/browser_mac.mm @@ -23,6 +23,9 @@ void Browser::AddRecentDocument(const base::FilePath& path) { [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:u]; } +void Browser::ClearRecentDocuments() { +} + std::string Browser::GetExecutableFileVersion() const { NSDictionary* infoDictionary = base::mac::OuterBundle().infoDictionary; NSString *version = [infoDictionary objectForKey:@"CFBundleVersion"]; diff --git a/atom/browser/browser_win.cc b/atom/browser/browser_win.cc index 91550ace4a7..c5e3aadc8be 100644 --- a/atom/browser/browser_win.cc +++ b/atom/browser/browser_win.cc @@ -59,6 +59,16 @@ void Browser::AddRecentDocument(const base::FilePath& path) { } } +void Browser::ClearRecentDocuments() { + CComPtr destinations; + if (FAILED(destinations.CoCreateInstance(CLSID_ApplicationDestinations, + NULL, CLSCTX_INPROC_SERVER))) + return; + if (FAILED(destinations->SetAppID(app_user_model_id_.c_str()))) + return; + destinations->RemoveAllDestinations(); +} + void Browser::SetAppUserModelID(const std::string& name) { app_user_model_id_ = base::UTF8ToUTF16( base::StringPrintf("atom-shell.app.%s", name));