Index: chrome/browser/extensions/path_util.cc |
diff --git a/chrome/browser/extensions/path_util.cc b/chrome/browser/extensions/path_util.cc |
index 429f9e4438759217bb484e8b0e09260e73dc021f..7ff52eb580f4e149e976480891daa72bf346df8a 100644 |
--- a/chrome/browser/extensions/path_util.cc |
+++ b/chrome/browser/extensions/path_util.cc |
@@ -40,10 +40,18 @@ std::string GetDisplayBaseName(const base::FilePath& path) { |
} |
} // namespace |
+#endif // defined(OS_MACOSX) |
base::FilePath PrettifyPath(const base::FilePath& source_path) { |
base::FilePath home_path; |
- PathService::Get(base::DIR_HOME, &home_path); |
+ if (source_path.empty() || !PathService::Get(base::DIR_HOME, &home_path)) |
+ return source_path; |
+ |
+ base::FilePath display_path = base::FilePath(FILE_PATH_LITERAL("~")); |
+ if (source_path == home_path) |
+ return display_path; |
+ |
+#if defined(OS_MACOSX) |
DCHECK(source_path.IsAbsolute()); |
// Break down the incoming path into components, and grab the display name |
@@ -53,13 +61,13 @@ base::FilePath PrettifyPath(const base::FilePath& source_path) { |
// show up as the HDD name. |
std::vector<base::FilePath::StringType> components; |
source_path.GetComponents(&components); |
- base::FilePath display_path = base::FilePath(components[0]); |
+ display_path = base::FilePath(components[0]); |
base::FilePath actual_path = display_path; |
for (std::vector<base::FilePath::StringType>::iterator i = |
components.begin() + 1; i != components.end(); ++i) { |
actual_path = actual_path.Append(*i); |
if (actual_path == home_path) { |
- display_path = base::FilePath("~"); |
+ display_path = base::FilePath(FILE_PATH_LITERAL("~")); |
Devlin
2014/08/06 23:35:56
Save the FILE_PATH_LITERAL so you don't have to ke
gpdavis
2014/08/07 01:20:06
Done.
|
home_path = base::FilePath(); |
continue; |
} |
@@ -68,17 +76,12 @@ base::FilePath PrettifyPath(const base::FilePath& source_path) { |
} |
DCHECK_EQ(actual_path.value(), source_path.value()); |
return display_path; |
-} |
-#else // defined(OS_MACOSX) |
-base::FilePath PrettifyPath(const base::FilePath& source_path) { |
- base::FilePath home_path; |
- base::FilePath display_path = base::FilePath::FromUTF8Unsafe("~"); |
- if (PathService::Get(base::DIR_HOME, &home_path) && |
- home_path.AppendRelativePath(source_path, &display_path)) |
+#else // defined(OS_MACOSX) |
+ if (home_path.AppendRelativePath(source_path, &display_path)) |
return display_path; |
return source_path; |
-} |
#endif // defined(OS_MACOSX) |
+} |
} // namespace path_util |
} // namespace extensions |