win: Add app.clearRecentDocuments API

This commit is contained in:
Cheng Zhao 2014-11-17 16:13:47 +08:00
parent 528f7bd45f
commit 48412769df
5 changed files with 21 additions and 0 deletions

View file

@ -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);

View file

@ -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 {

View file

@ -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;
}

View file

@ -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"];

View file

@ -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));