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

Unified Diff: chrome/browser/ui/webui/ntp/ntp_login_handler.cc

Issue 8921008: Follow-up to bug 102685 (r113862) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Refactoring AddCSSClass into a separate method Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/ntp/ntp_login_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/ntp/ntp_login_handler.cc
diff --git a/chrome/browser/ui/webui/ntp/ntp_login_handler.cc b/chrome/browser/ui/webui/ntp/ntp_login_handler.cc
index b4420ba549bb8157c3e809a1532ba125387ca04b..4e8b4eec438edd1e8025507aaa2e30ca2ee3cabe 100644
--- a/chrome/browser/ui/webui/ntp/ntp_login_handler.cc
+++ b/chrome/browser/ui/webui/ntp/ntp_login_handler.cc
@@ -186,17 +186,14 @@ void NTPLoginHandler::UpdateLogin() {
// title bar and the full name can be ambiguous.
if (cache.GetNumberOfProfiles() == 1) {
string16 name = cache.GetGAIANameOfProfileAtIndex(profile_index);
- header = ASCIIToUTF16("<span class='profile-name'>") +
- net::EscapeForHTML(name) +
- ASCIIToUTF16("</span>");
+ header = AddCSSClass(name, "profile-name");
const gfx::Image* image =
cache.GetGAIAPictureOfProfileAtIndex(profile_index);
if (image)
icon_url = web_ui_util::GetImageDataUrl(GetGAIAPictureForNTP(*image));
}
if (header.empty()) {
- header = UTF8ToUTF16("<span class='profile-name'>" +
- net::EscapeForHTML(username) + "</span>");
+ header = AddCSSClass(username, "profile-name");
}
}
} else if (SyncPromoUI::ShouldShowSyncPromo(profile) &&
@@ -204,9 +201,7 @@ void NTPLoginHandler::UpdateLogin() {
PromoResourceService::CanShowNTPSignInPromo(profile))) {
string16 signed_in_link = l10n_util::GetStringUTF16(
IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_LINK);
- signed_in_link = ASCIIToUTF16("<span class='link-span'>") +
- net::EscapeForHTML(signed_in_link) +
- ASCIIToUTF16("</span>");
+ signed_in_link = AddCSSClass(signed_in_link, "link-span");
header = l10n_util::GetStringFUTF16(
IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_HEADER,
l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME));
@@ -223,6 +218,18 @@ void NTPLoginHandler::UpdateLogin() {
"updateLogin", header_value, sub_header_value, icon_url_value);
}
+string16 NTPLoginHandler::AddCSSClass(std::string display_string,
James Hawkins 2011/12/12 19:09:18 This does not need to be on the NTPLoginHandler cl
James Hawkins 2011/12/12 19:09:18 Need a more descriptive (non-generic) name for the
Tyler Breisacher (Chromium) 2011/12/12 19:15:02 What would be a better class to put this in? Or sh
Tyler Breisacher (Chromium) 2011/12/12 19:15:02 I made two separate functions because "username" a
James Hawkins 2011/12/12 19:18:26 Not all functions need to live on an object, and i
James Hawkins 2011/12/12 19:18:26 UTF8ToUTF16
+ std::string css_class) {
+ return UTF8ToUTF16("<span class='" + css_class + "'>" +
+ net::EscapeForHTML(display_string) + "</span>");
+}
+
+string16 NTPLoginHandler::AddCSSClass(string16 display_string,
+ std::string css_class) {
+ return UTF8ToUTF16("<span class='" + css_class + "'>") +
+ net::EscapeForHTML(display_string) + UTF8ToUTF16("</span>");
+}
+
// static
bool NTPLoginHandler::ShouldShow(Profile* profile) {
#if defined(OS_CHROMEOS)
« no previous file with comments | « chrome/browser/ui/webui/ntp/ntp_login_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698