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

Unified Diff: chrome/browser/extensions/path_util.cc

Issue 439873002: Check for empty paths in path_util (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tighten #ifdefs Created 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..3442b623ff04a6d09fd7a0490528bbeee242fb8b 100644
--- a/chrome/browser/extensions/path_util.cc
+++ b/chrome/browser/extensions/path_util.cc
@@ -20,7 +20,7 @@ namespace extensions {
namespace path_util {
#if defined(OS_MACOSX)
-namespace {
+namespace OS_MACOSX {
not at google - send to devlin 2014/08/05 00:11:05 why do you have this extra namespace? it can stay
gpdavis 2014/08/05 01:53:51 I thought this was what you meant by "specific OS_
// 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.
@@ -39,11 +39,18 @@ std::string GetDisplayBaseName(const base::FilePath& path) {
return result;
}
-} // namespace
+} // namespace OS_MACOSX
+#endif // defined(OS_MACOSX)
base::FilePath PrettifyPath(const base::FilePath& source_path) {
+ if (source_path.empty())
+ return base::FilePath();
+
base::FilePath home_path;
- PathService::Get(base::DIR_HOME, &home_path);
+ if (!PathService::Get(base::DIR_HOME, &home_path))
+ return source_path;
+
+#if defined(OS_MACOSX)
DCHECK(source_path.IsAbsolute());
// Break down the incoming path into components, and grab the display name
@@ -63,22 +70,18 @@ base::FilePath PrettifyPath(const base::FilePath& source_path) {
home_path = base::FilePath();
continue;
}
- std::string display = GetDisplayBaseName(actual_path);
+ std::string display = OS_MACOSX::GetDisplayBaseName(actual_path);
display_path = display_path.Append(display);
}
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;
+#else // defined(OS_MACOSX)
base::FilePath display_path = base::FilePath::FromUTF8Unsafe("~");
- if (PathService::Get(base::DIR_HOME, &home_path) &&
- home_path.AppendRelativePath(source_path, &display_path))
+ if (home_path.AppendRelativePath(source_path, &display_path))
return display_path;
return source_path;
-}
#endif // defined(OS_MACOSX)
+}
} // namespace path_util
} // namespace extensions
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698