Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ntp/ntp_login_handler.h" | 5 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 gfx::CanvasSkia canvas(length, length, false); | 54 gfx::CanvasSkia canvas(length, length, false); |
| 55 canvas.DrawBitmapInt(bmp, 0, 0); | 55 canvas.DrawBitmapInt(bmp, 0, 0); |
| 56 | 56 |
| 57 // Draw a gray border on the inside of the icon. | 57 // Draw a gray border on the inside of the icon. |
| 58 SkColor color = SkColorSetARGB(83, 0, 0, 0); | 58 SkColor color = SkColorSetARGB(83, 0, 0, 0); |
| 59 canvas.DrawRectInt(color, 0, 0, length - 1, length - 1); | 59 canvas.DrawRectInt(color, 0, 0, length - 1, length - 1); |
| 60 | 60 |
| 61 return canvas.ExtractBitmap(); | 61 return canvas.ExtractBitmap(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 // Put the display_string into a span with the given CSS class. | |
|
James Hawkins
2011/12/12 23:24:41
s/Put/Puts/
James Hawkins
2011/12/12 23:24:41
s/display_string/|display_string|/
Tyler Breisacher (Chromium)
2011/12/12 23:37:42
Done.
Tyler Breisacher (Chromium)
2011/12/12 23:37:42
Or, |content| since I renamed it based on estade's
| |
| 65 string16 CreateSpanWithClass(const string16& content, | |
| 66 const std::string& css_class) { | |
| 67 return ASCIIToUTF16("<span class='" + css_class + "'>") + | |
| 68 net::EscapeForHTML(content) + ASCIIToUTF16("</span>"); | |
| 69 } | |
| 70 | |
| 64 } // namespace | 71 } // namespace |
| 65 | 72 |
| 66 NTPLoginHandler::NTPLoginHandler() { | 73 NTPLoginHandler::NTPLoginHandler() { |
| 67 } | 74 } |
| 68 | 75 |
| 69 NTPLoginHandler::~NTPLoginHandler() { | 76 NTPLoginHandler::~NTPLoginHandler() { |
| 70 } | 77 } |
| 71 | 78 |
| 72 WebUIMessageHandler* NTPLoginHandler::Attach(WebUI* web_ui) { | 79 WebUIMessageHandler* NTPLoginHandler::Attach(WebUI* web_ui) { |
| 73 PrefService* pref_service = Profile::FromWebUI(web_ui)->GetPrefs(); | 80 PrefService* pref_service = Profile::FromWebUI(web_ui)->GetPrefs(); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 if (!username.empty()) { | 186 if (!username.empty()) { |
| 180 ProfileInfoCache& cache = | 187 ProfileInfoCache& cache = |
| 181 g_browser_process->profile_manager()->GetProfileInfoCache(); | 188 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 182 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); | 189 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); |
| 183 if (profile_index != std::string::npos) { | 190 if (profile_index != std::string::npos) { |
| 184 // Only show the profile picture and full name for the single profile | 191 // Only show the profile picture and full name for the single profile |
| 185 // case. In the multi-profile case the profile picture is visible in the | 192 // case. In the multi-profile case the profile picture is visible in the |
| 186 // title bar and the full name can be ambiguous. | 193 // title bar and the full name can be ambiguous. |
| 187 if (cache.GetNumberOfProfiles() == 1) { | 194 if (cache.GetNumberOfProfiles() == 1) { |
| 188 string16 name = cache.GetGAIANameOfProfileAtIndex(profile_index); | 195 string16 name = cache.GetGAIANameOfProfileAtIndex(profile_index); |
| 189 header = ASCIIToUTF16("<span class='profile-name'>") + | 196 header = CreateSpanWithClass(name, "profile-name"); |
| 190 net::EscapeForHTML(name) + | |
| 191 ASCIIToUTF16("</span>"); | |
| 192 const gfx::Image* image = | 197 const gfx::Image* image = |
| 193 cache.GetGAIAPictureOfProfileAtIndex(profile_index); | 198 cache.GetGAIAPictureOfProfileAtIndex(profile_index); |
| 194 if (image) | 199 if (image) |
| 195 icon_url = web_ui_util::GetImageDataUrl(GetGAIAPictureForNTP(*image)); | 200 icon_url = web_ui_util::GetImageDataUrl(GetGAIAPictureForNTP(*image)); |
| 196 } | 201 } |
| 197 if (header.empty()) { | 202 if (header.empty()) |
| 198 header = UTF8ToUTF16("<span class='profile-name'>" + | 203 header = CreateSpanWithClass(UTF8ToUTF16(username), "profile-name"); |
| 199 net::EscapeForHTML(username) + "</span>"); | |
| 200 } | |
| 201 } | 204 } |
| 202 } else if (SyncPromoUI::ShouldShowSyncPromo(profile) && | 205 } else if (SyncPromoUI::ShouldShowSyncPromo(profile) && |
| 203 (SyncPromoUI::UserHasSeenSyncPromoAtStartup(profile) || | 206 (SyncPromoUI::UserHasSeenSyncPromoAtStartup(profile) || |
| 204 PromoResourceService::CanShowNTPSignInPromo(profile))) { | 207 PromoResourceService::CanShowNTPSignInPromo(profile))) { |
| 205 string16 signed_in_link = l10n_util::GetStringUTF16( | 208 string16 signed_in_link = l10n_util::GetStringUTF16( |
| 206 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_LINK); | 209 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_LINK); |
| 207 signed_in_link = ASCIIToUTF16("<span class='link-span'>") + | 210 signed_in_link = CreateSpanWithClass(signed_in_link, "link-span"); |
| 208 net::EscapeForHTML(signed_in_link) + | |
| 209 ASCIIToUTF16("</span>"); | |
| 210 header = l10n_util::GetStringFUTF16( | 211 header = l10n_util::GetStringFUTF16( |
| 211 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_HEADER, | 212 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_HEADER, |
| 212 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); | 213 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); |
| 213 sub_header = l10n_util::GetStringFUTF16( | 214 sub_header = l10n_util::GetStringFUTF16( |
| 214 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_SUB_HEADER, signed_in_link); | 215 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_SUB_HEADER, signed_in_link); |
| 215 // Record that the user was shown the promo. | 216 // Record that the user was shown the promo. |
| 216 RecordInHistogram(NTP_SIGN_IN_PROMO_VIEWED); | 217 RecordInHistogram(NTP_SIGN_IN_PROMO_VIEWED); |
| 217 } | 218 } |
| 218 | 219 |
| 219 StringValue header_value(header); | 220 StringValue header_value(header); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | 252 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); |
| 252 values->SetString("login_status_url", | 253 values->SetString("login_status_url", |
| 253 google_util::StringAppendGoogleLocaleParam(chrome::kSyncLearnMoreURL)); | 254 google_util::StringAppendGoogleLocaleParam(chrome::kSyncLearnMoreURL)); |
| 254 values->SetString("login_status_learn_more", | 255 values->SetString("login_status_learn_more", |
| 255 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); | 256 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); |
| 256 values->SetString("login_status_advanced", | 257 values->SetString("login_status_advanced", |
| 257 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); | 258 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); |
| 258 values->SetString("login_status_dismiss", | 259 values->SetString("login_status_dismiss", |
| 259 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); | 260 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); |
| 260 } | 261 } |
| OLD | NEW |