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) + | |
sail
2011/12/06 23:00:57
Ahh, I didn't know about EscapeForHTML(). Can you
Tyler Breisacher (Chromium)
2011/12/06 23:17:48
I figured it's unlikely someone would say their na
| |
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(username); |
sail
2011/12/06 23:00:57
You'll need to modify this case as well
sail
2011/12/06 23:46:25
Sorry, I mean you'll need to add "class='profile-n
| |
195 } | 199 } |
196 } else if (SyncPromoUI::ShouldShowSyncPromo(profile) && | 200 } else if (SyncPromoUI::ShouldShowSyncPromo(profile) && |
197 (SyncPromoUI::UserHasSeenSyncPromoAtStartup(profile) || | 201 (SyncPromoUI::UserHasSeenSyncPromoAtStartup(profile) || |
198 PromoResourceService::CanShowNTPSignInPromo(profile))) { | 202 PromoResourceService::CanShowNTPSignInPromo(profile))) { |
199 string16 signed_in_link = l10n_util::GetStringUTF16( | 203 string16 signed_in_link = l10n_util::GetStringUTF16( |
200 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_LINK); | 204 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_LINK); |
201 signed_in_link = ASCIIToUTF16("<span class='link-span'>") + signed_in_link + | 205 signed_in_link = ASCIIToUTF16("<span class='link-span'>") + signed_in_link + |
202 ASCIIToUTF16("</span>"); | 206 ASCIIToUTF16("</span>"); |
203 header = l10n_util::GetStringFUTF16( | 207 header = l10n_util::GetStringFUTF16( |
204 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_HEADER, | 208 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_HEADER, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | 248 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); |
245 values->SetString("login_status_url", | 249 values->SetString("login_status_url", |
246 google_util::StringAppendGoogleLocaleParam(chrome::kSyncLearnMoreURL)); | 250 google_util::StringAppendGoogleLocaleParam(chrome::kSyncLearnMoreURL)); |
247 values->SetString("login_status_learn_more", | 251 values->SetString("login_status_learn_more", |
248 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); | 252 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); |
249 values->SetString("login_status_advanced", | 253 values->SetString("login_status_advanced", |
250 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); | 254 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); |
251 values->SetString("login_status_dismiss", | 255 values->SetString("login_status_dismiss", |
252 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); | 256 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); |
253 } | 257 } |
OLD | NEW |