feat: app.getPath('recent') (#23381)

* feat: getPath("recent")

* test: Add a spec and docs

* fix: Integrate feedback

* fix: Handle path change

* chore: Cut SetRecentPath
This commit is contained in:
Felix Rieseberg 2020-05-12 19:27:56 -07:00 committed by GitHub
parent c7b2eb68cf
commit dcbed18f44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 57 additions and 0 deletions

View file

@ -54,6 +54,7 @@
#include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/node_includes.h"
#include "shell/common/options_switches.h"
#include "shell/common/platform_util.h"
#include "ui/gfx/image/image.h"
#if defined(OS_WIN)
@ -425,6 +426,10 @@ int GetPathConstant(const std::string& name) {
return chrome::DIR_USER_PICTURES;
else if (name == "videos")
return chrome::DIR_USER_VIDEOS;
#if defined(OS_WIN)
else if (name == "recent")
return electron::DIR_RECENT;
#endif
else if (name == "pepperFlashSystemPlugin")
return chrome::FILE_PEPPER_FLASH_SYSTEM_PLUGIN;
else
@ -885,6 +890,15 @@ base::FilePath App::GetPath(gin_helper::ErrorThrower thrower,
SetAppLogsPath(thrower, base::Optional<base::FilePath>());
succeed = base::PathService::Get(key, &path);
}
#if defined(OS_WIN)
// If we get the "recent" path before setting it, set it
if (!succeed && name == "recent" &&
platform_util::GetFolderPath(DIR_RECENT, &path)) {
base::ThreadRestrictions::ScopedAllowIO allow_io;
succeed = base::PathService::Override(DIR_RECENT, path);
}
#endif
}
if (!succeed)