Chromium Code Reviews| Index: chrome/browser/policy/device_policy_identity_strategy.cc |
| diff --git a/chrome/browser/policy/device_policy_identity_strategy.cc b/chrome/browser/policy/device_policy_identity_strategy.cc |
| index 0f199450979ed41f9364aa4a4d5e92c9e96628b3..51e281343ae8e38abe5dcd45682fa05f23b3aa17 100644 |
| --- a/chrome/browser/policy/device_policy_identity_strategy.cc |
| +++ b/chrome/browser/policy/device_policy_identity_strategy.cc |
| @@ -8,14 +8,26 @@ |
| #include "chrome/browser/chromeos/login/ownership_service.h" |
| #include "chrome/browser/chromeos/login/user_manager.h" |
| #include "chrome/browser/net/gaia/token_service.h" |
| +#include "chrome/browser/policy/proto/device_management_constants.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/profiles/profile_manager.h" |
| +#include "chrome/common/guid.h" |
| #include "chrome/common/net/gaia/gaia_constants.h" |
| #include "chrome/common/notification_service.h" |
| #include "chrome/common/notification_type.h" |
| +#if defined(OS_CHROMEOS) |
|
Mattias Nissler (ping if slow)
2011/02/21 14:55:27
Not needed, this file is on compiled on CrOS
gfeher
2011/02/22 15:57:29
Done.
|
| +#include "chrome/browser/chromeos/cros/cros_library.h" |
| +#include "chrome/browser/chromeos/cros/system_library.h" |
| +#endif |
| + |
| namespace policy { |
| +namespace { |
| + // Key name for MachineInfo. |
| + const char kMachineInfoSerialNumber[] = "serial_number"; |
| +} |
| + |
| DevicePolicyIdentityStrategy::DevicePolicyIdentityStrategy() |
| : should_register_(false) { |
| registrar_.Add(this, |
| @@ -31,8 +43,17 @@ DevicePolicyIdentityStrategy::DevicePolicyIdentityStrategy() |
| NotificationType::OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED, |
| NotificationService::AllSources()); |
| - // TODO(mnissler): Figure out how to read the machine id. |
| - machine_id_ = "dummy-cros-machine-ID"; |
| + machine_id_ = "unknown-cros-machine-ID"; |
| +#if defined(OS_CHROMEOS) |
| + chromeos::SystemLibrary* sys_lib = |
| + chromeos::CrosLibrary::Get()->GetSystemLibrary(); |
|
Mattias Nissler (ping if slow)
2011/02/21 14:55:27
Nice!
But I've heard rumors about the serial numb
gfeher
2011/02/22 15:57:29
I am still fighting with ChromeOS build to make a
|
| + |
| + // Required info. |
| + std::string serial_number; |
| + if (!sys_lib->GetMachineStatistic(kMachineInfoSerialNumber, &machine_id_)) { |
| + LOG(WARNING) << "Failed to get machine serial number." << std::endl; |
| + } |
| +#endif |
| } |
| std::string DevicePolicyIdentityStrategy::GetDeviceToken() { |
| @@ -43,6 +64,19 @@ std::string DevicePolicyIdentityStrategy::GetDeviceID() { |
| return machine_id_; |
|
Jakob Kummerow
2011/02/21 16:15:00
s/machine_id_/device_id_/ ?
gfeher
2011/02/22 15:57:29
Whoops!
|
| } |
| +std::string DevicePolicyIdentityStrategy::GetMachineID() { |
| + return machine_id_; |
| +} |
| + |
| +em::DeviceRegisterRequest_Type |
| +DevicePolicyIdentityStrategy::GetPolicyRegisterType() { |
| + return em::DeviceRegisterRequest::DEVICE; |
| +} |
| + |
| +std::string DevicePolicyIdentityStrategy::GetPolicyType() { |
| + return kChromeDevicePolicyType; |
| +} |
| + |
| bool DevicePolicyIdentityStrategy::GetCredentials(std::string* username, |
| std::string* auth_token) { |
| // Only register if requested. |
| @@ -86,8 +120,10 @@ void DevicePolicyIdentityStrategy::OnDeviceTokenAvailable( |
| void DevicePolicyIdentityStrategy::CheckAndTriggerFetch() { |
| std::string username; |
| std::string auth_token; |
| - if (GetCredentials(&username, &auth_token)) |
| + if (GetCredentials(&username, &auth_token)) { |
| + device_id_ = guid::GenerateGUID(); |
| NotifyAuthChanged(); |
| + } |
| } |
| void DevicePolicyIdentityStrategy::Observe(NotificationType type, |