Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: chrome/browser/ui/webui/policy_ui.cc

Issue 1052943002: Added device naming information to chrome://policy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed comments Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 source->AddLocalizedString("title", IDS_POLICY_TITLE); 83 source->AddLocalizedString("title", IDS_POLICY_TITLE);
84 source->AddLocalizedString("filterPlaceholder", 84 source->AddLocalizedString("filterPlaceholder",
85 IDS_POLICY_FILTER_PLACEHOLDER); 85 IDS_POLICY_FILTER_PLACEHOLDER);
86 source->AddLocalizedString("reloadPolicies", IDS_POLICY_RELOAD_POLICIES); 86 source->AddLocalizedString("reloadPolicies", IDS_POLICY_RELOAD_POLICIES);
87 source->AddLocalizedString("status", IDS_POLICY_STATUS); 87 source->AddLocalizedString("status", IDS_POLICY_STATUS);
88 source->AddLocalizedString("statusDevice", IDS_POLICY_STATUS_DEVICE); 88 source->AddLocalizedString("statusDevice", IDS_POLICY_STATUS_DEVICE);
89 source->AddLocalizedString("statusUser", IDS_POLICY_STATUS_USER); 89 source->AddLocalizedString("statusUser", IDS_POLICY_STATUS_USER);
90 source->AddLocalizedString("labelDomain", IDS_POLICY_LABEL_DOMAIN); 90 source->AddLocalizedString("labelDomain", IDS_POLICY_LABEL_DOMAIN);
91 source->AddLocalizedString("labelUsername", IDS_POLICY_LABEL_USERNAME); 91 source->AddLocalizedString("labelUsername", IDS_POLICY_LABEL_USERNAME);
92 source->AddLocalizedString("labelClientId", IDS_POLICY_LABEL_CLIENT_ID); 92 source->AddLocalizedString("labelClientId", IDS_POLICY_LABEL_CLIENT_ID);
93 source->AddLocalizedString("labelAssetId", IDS_POLICY_LABEL_ASSET_ID);
94 source->AddLocalizedString("labelLocation", IDS_POLICY_LABEL_LOCATION);
95 source->AddLocalizedString("labelDirectoryApiId",
96 IDS_POLICY_LABEL_DIRECTORY_API_ID);
93 source->AddLocalizedString("labelTimeSinceLastRefresh", 97 source->AddLocalizedString("labelTimeSinceLastRefresh",
94 IDS_POLICY_LABEL_TIME_SINCE_LAST_REFRESH); 98 IDS_POLICY_LABEL_TIME_SINCE_LAST_REFRESH);
95 source->AddLocalizedString("labelRefreshInterval", 99 source->AddLocalizedString("labelRefreshInterval",
96 IDS_POLICY_LABEL_REFRESH_INTERVAL); 100 IDS_POLICY_LABEL_REFRESH_INTERVAL);
97 source->AddLocalizedString("labelStatus", IDS_POLICY_LABEL_STATUS); 101 source->AddLocalizedString("labelStatus", IDS_POLICY_LABEL_STATUS);
98 source->AddLocalizedString("showUnset", IDS_POLICY_SHOW_UNSET); 102 source->AddLocalizedString("showUnset", IDS_POLICY_SHOW_UNSET);
99 source->AddLocalizedString("noPoliciesSet", IDS_POLICY_NO_POLICIES_SET); 103 source->AddLocalizedString("noPoliciesSet", IDS_POLICY_NO_POLICIES_SET);
100 source->AddLocalizedString("headerScope", IDS_POLICY_HEADER_SCOPE); 104 source->AddLocalizedString("headerScope", IDS_POLICY_HEADER_SCOPE);
101 source->AddLocalizedString("headerLevel", IDS_POLICY_HEADER_LEVEL); 105 source->AddLocalizedString("headerLevel", IDS_POLICY_HEADER_LEVEL);
102 source->AddLocalizedString("headerName", IDS_POLICY_HEADER_NAME); 106 source->AddLocalizedString("headerName", IDS_POLICY_HEADER_NAME);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 if (store->status() == policy::CloudPolicyStore::STATUS_OK) { 165 if (store->status() == policy::CloudPolicyStore::STATUS_OK) {
162 if (client && client->status() != policy::DM_STATUS_SUCCESS) 166 if (client && client->status() != policy::DM_STATUS_SUCCESS)
163 status = policy::FormatDeviceManagementStatus(client->status()); 167 status = policy::FormatDeviceManagementStatus(client->status());
164 else if (!store->is_managed()) 168 else if (!store->is_managed())
165 status = FormatAssociationState(store->policy()); 169 status = FormatAssociationState(store->policy());
166 } 170 }
167 171
168 const em::PolicyData* policy = store->policy(); 172 const em::PolicyData* policy = store->policy();
169 std::string client_id = policy ? policy->device_id() : std::string(); 173 std::string client_id = policy ? policy->device_id() : std::string();
170 std::string username = policy ? policy->username() : std::string(); 174 std::string username = policy ? policy->username() : std::string();
175 std::string asset_id = (policy && policy->has_annotated_asset_id()) ?
176 policy->annotated_asset_id() : std::string("Not Specified");
Nikita (slow) 2015/04/14 13:21:39 This should be a localized string (here and below)
Polina Bondarenko 2015/04/14 16:41:34 Done, but I'm not sure that I fixed it as expected
Nikita (slow) 2015/04/15 09:06:25 Right, this string should be up for translation.
177 std::string location = (policy && policy->has_annotated_location()) ?
178 policy->annotated_location() : std::string("Not Specified");
179 std::string directory_api_id = (policy && policy->has_directory_api_id()) ?
180 policy->directory_api_id() : std::string("Not Specified");
171 base::TimeDelta refresh_interval = 181 base::TimeDelta refresh_interval =
172 base::TimeDelta::FromMilliseconds(refresh_scheduler ? 182 base::TimeDelta::FromMilliseconds(refresh_scheduler ?
173 refresh_scheduler->refresh_delay() : 183 refresh_scheduler->refresh_delay() :
174 policy::CloudPolicyRefreshScheduler::kDefaultRefreshDelayMs); 184 policy::CloudPolicyRefreshScheduler::kDefaultRefreshDelayMs);
175 base::Time last_refresh_time = refresh_scheduler ? 185 base::Time last_refresh_time = refresh_scheduler ?
176 refresh_scheduler->last_refresh() : base::Time(); 186 refresh_scheduler->last_refresh() : base::Time();
177 187
178 bool no_error = store->status() == policy::CloudPolicyStore::STATUS_OK && 188 bool no_error = store->status() == policy::CloudPolicyStore::STATUS_OK &&
179 client && client->status() == policy::DM_STATUS_SUCCESS; 189 client && client->status() == policy::DM_STATUS_SUCCESS;
180 dict->SetBoolean("error", !no_error); 190 dict->SetBoolean("error", !no_error);
181 dict->SetString("status", status); 191 dict->SetString("status", status);
182 dict->SetString("clientId", client_id); 192 dict->SetString("clientId", client_id);
183 dict->SetString("username", username); 193 dict->SetString("username", username);
194 dict->SetString("assetId", asset_id);
195 dict->SetString("location", location);
196 dict->SetString("directoryApiId", directory_api_id);
184 dict->SetString("refreshInterval", 197 dict->SetString("refreshInterval",
185 ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_DURATION, 198 ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_DURATION,
186 ui::TimeFormat::LENGTH_SHORT, 199 ui::TimeFormat::LENGTH_SHORT,
187 refresh_interval)); 200 refresh_interval));
188 dict->SetString("timeSinceLastRefresh", last_refresh_time.is_null() ? 201 dict->SetString("timeSinceLastRefresh", last_refresh_time.is_null() ?
189 l10n_util::GetStringUTF16(IDS_POLICY_NEVER_FETCHED) : 202 l10n_util::GetStringUTF16(IDS_POLICY_NEVER_FETCHED) :
190 ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_ELAPSED, 203 ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_ELAPSED,
191 ui::TimeFormat::LENGTH_SHORT, 204 ui::TimeFormat::LENGTH_SHORT,
192 base::Time::NowFromSystemTime() - 205 base::Time::NowFromSystemTime() -
193 last_refresh_time)); 206 last_refresh_time));
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 } 827 }
815 828
816 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { 829 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) {
817 web_ui->AddMessageHandler(new PolicyUIHandler); 830 web_ui->AddMessageHandler(new PolicyUIHandler);
818 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), 831 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui),
819 CreatePolicyUIHTMLSource()); 832 CreatePolicyUIHTMLSource());
820 } 833 }
821 834
822 PolicyUI::~PolicyUI() { 835 PolicyUI::~PolicyUI() {
823 } 836 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698