diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-16 23:01:02 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-16 23:01:02 +0000 |
commit | 20d2a79d81c4e546c68ff40c3f2e52d81410f886 (patch) | |
tree | fc6c66f5a4af6fa4d1d8cb5b13d0e73d4fce2f4b /base | |
parent | 4cbf2000973c9ab04238399f02d95c25c5c0c2a4 (diff) | |
download | chromium_src-20d2a79d81c4e546c68ff40c3f2e52d81410f886.zip chromium_src-20d2a79d81c4e546c68ff40c3f2e52d81410f886.tar.gz chromium_src-20d2a79d81c4e546c68ff40c3f2e52d81410f886.tar.bz2 |
Move IsRunningOnChromeOS to base/chromeos so that ui/, /chromeos and other components can use it.
plus, a couple of cleanups including
- removed unnecessary includes
- removed unnecessary ifdef chromeos in chromeos only code.
BUG=115967
TEST=none
Review URL: http://codereview.chromium.org/9546013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127283 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/base.gypi | 7 | ||||
-rw-r--r-- | base/chromeos/chromeos_version.cc | 24 | ||||
-rw-r--r-- | base/chromeos/chromeos_version.h | 21 |
3 files changed, 52 insertions, 0 deletions
diff --git a/base/base.gypi b/base/base.gypi index c4df5b7..0c556f19 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -62,6 +62,8 @@ 'callback_internal.cc', 'callback_internal.h', 'cancelable_callback.h', + 'chromeos/chromeos_version.cc', + 'chromeos/chromeos_version.h', 'command_line.cc', 'command_line.h', 'compiler_specific.h', @@ -549,6 +551,11 @@ ['exclude', '^sys_info_linux\\.cc$'], ], }], + [ 'chromeos != 1', { + 'sources/': [ + ['exclude', '^chromeos/'], + ], + }], ], }], ], diff --git a/base/chromeos/chromeos_version.cc b/base/chromeos/chromeos_version.cc new file mode 100644 index 0000000..4a70cd5 --- /dev/null +++ b/base/chromeos/chromeos_version.cc @@ -0,0 +1,24 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/chromeos/chromeos_version.h" + +#include <stdlib.h> +#include <string.h> + +#include "base/logging.h" + +namespace base { +namespace chromeos { + +bool IsRunningOnChromeOS() { + // Check if the user name is chronos. Note that we don't go with + // getuid() + getpwuid_r() as it may end up reading /etc/passwd, which + // can be expensive. + const char* user = getenv("USER"); + return user && strcmp(user, "chronos") == 0; +} + +} // namespace chromeos +} // namespace base diff --git a/base/chromeos/chromeos_version.h b/base/chromeos/chromeos_version.h new file mode 100644 index 0000000..fc4b242 --- /dev/null +++ b/base/chromeos/chromeos_version.h @@ -0,0 +1,21 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BASE_CHROMEOS_CHROMEOS_VERSION_H_ +#define BASE_CHROMEOS_CHROMEOS_VERSION_H_ +#pragma once + +#include "base/base_export.h" + +namespace base { +namespace chromeos { + +// Returns true if the browser is running on Chrome OS. +// Useful for implementing stubs for Linux desktop. +BASE_EXPORT bool IsRunningOnChromeOS(); + +} // namespace chromeos +} // namespace base + +#endif // BASE_CHROMEOS_CHROMEOS_VERSION_H_ |