Index: chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.cc |
diff --git a/chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.cc b/chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.cc |
index 4814dcdeed2520dd018929e1305f64f2745e3a9d..8f46a4045871d4c3ced4489a9adba59cfa094397 100644 |
--- a/chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.cc |
+++ b/chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.cc |
@@ -8,8 +8,6 @@ |
#include "base/bind_helpers.h" |
#include "base/command_line.h" |
#include "base/port.h" |
-#include "base/prefs/pref_registry_simple.h" |
-#include "base/prefs/pref_service.h" |
#include "base/strings/string_number_conversions.h" |
#include "base/time/time.h" |
#include "chrome/browser/chromeos/attestation/attestation_policy_observer.h" |
@@ -35,10 +33,6 @@ namespace policy { |
namespace { |
-const char kNoRequisition[] = "none"; |
-const char kRemoraRequisition[] = "remora"; |
-const char kSharkRequisition[] = "shark"; |
- |
// These are the machine serial number keys that we check in order until we |
// find a non-empty serial number. The VPD spec says the serial number should be |
// in the "serial_number" key for v2+ VPDs. However, legacy devices used a |
@@ -74,18 +68,6 @@ std::string GetMachineStatistic(const std::string& key) { |
return value; |
} |
-// Gets a machine flag from StatisticsProvider, returns the given |
-// |default_value| if not present. |
-bool GetMachineFlag(const std::string& key, bool default_value) { |
- bool value = default_value; |
- chromeos::system::StatisticsProvider* provider = |
- chromeos::system::StatisticsProvider::GetInstance(); |
- if (!provider->GetMachineFlag(key, &value)) |
- return default_value; |
- |
- return value; |
-} |
- |
// Checks whether forced re-enrollment is enabled. |
bool ForcedReEnrollmentEnabled() { |
return chromeos::AutoEnrollmentController::GetMode() == |
@@ -106,65 +88,13 @@ DeviceCloudPolicyManagerChromeOS::DeviceCloudPolicyManagerChromeOS( |
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)), |
device_store_(store.Pass()), |
- state_keys_broker_(state_keys_broker), |
- local_state_(NULL) { |
-} |
- |
-DeviceCloudPolicyManagerChromeOS::~DeviceCloudPolicyManagerChromeOS() {} |
- |
-void DeviceCloudPolicyManagerChromeOS::Initialize(PrefService* local_state) { |
- CHECK(local_state); |
- |
- local_state_ = local_state; |
- |
+ state_keys_broker_(state_keys_broker) { |
state_keys_update_subscription_ = state_keys_broker_->RegisterUpdateCallback( |
base::Bind(&DeviceCloudPolicyManagerChromeOS::OnStateKeysUpdated, |
base::Unretained(this))); |
- |
- InitializeRequisition(); |
-} |
- |
-std::string DeviceCloudPolicyManagerChromeOS::GetDeviceRequisition() const { |
- std::string requisition; |
- const PrefService::Preference* pref = local_state_->FindPreference( |
- prefs::kDeviceEnrollmentRequisition); |
- if (!pref->IsDefaultValue()) |
- pref->GetValue()->GetAsString(&requisition); |
- |
- if (requisition == kNoRequisition) |
- requisition.clear(); |
- |
- return requisition; |
} |
-void DeviceCloudPolicyManagerChromeOS::SetDeviceRequisition( |
- const std::string& requisition) { |
- VLOG(1) << "SetDeviceRequisition " << requisition; |
- if (local_state_) { |
- if (requisition.empty()) { |
- local_state_->ClearPref(prefs::kDeviceEnrollmentRequisition); |
- local_state_->ClearPref(prefs::kDeviceEnrollmentAutoStart); |
- local_state_->ClearPref(prefs::kDeviceEnrollmentCanExit); |
- } else { |
- local_state_->SetString(prefs::kDeviceEnrollmentRequisition, requisition); |
- if (requisition == kNoRequisition) { |
- local_state_->ClearPref(prefs::kDeviceEnrollmentAutoStart); |
- local_state_->ClearPref(prefs::kDeviceEnrollmentCanExit); |
- } else { |
- local_state_->SetBoolean(prefs::kDeviceEnrollmentAutoStart, true); |
- local_state_->SetBoolean(prefs::kDeviceEnrollmentCanExit, false); |
- } |
- } |
- } |
-} |
- |
-bool DeviceCloudPolicyManagerChromeOS::IsRemoraRequisition() const { |
- return GetDeviceRequisition() == kRemoraRequisition; |
-} |
- |
-bool DeviceCloudPolicyManagerChromeOS::IsSharkRequisition() const { |
- return GetDeviceRequisition() == kSharkRequisition; |
-} |
+DeviceCloudPolicyManagerChromeOS::~DeviceCloudPolicyManagerChromeOS() {} |
void DeviceCloudPolicyManagerChromeOS::Shutdown() { |
state_keys_update_subscription_.reset(); |
@@ -172,16 +102,6 @@ void DeviceCloudPolicyManagerChromeOS::Shutdown() { |
} |
// static |
-void DeviceCloudPolicyManagerChromeOS::RegisterPrefs( |
- PrefRegistrySimple* registry) { |
- registry->RegisterStringPref(prefs::kDeviceEnrollmentRequisition, |
- std::string()); |
- registry->RegisterBooleanPref(prefs::kDeviceEnrollmentAutoStart, false); |
- registry->RegisterBooleanPref(prefs::kDeviceEnrollmentCanExit, true); |
- registry->RegisterDictionaryPref(prefs::kServerBackedDeviceState); |
-} |
- |
-// static |
std::string DeviceCloudPolicyManagerChromeOS::GetMachineID() { |
std::string machine_id; |
chromeos::system::StatisticsProvider* provider = |
@@ -207,7 +127,8 @@ std::string DeviceCloudPolicyManagerChromeOS::GetMachineModel() { |
void DeviceCloudPolicyManagerChromeOS::StartConnection( |
scoped_ptr<CloudPolicyClient> client_to_connect, |
- scoped_ptr<CloudPolicyClient::StatusProvider> device_status_provider) { |
+ scoped_ptr<CloudPolicyClient::StatusProvider> device_status_provider, |
+ PrefService* local_state) { |
CHECK(!service()); |
device_status_provider_ = device_status_provider.Pass(); |
@@ -218,7 +139,7 @@ void DeviceCloudPolicyManagerChromeOS::StartConnection( |
core()->Connect(client_to_connect.Pass()); |
core()->StartRefreshScheduler(); |
- core()->TrackRefreshDelayPref(local_state_, |
+ core()->TrackRefreshDelayPref(local_state, |
prefs::kDevicePolicyRefreshRate); |
attestation_policy_observer_.reset( |
new chromeos::attestation::AttestationPolicyObserver(client())); |
@@ -229,36 +150,4 @@ void DeviceCloudPolicyManagerChromeOS::OnStateKeysUpdated() { |
client()->SetStateKeysToUpload(state_keys_broker_->state_keys()); |
} |
-void DeviceCloudPolicyManagerChromeOS::InitializeRequisition() { |
- // OEM statistics are only loaded when OOBE is not completed. |
- if (chromeos::StartupUtils::IsOobeCompleted()) |
- return; |
- |
- const PrefService::Preference* pref = local_state_->FindPreference( |
- prefs::kDeviceEnrollmentRequisition); |
- if (pref->IsDefaultValue()) { |
- std::string requisition = |
- GetMachineStatistic(chromeos::system::kOemDeviceRequisitionKey); |
- |
- if (!requisition.empty()) { |
- local_state_->SetString(prefs::kDeviceEnrollmentRequisition, |
- requisition); |
- if (requisition == kRemoraRequisition || |
- requisition == kSharkRequisition) { |
- local_state_->SetBoolean(prefs::kDeviceEnrollmentAutoStart, true); |
- local_state_->SetBoolean(prefs::kDeviceEnrollmentCanExit, false); |
- } else { |
- local_state_->SetBoolean( |
- prefs::kDeviceEnrollmentAutoStart, |
- GetMachineFlag(chromeos::system::kOemIsEnterpriseManagedKey, |
- false)); |
- local_state_->SetBoolean( |
- prefs::kDeviceEnrollmentCanExit, |
- GetMachineFlag(chromeos::system::kOemCanExitEnterpriseEnrollmentKey, |
- false)); |
- } |
- } |
- } |
-} |
- |
} // namespace policy |