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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 base::Time last_refresh_time = refresh_scheduler ? | 181 base::Time last_refresh_time = refresh_scheduler ? |
182 refresh_scheduler->last_refresh() : base::Time(); | 182 refresh_scheduler->last_refresh() : base::Time(); |
183 | 183 |
184 bool no_error = store->status() == policy::CloudPolicyStore::STATUS_OK && | 184 bool no_error = store->status() == policy::CloudPolicyStore::STATUS_OK && |
185 client && client->status() == policy::DM_STATUS_SUCCESS; | 185 client && client->status() == policy::DM_STATUS_SUCCESS; |
186 dict->SetBoolean("error", !no_error); | 186 dict->SetBoolean("error", !no_error); |
187 dict->SetString("status", status); | 187 dict->SetString("status", status); |
188 dict->SetString("clientId", client_id); | 188 dict->SetString("clientId", client_id); |
189 dict->SetString("username", username); | 189 dict->SetString("username", username); |
190 dict->SetString("refreshInterval", | 190 dict->SetString("refreshInterval", |
191 ui::TimeFormat::TimeDurationShort(refresh_interval)); | 191 ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_DURATION, |
| 192 ui::TimeFormat::LENGTH_SHORT, |
| 193 refresh_interval)); |
192 dict->SetString("timeSinceLastRefresh", last_refresh_time.is_null() ? | 194 dict->SetString("timeSinceLastRefresh", last_refresh_time.is_null() ? |
193 l10n_util::GetStringUTF16(IDS_POLICY_NEVER_FETCHED) : | 195 l10n_util::GetStringUTF16(IDS_POLICY_NEVER_FETCHED) : |
194 ui::TimeFormat::TimeElapsed(base::Time::NowFromSystemTime() - | 196 ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_ELAPSED, |
195 last_refresh_time)); | 197 ui::TimeFormat::LENGTH_SHORT, |
| 198 base::Time::NowFromSystemTime() - |
| 199 last_refresh_time)); |
196 } | 200 } |
197 | 201 |
198 void ExtractDomainFromUsername(base::DictionaryValue* dict) { | 202 void ExtractDomainFromUsername(base::DictionaryValue* dict) { |
199 std::string username; | 203 std::string username; |
200 dict->GetString("username", &username); | 204 dict->GetString("username", &username); |
201 if (!username.empty()) | 205 if (!username.empty()) |
202 dict->SetString("domain", gaia::ExtractDomainName(username)); | 206 dict->SetString("domain", gaia::ExtractDomainName(username)); |
203 } | 207 } |
204 | 208 |
205 // Utility function that returns a JSON serialization of the given |dict|. | 209 // Utility function that returns a JSON serialization of the given |dict|. |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 } | 788 } |
785 | 789 |
786 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 790 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
787 web_ui->AddMessageHandler(new PolicyUIHandler); | 791 web_ui->AddMessageHandler(new PolicyUIHandler); |
788 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), | 792 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), |
789 CreatePolicyUIHTMLSource()); | 793 CreatePolicyUIHTMLSource()); |
790 } | 794 } |
791 | 795 |
792 PolicyUI::~PolicyUI() { | 796 PolicyUI::~PolicyUI() { |
793 } | 797 } |
OLD | NEW |