Browse Source

win: Add app.clearRecentDocuments API

Cheng Zhao 10 years ago
parent
commit
48412769df

+ 2 - 0
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);

+ 3 - 0
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 {

+ 3 - 0
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;
 }

+ 3 - 0
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"];

+ 10 - 0
atom/browser/browser_win.cc

@@ -59,6 +59,16 @@ void Browser::AddRecentDocument(const base::FilePath& path) {
   }
 }
 
+void Browser::ClearRecentDocuments() {
+  CComPtr<IApplicationDestinations> 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));