Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5948)

Unified Diff: chrome/browser/policy/browser_policy_connector.cc

Issue 8872032: Added the AutoEnrollmentClient and unit tests for it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Style cleanup, rebased Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/policy/browser_policy_connector.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/policy/browser_policy_connector.cc
diff --git a/chrome/browser/policy/browser_policy_connector.cc b/chrome/browser/policy/browser_policy_connector.cc
index 17decb07f6036b7c5d2c8e126b6575d08c4d0edc..6d547a080f5c432306944e3b88786f8eacd79ed1 100644
--- a/chrome/browser/policy/browser_policy_connector.cc
+++ b/chrome/browser/policy/browser_policy_connector.cc
@@ -69,7 +69,7 @@ const char kMachineInfoSystemHwqual[] = "hardware_class";
// in the "serial_number" key for v2+ VPDs. However, we cannot check this first,
// since we'd get the "serial_number" value from the SMBIOS (yes, there's a name
// clash here!), which is different from the serial number we want and not
-// actually per-device. So, we check the the legacy keys first. If we find a
+// actually per-device. So, we check the legacy keys first. If we find a
// serial number for these, we use it, otherwise we must be on a newer device
// that provides the correct data in "serial_number".
const char* kMachineInfoSerialNumberKeys[] = {
@@ -155,22 +155,16 @@ void BrowserPolicyConnector::RegisterForDevicePolicy(
if (device_data_store_.get()) {
if (device_data_store_->machine_id().empty() ||
device_data_store_->machine_model().empty()) {
- std::string machine_id;
- std::string machine_model;
chromeos::system::StatisticsProvider* provider =
chromeos::system::StatisticsProvider::GetInstance();
+
+ std::string machine_model;
if (!provider->GetMachineStatistic(kMachineInfoSystemHwqual,
&machine_model)) {
LOG(ERROR) << "Failed to get machine model.";
}
- for (size_t i = 0; i < arraysize(kMachineInfoSerialNumberKeys); i++) {
- if (provider->GetMachineStatistic(kMachineInfoSerialNumberKeys[i],
- &machine_id) &&
- !machine_id.empty()) {
- break;
- }
- }
+ std::string machine_id = GetSerialNumber();
if (machine_id.empty())
LOG(ERROR) << "Failed to get machine serial number.";
@@ -210,6 +204,23 @@ EnterpriseInstallAttributes::LockResult
return EnterpriseInstallAttributes::LOCK_BACKEND_ERROR;
}
+// static
+std::string BrowserPolicyConnector::GetSerialNumber() {
+ std::string serial_number;
+#if defined(OS_CHROMEOS)
+ chromeos::system::StatisticsProvider* provider =
+ chromeos::system::StatisticsProvider::GetInstance();
+ for (size_t i = 0; i < arraysize(kMachineInfoSerialNumberKeys); i++) {
+ if (provider->GetMachineStatistic(kMachineInfoSerialNumberKeys[i],
+ &serial_number) &&
+ !serial_number.empty()) {
+ break;
+ }
+ }
+#endif
+ return serial_number;
+}
+
std::string BrowserPolicyConnector::GetEnterpriseDomain() {
#if defined(OS_CHROMEOS)
if (install_attributes_.get())
« no previous file with comments | « chrome/browser/policy/browser_policy_connector.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698