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

Side by Side Diff: base/chromeos/chromeos_version.cc

Issue 10843041: Add OS_CHROMEOS case in file_util::GetHomeDir() (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « base/chromeos/chromeos_version.h ('k') | chrome/browser/chromeos/gdata/gdata_cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/chromeos/chromeos_version.h" 5 #include "base/chromeos/chromeos_version.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 11
12 namespace base { 12 namespace base {
13 namespace chromeos { 13 namespace chromeos {
14 14
15 bool IsRunningOnChromeOS() { 15 bool IsRunningOnChromeOS() {
16 // Check if the user name is chronos. Note that we don't go with 16 // Check if the user name is chronos. Note that we don't go with
17 // getuid() + getpwuid_r() as it may end up reading /etc/passwd, which 17 // getuid() + getpwuid_r() as it may end up reading /etc/passwd, which
18 // can be expensive. 18 // can be expensive.
19 const char* user = getenv("USER"); 19 const char* user = getenv("USER");
20 return user && strcmp(user, "chronos") == 0; 20 return user && strcmp(user, "chronos") == 0;
21 } 21 }
22 22
23 // Returns the home directory path, or an empty string if the home directory
24 // is not found.
satorux1 2012/08/02 06:09:57 Please remove the comment. we shouldn't repeat her
Haruki Sato 2012/08/02 06:44:13 Done. Thanks.
25 std::string GetHomeDirectory() {
26 if (base::chromeos::IsRunningOnChromeOS())
satorux1 2012/08/02 06:09:57 remove base::chromeos::
Haruki Sato 2012/08/02 06:44:13 Done. Thanks.
27 return "/home/chronos/user";
28
29 const char* home = getenv("HOME");
30 if (home)
31 return home;
32 return "";
33 }
34
23 } // namespace chromeos 35 } // namespace chromeos
24 } // namespace base 36 } // namespace base
OLDNEW
« no previous file with comments | « base/chromeos/chromeos_version.h ('k') | chrome/browser/chromeos/gdata/gdata_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698