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

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

Issue 10823157: Prettify Mac names, rewrite getDisplayPath API call to focus on $HOME (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Actually works on Mac now Created 8 years, 4 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
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.

Powered by Google App Engine
This is Rietveld 408576698