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 18 matching lines...) Expand all Loading... | |
29 #include "chrome/browser/ui/webui/web_ui_util.h" | 29 #include "chrome/browser/ui/webui/web_ui_util.h" |
30 #include "chrome/browser/web_resource/promo_resource_service.h" | 30 #include "chrome/browser/web_resource/promo_resource_service.h" |
31 #include "chrome/common/chrome_notification_types.h" | 31 #include "chrome/common/chrome_notification_types.h" |
32 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
33 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
34 #include "content/browser/tab_contents/tab_contents.h" | 34 #include "content/browser/tab_contents/tab_contents.h" |
35 #include "content/public/browser/notification_details.h" | 35 #include "content/public/browser/notification_details.h" |
36 #include "content/public/browser/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
37 #include "grit/chromium_strings.h" | 37 #include "grit/chromium_strings.h" |
38 #include "grit/generated_resources.h" | 38 #include "grit/generated_resources.h" |
39 #include "net/base/escape.h" | |
39 #include "skia/ext/image_operations.h" | 40 #include "skia/ext/image_operations.h" |
40 #include "ui/base/l10n/l10n_util.h" | 41 #include "ui/base/l10n/l10n_util.h" |
41 #include "ui/gfx/canvas_skia.h" | 42 #include "ui/gfx/canvas_skia.h" |
42 #include "ui/gfx/image/image.h" | 43 #include "ui/gfx/image/image.h" |
43 | 44 |
44 namespace { | 45 namespace { |
45 | 46 |
46 SkBitmap GetGAIAPictureForNTP(const gfx::Image& image) { | 47 SkBitmap GetGAIAPictureForNTP(const gfx::Image& image) { |
47 // This value must match the width and height value of login-status-icon | 48 // This value must match the width and height value of login-status-icon |
48 // in new_tab.css. | 49 // in new_tab.css. |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 std::string icon_url; | 178 std::string icon_url; |
178 if (!username.empty()) { | 179 if (!username.empty()) { |
179 ProfileInfoCache& cache = | 180 ProfileInfoCache& cache = |
180 g_browser_process->profile_manager()->GetProfileInfoCache(); | 181 g_browser_process->profile_manager()->GetProfileInfoCache(); |
181 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); | 182 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); |
182 if (profile_index != std::string::npos) { | 183 if (profile_index != std::string::npos) { |
183 // Only show the profile picture and full name for the single profile | 184 // Only show the profile picture and full name for the single profile |
184 // case. In the multi-profile case the profile picture is visible in the | 185 // case. In the multi-profile case the profile picture is visible in the |
185 // title bar and the full name can be ambiguous. | 186 // title bar and the full name can be ambiguous. |
186 if (cache.GetNumberOfProfiles() == 1) { | 187 if (cache.GetNumberOfProfiles() == 1) { |
187 header = cache.GetGAIANameOfProfileAtIndex(profile_index); | 188 string16 name = cache.GetGAIANameOfProfileAtIndex(profile_index); |
189 header = ASCIIToUTF16("<span class='profile-name'>") + | |
190 net::EscapeForHTML(name) + | |
James Hawkins
2011/12/10 03:07:30
nit: Wrapped lines must be indented exactly 4 spac
| |
191 ASCIIToUTF16("</span>"); | |
188 const gfx::Image* image = | 192 const gfx::Image* image = |
189 cache.GetGAIAPictureOfProfileAtIndex(profile_index); | 193 cache.GetGAIAPictureOfProfileAtIndex(profile_index); |
190 if (image) | 194 if (image) |
191 icon_url = web_ui_util::GetImageDataUrl(GetGAIAPictureForNTP(*image)); | 195 icon_url = web_ui_util::GetImageDataUrl(GetGAIAPictureForNTP(*image)); |
192 } | 196 } |
193 if (header.empty()) | 197 if (header.empty()) { |
194 header = UTF8ToUTF16(username); | 198 header = UTF8ToUTF16("<span class='profile-name'>" + |
James Hawkins
2011/12/10 03:07:30
You use ASCIITo above and UTF8To here; is there a
Tyler Breisacher (Chromium)
2011/12/10 03:43:25
I was doing ASCII above because I was following th
James Hawkins
2011/12/10 04:14:25
Probably. If these are all the same, we should re
| |
199 net::EscapeForHTML(username) + "</span>"); | |
200 } | |
195 } | 201 } |
196 } else if (SyncPromoUI::ShouldShowSyncPromo(profile) && | 202 } else if (SyncPromoUI::ShouldShowSyncPromo(profile) && |
197 (SyncPromoUI::UserHasSeenSyncPromoAtStartup(profile) || | 203 (SyncPromoUI::UserHasSeenSyncPromoAtStartup(profile) || |
198 PromoResourceService::CanShowNTPSignInPromo(profile))) { | 204 PromoResourceService::CanShowNTPSignInPromo(profile))) { |
199 string16 signed_in_link = l10n_util::GetStringUTF16( | 205 string16 signed_in_link = l10n_util::GetStringUTF16( |
200 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_LINK); | 206 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_LINK); |
201 signed_in_link = ASCIIToUTF16("<span class='link-span'>") + signed_in_link + | 207 signed_in_link = ASCIIToUTF16("<span class='link-span'>") + |
208 net::EscapeForHTML(signed_in_link) + | |
202 ASCIIToUTF16("</span>"); | 209 ASCIIToUTF16("</span>"); |
203 header = l10n_util::GetStringFUTF16( | 210 header = l10n_util::GetStringFUTF16( |
204 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_HEADER, | 211 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_HEADER, |
205 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); | 212 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); |
206 sub_header = l10n_util::GetStringFUTF16( | 213 sub_header = l10n_util::GetStringFUTF16( |
207 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_SUB_HEADER, signed_in_link); | 214 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_SUB_HEADER, signed_in_link); |
208 // Record that the user was shown the promo. | 215 // Record that the user was shown the promo. |
209 RecordInHistogram(NTP_SIGN_IN_PROMO_VIEWED); | 216 RecordInHistogram(NTP_SIGN_IN_PROMO_VIEWED); |
210 } | 217 } |
211 | 218 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | 251 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); |
245 values->SetString("login_status_url", | 252 values->SetString("login_status_url", |
246 google_util::StringAppendGoogleLocaleParam(chrome::kSyncLearnMoreURL)); | 253 google_util::StringAppendGoogleLocaleParam(chrome::kSyncLearnMoreURL)); |
247 values->SetString("login_status_learn_more", | 254 values->SetString("login_status_learn_more", |
248 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); | 255 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); |
249 values->SetString("login_status_advanced", | 256 values->SetString("login_status_advanced", |
250 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); | 257 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); |
251 values->SetString("login_status_dismiss", | 258 values->SetString("login_status_dismiss", |
252 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); | 259 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); |
253 } | 260 } |
OLD | NEW |