summaryrefslogtreecommitdiffstats
path: root/chromeos
diff options
context:
space:
mode:
authorjdufault <jdufault@chromium.org>2015-06-25 17:07:19 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-26 00:08:08 +0000
commit15dbc8fe928b3ab054261109c023595c24d151d1 (patch)
tree5ae6a655b49e6164d0dacfa978c6bb3d9d94597b /chromeos
parentfd78e00559a09b91995e5c7df0d34e5ff8173a3d (diff)
downloadchromium_src-15dbc8fe928b3ab054261109c023595c24d151d1.zip
chromium_src-15dbc8fe928b3ab054261109c023595c24d151d1.tar.gz
chromium_src-15dbc8fe928b3ab054261109c023595c24d151d1.tar.bz2
Add a method that determines the type of ChromeOS device we are running on.
Currently, this is used for specifying the device type in localization messages. For more context regarding this, see: - https://codereview.chromium.org/1206063002 This CL replaces an existing utility method of a similar nature with a more robust implementation. The old utility method is removed in the following CL: - https://codereview.chromium.org/1164393003 This method is used for the following two CL's. Note that it may make sense to define a common GetDeviceNameAsASCII or some style of method, since both of the callers implement one. - https://codereview.chromium.org/1203263003 - https://codereview.chromium.org/1204093003 BUG=341356 Review URL: https://codereview.chromium.org/1204783005 Cr-Commit-Position: refs/heads/master@{#336300}
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/chromeos.gyp2
-rw-r--r--chromeos/system/devicetype.cc37
-rw-r--r--chromeos/system/devicetype.h25
3 files changed, 64 insertions, 0 deletions
diff --git a/chromeos/chromeos.gyp b/chromeos/chromeos.gyp
index d11f212..7179621 100644
--- a/chromeos/chromeos.gyp
+++ b/chromeos/chromeos.gyp
@@ -445,6 +445,8 @@
'settings/timezone_settings.h',
'settings/timezone_settings_helper.cc',
'settings/timezone_settings_helper.h',
+ 'system/devicetype.cc',
+ 'system/devicetype.h',
'system/name_value_pairs_parser.cc',
'system/name_value_pairs_parser.h',
'system/statistics_provider.cc',
diff --git a/chromeos/system/devicetype.cc b/chromeos/system/devicetype.cc
new file mode 100644
index 0000000..c99ddf4
--- /dev/null
+++ b/chromeos/system/devicetype.cc
@@ -0,0 +1,37 @@
+// Copyright 2015 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 "chromeos/system/devicetype.h"
+
+#include <string>
+
+#include "base/sys_info.h"
+
+namespace chromeos {
+
+namespace {
+const char kDeviceType[] = "CHROMEOS_DEVICE_TYPE";
+}
+
+DeviceType GetDeviceType() {
+ std::string value;
+ if (base::SysInfo::GetLsbReleaseValue(kDeviceType, &value)) {
+ if (value == "CHROMEBASE")
+ return DeviceType::kChromebase;
+ else if (value == "CHROMEBIT")
+ return DeviceType::kChromebit;
+ // Most devices are Chromebooks, so we will also consider reference boards
+ // as chromebooks.
+ else if (value == "CHROMEBOOK" || value == "REFERENCE")
+ return DeviceType::kChromebook;
+ else if (value == "CHROMEBOX")
+ return DeviceType::kChromebox;
+ else
+ LOG(ERROR) << "Unknown device type \"" << value << "\"";
+ }
+
+ return DeviceType::kUnknown;
+}
+
+} // namespace chromeos
diff --git a/chromeos/system/devicetype.h b/chromeos/system/devicetype.h
new file mode 100644
index 0000000..f0a610c
--- /dev/null
+++ b/chromeos/system/devicetype.h
@@ -0,0 +1,25 @@
+// Copyright 2015 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 CHROMEOS_SYSTEM_DEVICETYPE_H_
+#define CHROMEOS_SYSTEM_DEVICETYPE_H_
+
+#include "chromeos/chromeos_export.h"
+
+namespace chromeos {
+
+enum class DeviceType {
+ kChromebase,
+ kChromebit,
+ kChromebook,
+ kChromebox,
+ kUnknown, // Unknown fallback device.
+};
+
+// Returns the current device type, eg, Chromebook, Chromebox.
+CHROMEOS_EXPORT DeviceType GetDeviceType();
+
+} // namespace chromeos
+
+#endif // CHROMEOS_SYSTEM_DEVICETYPE_H_