OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/policy_ui.h" | 5 #include "chrome/browser/ui/webui/policy_ui.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 source->AddLocalizedString("title", IDS_POLICY_TITLE); | 87 source->AddLocalizedString("title", IDS_POLICY_TITLE); |
88 source->AddLocalizedString("filterPlaceholder", | 88 source->AddLocalizedString("filterPlaceholder", |
89 IDS_POLICY_FILTER_PLACEHOLDER); | 89 IDS_POLICY_FILTER_PLACEHOLDER); |
90 source->AddLocalizedString("reloadPolicies", IDS_POLICY_RELOAD_POLICIES); | 90 source->AddLocalizedString("reloadPolicies", IDS_POLICY_RELOAD_POLICIES); |
91 source->AddLocalizedString("status", IDS_POLICY_STATUS); | 91 source->AddLocalizedString("status", IDS_POLICY_STATUS); |
92 source->AddLocalizedString("statusDevice", IDS_POLICY_STATUS_DEVICE); | 92 source->AddLocalizedString("statusDevice", IDS_POLICY_STATUS_DEVICE); |
93 source->AddLocalizedString("statusUser", IDS_POLICY_STATUS_USER); | 93 source->AddLocalizedString("statusUser", IDS_POLICY_STATUS_USER); |
94 source->AddLocalizedString("labelDomain", IDS_POLICY_LABEL_DOMAIN); | 94 source->AddLocalizedString("labelDomain", IDS_POLICY_LABEL_DOMAIN); |
95 source->AddLocalizedString("labelUsername", IDS_POLICY_LABEL_USERNAME); | 95 source->AddLocalizedString("labelUsername", IDS_POLICY_LABEL_USERNAME); |
96 source->AddLocalizedString("labelClientId", IDS_POLICY_LABEL_CLIENT_ID); | 96 source->AddLocalizedString("labelClientId", IDS_POLICY_LABEL_CLIENT_ID); |
| 97 source->AddLocalizedString("labelAssetId", IDS_POLICY_LABEL_ASSET_ID); |
| 98 source->AddLocalizedString("labelLocation", IDS_POLICY_LABEL_LOCATION); |
| 99 source->AddLocalizedString("labelDirectoryApiId", |
| 100 IDS_POLICY_LABEL_DIRECTORY_API_ID); |
97 source->AddLocalizedString("labelTimeSinceLastRefresh", | 101 source->AddLocalizedString("labelTimeSinceLastRefresh", |
98 IDS_POLICY_LABEL_TIME_SINCE_LAST_REFRESH); | 102 IDS_POLICY_LABEL_TIME_SINCE_LAST_REFRESH); |
99 source->AddLocalizedString("labelRefreshInterval", | 103 source->AddLocalizedString("labelRefreshInterval", |
100 IDS_POLICY_LABEL_REFRESH_INTERVAL); | 104 IDS_POLICY_LABEL_REFRESH_INTERVAL); |
101 source->AddLocalizedString("labelStatus", IDS_POLICY_LABEL_STATUS); | 105 source->AddLocalizedString("labelStatus", IDS_POLICY_LABEL_STATUS); |
102 source->AddLocalizedString("showUnset", IDS_POLICY_SHOW_UNSET); | 106 source->AddLocalizedString("showUnset", IDS_POLICY_SHOW_UNSET); |
103 source->AddLocalizedString("noPoliciesSet", IDS_POLICY_NO_POLICIES_SET); | 107 source->AddLocalizedString("noPoliciesSet", IDS_POLICY_NO_POLICIES_SET); |
104 source->AddLocalizedString("headerScope", IDS_POLICY_HEADER_SCOPE); | 108 source->AddLocalizedString("headerScope", IDS_POLICY_HEADER_SCOPE); |
105 source->AddLocalizedString("headerLevel", IDS_POLICY_HEADER_LEVEL); | 109 source->AddLocalizedString("headerLevel", IDS_POLICY_HEADER_LEVEL); |
106 source->AddLocalizedString("headerName", IDS_POLICY_HEADER_NAME); | 110 source->AddLocalizedString("headerName", IDS_POLICY_HEADER_NAME); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 if (store->status() == policy::CloudPolicyStore::STATUS_OK) { | 169 if (store->status() == policy::CloudPolicyStore::STATUS_OK) { |
166 if (client && client->status() != policy::DM_STATUS_SUCCESS) | 170 if (client && client->status() != policy::DM_STATUS_SUCCESS) |
167 status = policy::FormatDeviceManagementStatus(client->status()); | 171 status = policy::FormatDeviceManagementStatus(client->status()); |
168 else if (!store->is_managed()) | 172 else if (!store->is_managed()) |
169 status = FormatAssociationState(store->policy()); | 173 status = FormatAssociationState(store->policy()); |
170 } | 174 } |
171 | 175 |
172 const em::PolicyData* policy = store->policy(); | 176 const em::PolicyData* policy = store->policy(); |
173 std::string client_id = policy ? policy->device_id() : std::string(); | 177 std::string client_id = policy ? policy->device_id() : std::string(); |
174 std::string username = policy ? policy->username() : std::string(); | 178 std::string username = policy ? policy->username() : std::string(); |
| 179 std::string asset_id = (policy && policy->has_annotated_asset_id()) ? |
| 180 policy->annotated_asset_id() : std::string("Not Specified"); |
| 181 std::string location = (policy && policy->has_annotated_location()) ? |
| 182 policy->annotated_location() : std::string("Not Specified"); |
| 183 std::string directory_api_id = (policy && policy->has_directory_api_id()) ? |
| 184 policy->directory_api_id() : std::string("Not Specified"); |
175 base::TimeDelta refresh_interval = | 185 base::TimeDelta refresh_interval = |
176 base::TimeDelta::FromMilliseconds(refresh_scheduler ? | 186 base::TimeDelta::FromMilliseconds(refresh_scheduler ? |
177 refresh_scheduler->refresh_delay() : | 187 refresh_scheduler->refresh_delay() : |
178 policy::CloudPolicyRefreshScheduler::kDefaultRefreshDelayMs); | 188 policy::CloudPolicyRefreshScheduler::kDefaultRefreshDelayMs); |
179 base::Time last_refresh_time = refresh_scheduler ? | 189 base::Time last_refresh_time = refresh_scheduler ? |
180 refresh_scheduler->last_refresh() : base::Time(); | 190 refresh_scheduler->last_refresh() : base::Time(); |
181 | 191 |
182 bool no_error = store->status() == policy::CloudPolicyStore::STATUS_OK && | 192 bool no_error = store->status() == policy::CloudPolicyStore::STATUS_OK && |
183 client && client->status() == policy::DM_STATUS_SUCCESS; | 193 client && client->status() == policy::DM_STATUS_SUCCESS; |
184 dict->SetBoolean("error", !no_error); | 194 dict->SetBoolean("error", !no_error); |
185 dict->SetString("status", status); | 195 dict->SetString("status", status); |
186 dict->SetString("clientId", client_id); | 196 dict->SetString("clientId", client_id); |
187 dict->SetString("username", username); | 197 dict->SetString("username", username); |
| 198 dict->SetString("assetId", asset_id); |
| 199 dict->SetString("location", location); |
| 200 dict->SetString("directoryApiId", directory_api_id); |
188 dict->SetString("refreshInterval", | 201 dict->SetString("refreshInterval", |
189 ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_DURATION, | 202 ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_DURATION, |
190 ui::TimeFormat::LENGTH_SHORT, | 203 ui::TimeFormat::LENGTH_SHORT, |
191 refresh_interval)); | 204 refresh_interval)); |
192 dict->SetString("timeSinceLastRefresh", last_refresh_time.is_null() ? | 205 dict->SetString("timeSinceLastRefresh", last_refresh_time.is_null() ? |
193 l10n_util::GetStringUTF16(IDS_POLICY_NEVER_FETCHED) : | 206 l10n_util::GetStringUTF16(IDS_POLICY_NEVER_FETCHED) : |
194 ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_ELAPSED, | 207 ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_ELAPSED, |
195 ui::TimeFormat::LENGTH_SHORT, | 208 ui::TimeFormat::LENGTH_SHORT, |
196 base::Time::NowFromSystemTime() - | 209 base::Time::NowFromSystemTime() - |
197 last_refresh_time)); | 210 last_refresh_time)); |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 } | 798 } |
786 | 799 |
787 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 800 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
788 web_ui->AddMessageHandler(new PolicyUIHandler); | 801 web_ui->AddMessageHandler(new PolicyUIHandler); |
789 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), | 802 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), |
790 CreatePolicyUIHTMLSource()); | 803 CreatePolicyUIHTMLSource()); |
791 } | 804 } |
792 | 805 |
793 PolicyUI::~PolicyUI() { | 806 PolicyUI::~PolicyUI() { |
794 } | 807 } |
OLD | NEW |