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 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) + | |
| 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()) |
|
Evan Stade
2011/12/08 18:23:35
curlies
| |
| 194 header = UTF8ToUTF16(username); | 198 header = UTF8ToUTF16("<span class='profile-name'>" + |
| 199 net::EscapeForHTML(username) + "</span>"); | |
| 195 } | 200 } |
| 196 } else if (SyncPromoUI::ShouldShowSyncPromo(profile) && | 201 } else if (SyncPromoUI::ShouldShowSyncPromo(profile) && |
| 197 (SyncPromoUI::UserHasSeenSyncPromoAtStartup(profile) || | 202 (SyncPromoUI::UserHasSeenSyncPromoAtStartup(profile) || |
| 198 PromoResourceService::CanShowNTPSignInPromo(profile))) { | 203 PromoResourceService::CanShowNTPSignInPromo(profile))) { |
| 199 string16 signed_in_link = l10n_util::GetStringUTF16( | 204 string16 signed_in_link = l10n_util::GetStringUTF16( |
| 200 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_LINK); | 205 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_LINK); |
| 201 signed_in_link = ASCIIToUTF16("<span class='link-span'>") + signed_in_link + | 206 signed_in_link = ASCIIToUTF16("<span class='link-span'>") + |
| 207 net::EscapeForHTML(signed_in_link) + | |
| 202 ASCIIToUTF16("</span>"); | 208 ASCIIToUTF16("</span>"); |
| 203 header = l10n_util::GetStringFUTF16( | 209 header = l10n_util::GetStringFUTF16( |
| 204 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_HEADER, | 210 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_HEADER, |
| 205 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); | 211 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); |
| 206 sub_header = l10n_util::GetStringFUTF16( | 212 sub_header = l10n_util::GetStringFUTF16( |
| 207 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_SUB_HEADER, signed_in_link); | 213 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_SUB_HEADER, signed_in_link); |
| 208 // Record that the user was shown the promo. | 214 // Record that the user was shown the promo. |
| 209 RecordInHistogram(NTP_SIGN_IN_PROMO_VIEWED); | 215 RecordInHistogram(NTP_SIGN_IN_PROMO_VIEWED); |
| 210 } | 216 } |
| 211 | 217 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | 250 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); |
| 245 values->SetString("login_status_url", | 251 values->SetString("login_status_url", |
| 246 google_util::StringAppendGoogleLocaleParam(chrome::kSyncLearnMoreURL)); | 252 google_util::StringAppendGoogleLocaleParam(chrome::kSyncLearnMoreURL)); |
| 247 values->SetString("login_status_learn_more", | 253 values->SetString("login_status_learn_more", |
| 248 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); | 254 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); |
| 249 values->SetString("login_status_advanced", | 255 values->SetString("login_status_advanced", |
| 250 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); | 256 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); |
| 251 values->SetString("login_status_dismiss", | 257 values->SetString("login_status_dismiss", |
| 252 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); | 258 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); |
| 253 } | 259 } |
| OLD | NEW |