| 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 fd3bcbb69d5d722ac86c8fec49e9821536db6873..d48c2b81148f0f3133d15079b7a76b97b48d26d7 100644
|
| --- a/chrome/browser/extensions/api/file_system/file_system_api.cc
|
| +++ b/chrome/browser/extensions/api/file_system/file_system_api.cc
|
| @@ -4,6 +4,10 @@
|
|
|
| #include "chrome/browser/extensions/api/file_system/file_system_api.h"
|
|
|
| +#if defined(OS_MACOSX)
|
| +#include "base/mac/foundation_util.h"
|
| +#endif
|
| +
|
| #include "base/bind.h"
|
| #include "base/file_path.h"
|
| #include "base/file_util.h"
|
| @@ -46,10 +50,16 @@ namespace {
|
|
|
| struct RewritePair {
|
| int path_key;
|
| - const char* output;
|
| + const char* output; // NULL indicates that this display name should be
|
| + // retrieved from the system.
|
| };
|
|
|
| const RewritePair g_rewrite_pairs[] = {
|
| +#if defined(OS_MACOSX)
|
| + {base::DIR_DESKTOP, NULL},
|
| + {base::DIR_DOCUMENTS, NULL},
|
| + {base::DIR_DOWNLOADS, NULL},
|
| +#endif
|
| #if defined(OS_WIN)
|
| {base::DIR_PROFILE, "~"},
|
| #elif defined(OS_POSIX)
|
| @@ -65,7 +75,22 @@ FilePath PrettifyPath(const FilePath& file_path) {
|
| continue; // We don't DCHECK this value, as Get will return false even
|
| // if the path_key gives a blank string as a result.
|
|
|
| - FilePath output = FilePath::FromUTF8Unsafe(g_rewrite_pairs[i].output);
|
| + FilePath output;
|
| + if (!g_rewrite_pairs[i].output) {
|
| +#if defined(OS_MACOSX)
|
| + if (!candidate_path.IsParent(file_path))
|
| + continue;
|
| +
|
| + std::string display_name;
|
| + base::mac::GetDisplayNameForPath(candidate_path, &display_name);
|
| + output = FilePath::FromUTF8Unsafe(display_name);
|
| +#else
|
| + NOTREACHED();
|
| +#endif
|
| + } else {
|
| + output = FilePath::FromUTF8Unsafe(g_rewrite_pairs[i].output);
|
| + }
|
| +
|
| if (candidate_path.AppendRelativePath(file_path, &output)) {
|
| // The output path must not be absolute, as it might collide with the
|
| // real filesystem.
|
|
|