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 "components/policy/core/browser/browser_policy_connector.h"
12 #include "components/version_info/version_info.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 return base::StringPrintf("%s %s(%s)",
34 version_info::GetProductName().c_str(),
35 version_info::GetVersionNumber().c_str(),
36 version_info::GetLastChange().c_str());
39 std::string
DeviceManagementServiceConfiguration::GetPlatformParameter() {
40 std::string os_name
= base::SysInfo::OperatingSystemName();
41 std::string os_hardware
= base::SysInfo::OperatingSystemArchitecture();
43 #if defined(OS_CHROMEOS)
44 chromeos::system::StatisticsProvider
* provider
=
45 chromeos::system::StatisticsProvider::GetInstance();
48 if (!provider
->GetMachineStatistic(chromeos::system::kHardwareClassKey
,
50 LOG(ERROR
) << "Failed to get machine information";
52 os_name
+= ",CrOS," + base::SysInfo::GetLsbReleaseBoard();
53 os_hardware
+= "," + hwclass
;
56 std::string
os_version("-");
57 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS)
58 int32 os_major_version
= 0;
59 int32 os_minor_version
= 0;
60 int32 os_bugfix_version
= 0;
61 base::SysInfo::OperatingSystemVersionNumbers(&os_major_version
,
64 os_version
= base::StringPrintf("%d.%d.%d",
70 return base::StringPrintf(
71 "%s|%s|%s", os_name
.c_str(), os_hardware
.c_str(), os_version
.c_str());