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

Side by Side 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: Move and rename AddCSSClass 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
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
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.
64 // Put the display_string into a span with the given CSS class.
65 string16 InsertIntoSpanWithClass(string16 display_string,
66 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.
67 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.
68 net::EscapeForHTML(display_string) + UTF8ToUTF16("</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
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 = InsertIntoSpanWithClass(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 = InsertIntoSpanWithClass(UTF8ToUTF16(username), "profile-name");
199 net::EscapeForHTML(username) + "</span>");
200 } 204 }
Evan Stade 2011/12/12 19:48:59 no curlies
Tyler Breisacher (Chromium) 2011/12/12 23:04:24 Done.
201 } 205 }
202 } else if (SyncPromoUI::ShouldShowSyncPromo(profile) && 206 } else if (SyncPromoUI::ShouldShowSyncPromo(profile) &&
203 (SyncPromoUI::UserHasSeenSyncPromoAtStartup(profile) || 207 (SyncPromoUI::UserHasSeenSyncPromoAtStartup(profile) ||
204 PromoResourceService::CanShowNTPSignInPromo(profile))) { 208 PromoResourceService::CanShowNTPSignInPromo(profile))) {
205 string16 signed_in_link = l10n_util::GetStringUTF16( 209 string16 signed_in_link = l10n_util::GetStringUTF16(
206 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_LINK); 210 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_LINK);
207 signed_in_link = ASCIIToUTF16("<span class='link-span'>") + 211 signed_in_link = InsertIntoSpanWithClass(signed_in_link, "link-span");
208 net::EscapeForHTML(signed_in_link) +
209 ASCIIToUTF16("</span>");
210 header = l10n_util::GetStringFUTF16( 212 header = l10n_util::GetStringFUTF16(
211 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_HEADER, 213 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_HEADER,
212 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); 214 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME));
213 sub_header = l10n_util::GetStringFUTF16( 215 sub_header = l10n_util::GetStringFUTF16(
214 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_SUB_HEADER, signed_in_link); 216 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_SUB_HEADER, signed_in_link);
215 // Record that the user was shown the promo. 217 // Record that the user was shown the promo.
216 RecordInHistogram(NTP_SIGN_IN_PROMO_VIEWED); 218 RecordInHistogram(NTP_SIGN_IN_PROMO_VIEWED);
217 } 219 }
218 220
219 StringValue header_value(header); 221 StringValue header_value(header);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); 253 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)));
252 values->SetString("login_status_url", 254 values->SetString("login_status_url",
253 google_util::StringAppendGoogleLocaleParam(chrome::kSyncLearnMoreURL)); 255 google_util::StringAppendGoogleLocaleParam(chrome::kSyncLearnMoreURL));
254 values->SetString("login_status_learn_more", 256 values->SetString("login_status_learn_more",
255 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); 257 l10n_util::GetStringUTF16(IDS_LEARN_MORE));
256 values->SetString("login_status_advanced", 258 values->SetString("login_status_advanced",
257 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); 259 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED));
258 values->SetString("login_status_dismiss", 260 values->SetString("login_status_dismiss",
259 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); 261 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK));
260 } 262 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698