Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1475)

Unified Diff: chrome/browser/extensions/api/file_system/file_system_api.cc

Issue 15896035: File system API: whitelist the Downloads dir on Chrome OS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Sam's comments. Confirmed test passing on chromeos. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/api/file_system/file_system_apitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/file_system/file_system_api.cc
diff --git a/chrome/browser/extensions/api/file_system/file_system_api.cc b/chrome/browser/extensions/api/file_system/file_system_api.cc
index 615e1a7156d1137c7f40412edde5011252c9b5e4..9bff7933fb7701dca5428379aea8a53cb869f3cd 100644
--- a/chrome/browser/extensions/api/file_system/file_system_api.cc
+++ b/chrome/browser/extensions/api/file_system/file_system_api.cc
@@ -73,6 +73,14 @@ const int kBlacklistedPaths[] = {
chrome::DIR_USER_DATA,
};
+#if defined(OS_CHROMEOS)
+// On Chrome OS, the default downloads directory is a subdirectory of user data
+// directory, and should be whitelisted.
+const int kWhitelistedPaths[] = {
+ chrome::DIR_DEFAULT_DOWNLOADS_SAFE,
+};
+#endif
+
#if defined(OS_MACOSX)
// Retrieves the localized display name for the base name of the given path.
// If the path is not localized, this will just return the base name.
@@ -211,11 +219,26 @@ bool DoCheckWritableFile(const base::FilePath& path,
if (extension_directory == path || extension_directory.IsParent(path))
return false;
- for (size_t i = 0; i < arraysize(kBlacklistedPaths); i++) {
- base::FilePath blacklisted_path;
- if (PathService::Get(kBlacklistedPaths[i], &blacklisted_path) &&
- (blacklisted_path == path || blacklisted_path.IsParent(path))) {
- return false;
+ bool is_whitelisted_path = false;
+
+#if defined(OS_CHROMEOS)
+ for (size_t i = 0; i < arraysize(kWhitelistedPaths); i++) {
+ base::FilePath whitelisted_path;
+ if (PathService::Get(kWhitelistedPaths[i], &whitelisted_path) &&
+ (whitelisted_path == path || whitelisted_path.IsParent(path))) {
+ is_whitelisted_path = true;
+ break;
+ }
+ }
+#endif
+
+ if (!is_whitelisted_path) {
+ for (size_t i = 0; i < arraysize(kBlacklistedPaths); i++) {
+ base::FilePath blacklisted_path;
+ if (PathService::Get(kBlacklistedPaths[i], &blacklisted_path) &&
+ (blacklisted_path == path || blacklisted_path.IsParent(path))) {
+ return false;
+ }
}
}
« no previous file with comments | « no previous file | chrome/browser/extensions/api/file_system/file_system_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698