// 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

// 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[] = "DEVICETYPE";
}

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

Use the correct lsb key when fetching the CrOS device type.
Use the correct lsb key when fetching the CrOS device type.

This fixes a typo where the wrong key was used. The data is exposed under
a different key.

BUG=341356

Review URL: https://codereview.chromium.org/1220253007

Cr-Commit-Position: 972c6d2dc6dd5efdad1377c0d224e03eb8f276f7@{#337452}
