Chromium Code Reviews| 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..5d02ac168d27d5f5d834a4b412f17f260b3ce9a4 100644 |
| --- a/chrome/browser/ui/webui/ntp/ntp_login_handler.cc |
| +++ b/chrome/browser/ui/webui/ntp/ntp_login_handler.cc |
| @@ -61,6 +61,13 @@ SkBitmap GetGAIAPictureForNTP(const gfx::Image& image) { |
| return canvas.ExtractBitmap(); |
| } |
|
Tyler Breisacher (Chromium)
2011/12/12 19:35:05
I'm not that happy with this name, other ideas are
Evan Stade
2011/12/12 19:48:59
CreateSpanWithClass(content, css_class)
Tyler Breisacher (Chromium)
2011/12/12 23:04:24
Done.
|
| +// Put the display_string into a span with the given CSS class. |
| +string16 InsertIntoSpanWithClass(string16 display_string, |
| + std::string css_class) { |
|
Evan Stade
2011/12/12 19:35:52
const ref on the parameters
Tyler Breisacher (Chromium)
2011/12/12 23:04:24
Done.
|
| + return UTF8ToUTF16("<span class='" + css_class + "'>") + |
|
Evan Stade
2011/12/12 19:35:52
both of these should be ASCIITo
Tyler Breisacher (Chromium)
2011/12/12 23:04:24
Done.
|
| + net::EscapeForHTML(display_string) + UTF8ToUTF16("</span>"); |
| +} |
| + |
| } // namespace |
| NTPLoginHandler::NTPLoginHandler() { |
| @@ -186,17 +193,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 = InsertIntoSpanWithClass(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 = InsertIntoSpanWithClass(UTF8ToUTF16(username), "profile-name"); |
| } |
|
Evan Stade
2011/12/12 19:48:59
no curlies
Tyler Breisacher (Chromium)
2011/12/12 23:04:24
Done.
|
| } |
| } else if (SyncPromoUI::ShouldShowSyncPromo(profile) && |
| @@ -204,9 +208,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 = InsertIntoSpanWithClass(signed_in_link, "link-span"); |
| header = l10n_util::GetStringFUTF16( |
| IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_HEADER, |
| l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); |