Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / policy / device_management_service_configuration.cc
blobd5de4f0aba758a2f20fbfc070e3d72299c753c90
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"
16 #endif
18 namespace policy {
20 DeviceManagementServiceConfiguration::DeviceManagementServiceConfiguration(
21 const std::string& server_url)
22 : server_url_(server_url) {
25 DeviceManagementServiceConfiguration::~DeviceManagementServiceConfiguration() {
28 std::string DeviceManagementServiceConfiguration::GetServerUrl() {
29 return server_url_;
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();
48 std::string hwclass;
49 if (!provider->GetMachineStatistic(chromeos::system::kHardwareClassKey,
50 &hwclass)) {
51 LOG(ERROR) << "Failed to get machine information";
53 os_name += ",CrOS," + base::SysInfo::GetLsbReleaseBoard();
54 os_hardware += "," + hwclass;
55 #endif
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,
63 &os_minor_version,
64 &os_bugfix_version);
65 os_version = base::StringPrintf("%d.%d.%d",
66 os_major_version,
67 os_minor_version,
68 os_bugfix_version);
69 #endif
71 return base::StringPrintf(
72 "%s|%s|%s", os_name.c_str(), os_hardware.c_str(), os_version.c_str());
75 } // namespace policy