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

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

Issue 147443007: Add support for localized time strings with two units, eg. "2 hours 17 minutes" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Tony's comments Created 6 years, 9 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/foreign_session_handler.cc ('k') | chrome/common/time_format_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698