1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/policy/device_management_service_configuration.h"
7 #include "base/basictypes.h"
8 #include "base/logging.h"
9 #include "base/strings/stringprintf.h"
10 #include "base/sys_info.h"
11 #include "chrome/common/chrome_version_info.h"
12 #include "components/policy/core/browser/browser_policy_connector.h"
14 #if defined(OS_CHROMEOS)
15 #include "chromeos/system/statistics_provider.h"
20 DeviceManagementServiceConfiguration::DeviceManagementServiceConfiguration(
21 const std::string
& server_url
)
22 : server_url_(server_url
) {
25 DeviceManagementServiceConfiguration::~DeviceManagementServiceConfiguration() {
28 std::string
DeviceManagementServiceConfiguration::GetServerUrl() {
32 std::string
DeviceManagementServiceConfiguration::GetAgentParameter() {
33 chrome::VersionInfo version_info
;
34 return base::StringPrintf("%s %s(%s)",
35 version_info
.Name().c_str(),
36 version_info
.Version().c_str(),
37 version_info
.LastChange().c_str());
40 std::string
DeviceManagementServiceConfiguration::GetPlatformParameter() {
41 std::string os_name
= base::SysInfo::OperatingSystemName();
42 std::string os_hardware
= base::SysInfo::OperatingSystemArchitecture();
44 #if defined(OS_CHROMEOS)
45 chromeos::system::StatisticsProvider
* provider
=
46 chromeos::system::StatisticsProvider::GetInstance();
49 if (!provider
->GetMachineStatistic(chromeos::system::kHardwareClassKey
,
51 LOG(ERROR
) << "Failed to get machine information";
53 os_name
+= ",CrOS," + base::SysInfo::GetLsbReleaseBoard();
54 os_hardware
+= "," + hwclass
;
57 std::string
os_version("-");
58 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS)
59 int32 os_major_version
= 0;
60 int32 os_minor_version
= 0;
61 int32 os_bugfix_version
= 0;
62 base::SysInfo::OperatingSystemVersionNumbers(&os_major_version
,
65 os_version
= base::StringPrintf("%d.%d.%d",
71 return base::StringPrintf(
72 "%s|%s|%s", os_name
.c_str(), os_hardware
.c_str(), os_version
.c_str());