Commit 63735786 authored by mnissler@chromium.org's avatar mnissler@chromium.org

Add a new AssociationState DEPROVISIONED for cloud policy.

This adds a new enum value to Policy.AssociationState, indicating that
the server side dropped the client from management. The association
state is now also surfaced in the Status line in about:policy.

BUG=chromium:329834

Review URL: https://codereview.chromium.org/117253002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242099 0039d316-1c4b-4281-b951-d872f2087c98
parent d2dc9572
...@@ -229,6 +229,8 @@ message PolicyData { ...@@ -229,6 +229,8 @@ message PolicyData {
ACTIVE = 0; ACTIVE = 0;
// Association is alive, but the corresponding domain is not managed. // Association is alive, but the corresponding domain is not managed.
UNMANAGED = 1; UNMANAGED = 1;
// Client got dropped on the server side.
DEPROVISIONED = 2;
} }
optional AssociationState state = 9 [default = ACTIVE]; optional AssociationState state = 9 [default = ACTIVE];
......
...@@ -130,6 +130,27 @@ content::WebUIDataSource* CreatePolicyUIHTMLSource() { ...@@ -130,6 +130,27 @@ content::WebUIDataSource* CreatePolicyUIHTMLSource() {
return source; return source;
} }
// Formats the association state indicated by |data|. If |data| is NULL, the
// state is considered to be UNMANAGED.
base::string16 FormatAssociationState(const em::PolicyData* data) {
if (data) {
switch (data->state()) {
case em::PolicyData::ACTIVE:
return l10n_util::GetStringUTF16(IDS_POLICY_ASSOCIATION_STATE_ACTIVE);
case em::PolicyData::UNMANAGED:
return l10n_util::GetStringUTF16(
IDS_POLICY_ASSOCIATION_STATE_UNMANAGED);
case em::PolicyData::DEPROVISIONED:
return l10n_util::GetStringUTF16(
IDS_POLICY_ASSOCIATION_STATE_DEPROVISIONED);
}
NOTREACHED() << "Unknown state " << data->state();
}
// Default to UNMANAGED for the case of missing policy or bad state enum.
return l10n_util::GetStringUTF16(IDS_POLICY_ASSOCIATION_STATE_UNMANAGED);
}
void GetStatusFromCore(const policy::CloudPolicyCore* core, void GetStatusFromCore(const policy::CloudPolicyCore* core,
base::DictionaryValue* dict) { base::DictionaryValue* dict) {
const policy::CloudPolicyStore* store = core->store(); const policy::CloudPolicyStore* store = core->store();
...@@ -137,14 +158,18 @@ void GetStatusFromCore(const policy::CloudPolicyCore* core, ...@@ -137,14 +158,18 @@ void GetStatusFromCore(const policy::CloudPolicyCore* core,
const policy::CloudPolicyRefreshScheduler* refresh_scheduler = const policy::CloudPolicyRefreshScheduler* refresh_scheduler =
core->refresh_scheduler(); core->refresh_scheduler();
bool no_error = store->status() == policy::CloudPolicyStore::STATUS_OK && // CloudPolicyStore errors take precedence to show in the status message.
client && client->status() == policy::DM_STATUS_SUCCESS; // Other errors (such as transient policy fetching problems) get displayed
// only if CloudPolicyStore is in STATUS_OK.
base::string16 status = base::string16 status =
store->status() == policy::CloudPolicyStore::STATUS_OK && policy::FormatStoreStatus(store->status(), store->validation_status());
client && client->status() != policy::DM_STATUS_SUCCESS ? if (store->status() == policy::CloudPolicyStore::STATUS_OK) {
policy::FormatDeviceManagementStatus(client->status()) : if (client && client->status() != policy::DM_STATUS_SUCCESS)
policy::FormatStoreStatus(store->status(), status = policy::FormatDeviceManagementStatus(client->status());
store->validation_status()); else if (!store->is_managed())
status = FormatAssociationState(store->policy());
}
const em::PolicyData* policy = store->policy(); const em::PolicyData* policy = store->policy();
std::string client_id = policy ? policy->device_id() : std::string(); std::string client_id = policy ? policy->device_id() : std::string();
std::string username = policy ? policy->username() : std::string(); std::string username = policy ? policy->username() : std::string();
...@@ -155,6 +180,8 @@ void GetStatusFromCore(const policy::CloudPolicyCore* core, ...@@ -155,6 +180,8 @@ void GetStatusFromCore(const policy::CloudPolicyCore* core,
base::Time last_refresh_time = refresh_scheduler ? base::Time last_refresh_time = refresh_scheduler ?
refresh_scheduler->last_refresh() : base::Time(); refresh_scheduler->last_refresh() : base::Time();
bool no_error = store->status() == policy::CloudPolicyStore::STATUS_OK &&
client && client->status() == policy::DM_STATUS_SUCCESS;
dict->SetBoolean("error", !no_error); dict->SetBoolean("error", !no_error);
dict->SetString("status", status); dict->SetString("status", status);
dict->SetString("clientId", client_id); dict->SetString("clientId", client_id);
......
...@@ -229,6 +229,8 @@ message PolicyData { ...@@ -229,6 +229,8 @@ message PolicyData {
ACTIVE = 0; ACTIVE = 0;
// Association is alive, but the corresponding domain is not managed. // Association is alive, but the corresponding domain is not managed.
UNMANAGED = 1; UNMANAGED = 1;
// Client got dropped on the server side.
DEPROVISIONED = 2;
} }
optional AssociationState state = 9 [default = ACTIVE]; optional AssociationState state = 9 [default = ACTIVE];
......
...@@ -112,6 +112,16 @@ ...@@ -112,6 +112,16 @@
Unknown error Unknown error
</message> </message>
<message name="IDS_POLICY_ASSOCIATION_STATE_ACTIVE" desc="Message indicating that the server actively manages the client.">
Active
</message>
<message name="IDS_POLICY_ASSOCIATION_STATE_UNMANAGED" desc="Message indicating that the server is currently not willing to manage this client.">
Unmanaged
</message>
<message name="IDS_POLICY_ASSOCIATION_STATE_DEPROVISIONED" desc="Message indicating that the server has deprovisioned the client.">
Deprovisioned
</message>
<message name="IDS_POLICY_TYPE_ERROR" desc="The text displayed in the status column when a policy value has the wrong type."> <message name="IDS_POLICY_TYPE_ERROR" desc="The text displayed in the status column when a policy value has the wrong type.">
Expected <ph name="VALUE_TYPE">$1<ex>boolean</ex></ph> value. Expected <ph name="VALUE_TYPE">$1<ex>boolean</ex></ph> value.
</message> </message>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment