Index: base/file_util_posix.cc |
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc |
index 7e7dc052300fde54dc71f36681d783dc14776b17..7797a4124f8037d677911b5ce6af766c1945897b 100644 |
--- a/base/file_util_posix.cc |
+++ b/base/file_util_posix.cc |
@@ -31,6 +31,7 @@ |
#include <fstream> |
#include "base/basictypes.h" |
+#include "base/command_line.h" |
#include "base/files/file_enumerator.h" |
#include "base/files/file_path.h" |
#include "base/logging.h" |
@@ -191,6 +192,20 @@ bool DetermineDevShmExecutable() { |
} |
#endif // defined(OS_LINUX) |
+#if defined(OS_CHROMEOS) |
+// On Chrome OS Indicates that a user has logged in and that |
+// GetHomeDir() calls are now valid. |
+static bool is_user_logged_in = false; |
+ |
+// Primary logged in user id hash which is used on ChromeOS to identify |
+// that user home dir. |
+static std::string primary_user_id_hash; |
+ |
+bool IsUserLoggedIn() { |
+ return is_user_logged_in; |
+} |
+#endif |
+ |
} // namespace |
FilePath MakeAbsoluteFilePath(const FilePath& input) { |
@@ -484,8 +499,14 @@ bool GetShmemTempDir(bool executable, FilePath* path) { |
#if !defined(OS_MACOSX) // Mac implementation is in file_util_mac.mm. |
FilePath GetHomeDir() { |
#if defined(OS_CHROMEOS) |
- if (SysInfo::IsRunningOnChromeOS()) |
- return FilePath("/home/chronos/user"); |
+ if (SysInfo::IsRunningOnChromeOS()) { |
+ if (IsUserLoggedIn()) { |
+ return FilePath("/home/chronos/u-" + primary_user_id_hash); |
+ } else { |
+ NOTREACHED() << "Called GetHomeDir() when not logged in."; |
+ return FilePath("/home/chronos/user"); |
+ } |
+ } |
#endif |
const char* home_dir = getenv("HOME"); |
@@ -515,6 +536,16 @@ FilePath GetHomeDir() { |
} |
#endif // !defined(OS_MACOSX) |
+#if defined(OS_CHROMEOS) |
+void SetUserLoggedIn(bool logged_in) { |
+ is_user_logged_in = logged_in; |
+} |
+ |
+void SetPrimaryUserIdHash(std::string user_id_hash) { |
+ primary_user_id_hash = user_id_hash; |
+} |
+#endif |
+ |
bool CreateTemporaryFile(FilePath* path) { |
ThreadRestrictions::AssertIOAllowed(); // For call to close(). |
FilePath directory; |