diff options
author | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-10 06:24:52 +0000 |
---|---|---|
committer | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-10 06:24:52 +0000 |
commit | d43970a7ceee5fc5433787b0f28b64234a4039f2 (patch) | |
tree | 0cfd2581dc24c226cab75da6b683458dac540199 /chrome/browser/policy | |
parent | 7237bfcc6ded653b4ae2defaee6f1303b1744ede (diff) | |
download | chromium_src-d43970a7ceee5fc5433787b0f28b64234a4039f2.zip chromium_src-d43970a7ceee5fc5433787b0f28b64234a4039f2.tar.gz chromium_src-d43970a7ceee5fc5433787b0f28b64234a4039f2.tar.bz2 |
Split SystemAccess into TimezoneSettings, StatisticsProvider, and SyslogsProvider.
SystemAccess contained three separate things: timezone settings,
statistics provider, and syslogs provider. We should have them
in separate classes.
This patch touches many files but changes are mechanical. No logic
changes introduced.
BUG=none
TEST=chrome builds and try bots pass
Review URL: http://codereview.chromium.org/7324017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91971 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/policy')
-rw-r--r-- | chrome/browser/policy/cloud_policy_data_store.cc | 13 | ||||
-rw-r--r-- | chrome/browser/policy/device_management_backend_impl.cc | 9 | ||||
-rw-r--r-- | chrome/browser/policy/device_policy_identity_strategy.cc | 106 |
3 files changed, 118 insertions, 10 deletions
diff --git a/chrome/browser/policy/cloud_policy_data_store.cc b/chrome/browser/policy/cloud_policy_data_store.cc index 22d8581..b3d7a84b 100644 --- a/chrome/browser/policy/cloud_policy_data_store.cc +++ b/chrome/browser/policy/cloud_policy_data_store.cc @@ -9,7 +9,7 @@ #include "chrome/browser/policy/proto/device_management_constants.h" #if defined(OS_CHROMEOS) -#include "chrome/browser/chromeos/system_access.h" +#include "chrome/browser/chromeos/system/statistics_provider.h" #endif namespace { @@ -34,13 +34,14 @@ CloudPolicyDataStore* CloudPolicyDataStore::CreateForDevicePolicies() { std::string machine_model; std::string machine_id; #if defined(OS_CHROMEOS) - chromeos::SystemAccess* sys_lib = chromeos::SystemAccess::GetInstance(); - if (!sys_lib->GetMachineStatistic(kMachineInfoSystemHwqual, - &machine_model)) { + chromeos::system::StatisticsProvider* provider = + chromeos::system::StatisticsProvider::GetInstance(); + if (!provider->GetMachineStatistic(kMachineInfoSystemHwqual, + &machine_model)) { LOG(ERROR) << "Failed to get machine model."; } - if (!sys_lib->GetMachineStatistic(kMachineInfoSerialNumber, - &machine_id)) { + if (!provider->GetMachineStatistic(kMachineInfoSerialNumber, + &machine_id)) { LOG(ERROR) << "Failed to get machine serial number."; } #endif diff --git a/chrome/browser/policy/device_management_backend_impl.cc b/chrome/browser/policy/device_management_backend_impl.cc index 7f3850e..0988706 100644 --- a/chrome/browser/policy/device_management_backend_impl.cc +++ b/chrome/browser/policy/device_management_backend_impl.cc @@ -21,7 +21,7 @@ #include "net/url_request/url_request_status.h" #if defined(OS_CHROMEOS) -#include "chrome/browser/chromeos/system_access.h" +#include "chrome/browser/chromeos/system/statistics_provider.h" #endif namespace policy { @@ -460,12 +460,13 @@ std::string DeviceManagementBackendImpl::GetPlatformString() { std::string os_hardware(base::SysInfo::CPUArchitecture()); #if defined(OS_CHROMEOS) - chromeos::SystemAccess* sys_lib = chromeos::SystemAccess::GetInstance(); + chromeos::system::StatisticsProvider* provider = + chromeos::system::StatisticsProvider::GetInstance(); std::string hwclass; std::string board; - if (!sys_lib->GetMachineStatistic(kMachineInfoHWClass, &hwclass) || - !sys_lib->GetMachineStatistic(kMachineInfoBoard, &board)) { + if (!provider->GetMachineStatistic(kMachineInfoHWClass, &hwclass) || + !provider->GetMachineStatistic(kMachineInfoBoard, &board)) { LOG(ERROR) << "Failed to get machine information"; } os_name += ",CrOS," + board; diff --git a/chrome/browser/policy/device_policy_identity_strategy.cc b/chrome/browser/policy/device_policy_identity_strategy.cc new file mode 100644 index 0000000..b0519aa --- /dev/null +++ b/chrome/browser/policy/device_policy_identity_strategy.cc @@ -0,0 +1,106 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/policy/device_policy_identity_strategy.h" + +#include "chrome/browser/browser_process.h" +#include "chrome/browser/chromeos/cros/cros_library.h" +#include "chrome/browser/chromeos/login/ownership_service.h" +#include "chrome/browser/chromeos/login/user_manager.h" +#include "chrome/browser/chromeos/system/statistics_provider.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 "content/common/notification_service.h" +#include "content/common/notification_type.h" + +// MachineInfo key names. +static const char kMachineInfoSystemHwqual[] = "hardware_class"; +static const char kMachineInfoSerialNumber[] = "serial_number"; + +namespace policy { + +DevicePolicyIdentityStrategy::DevicePolicyIdentityStrategy() { + chromeos::system::StatisticsProvider* provider = + chromeos::system::StatisticsProvider::GetInstance(); + + if (!provider->GetMachineStatistic(kMachineInfoSystemHwqual, + &machine_model_)) { + LOG(ERROR) << "Failed to get machine model."; + } + if (!provider->GetMachineStatistic(kMachineInfoSerialNumber, + &machine_id_)) { + LOG(ERROR) << "Failed to get machine serial number."; + } +} + +DevicePolicyIdentityStrategy::~DevicePolicyIdentityStrategy() { +} + +std::string DevicePolicyIdentityStrategy::GetDeviceToken() { + return device_token_; +} + +std::string DevicePolicyIdentityStrategy::GetDeviceID() { + return device_id_; +} + +std::string DevicePolicyIdentityStrategy::GetMachineID() { + return machine_id_; +} + +std::string DevicePolicyIdentityStrategy::GetMachineModel() { + return machine_model_; +} + +em::DeviceRegisterRequest_Type +DevicePolicyIdentityStrategy::GetPolicyRegisterType() { + return em::DeviceRegisterRequest::DEVICE; +} + +std::string DevicePolicyIdentityStrategy::GetPolicyType() { + return kChromeDevicePolicyType; +} + +void DevicePolicyIdentityStrategy::SetAuthCredentials( + const std::string& username, + const std::string& auth_token) { + username_ = username; + auth_token_ = auth_token; + device_id_ = guid::GenerateGUID(); + NotifyAuthChanged(); +} + +void DevicePolicyIdentityStrategy::SetDeviceManagementCredentials( + const std::string& owner_email, + const std::string& device_id, + const std::string& device_token) { + username_ = owner_email; + device_id_ = device_id; + device_token_ = device_token; + NotifyDeviceTokenChanged(); +} + +void DevicePolicyIdentityStrategy::FetchPolicy() { + DCHECK(!device_token_.empty()); + NotifyDeviceTokenChanged(); +} + +bool DevicePolicyIdentityStrategy::GetCredentials(std::string* username, + std::string* auth_token) { + *username = username_; + *auth_token = auth_token_; + + return !username->empty() && !auth_token->empty(); +} + +void DevicePolicyIdentityStrategy::OnDeviceTokenAvailable( + const std::string& token) { + device_token_ = token; +} + +} // namespace policy |