Index: chrome/browser/notifications/platform_notification_service_impl.cc |
diff --git a/chrome/browser/notifications/platform_notification_service_impl.cc b/chrome/browser/notifications/platform_notification_service_impl.cc |
index f03f2beb7239553a3abe9bbbfb9c0c51abd75955..79fc0bb0437af96954a4ea1fde98af99d74b8c7f 100644 |
--- a/chrome/browser/notifications/platform_notification_service_impl.cc |
+++ b/chrome/browser/notifications/platform_notification_service_impl.cc |
@@ -323,17 +323,22 @@ Notification PlatformNotificationServiceImpl::CreateNotificationFromData( |
const SkBitmap& icon, |
const content::PlatformNotificationData& notification_data, |
NotificationDelegate* delegate) const { |
- base::string16 display_source = DisplayNameForOrigin(profile, origin); |
- |
// TODO(peter): Icons for Web Notifications are currently always requested for |
// 1x scale, whereas the displays on which they can be displayed can have a |
// different pixel density. Be smarter about this when the API gets updated |
// with a way for developers to specify images of different resolutions. |
- Notification notification(origin, notification_data.title, |
- notification_data.body, gfx::Image::CreateFrom1xBitmap(icon), |
- display_source, notification_data.tag, delegate); |
+ Notification notification( |
+ origin, notification_data.title, notification_data.body, |
+ gfx::Image::CreateFrom1xBitmap(icon), base::UTF8ToUTF16(origin.host()), |
+ notification_data.tag, delegate); |
- notification.set_context_message(display_source); |
+ std::string display_source = DisplayNameForOrigin(profile, origin); |
+#if defined(ENABLE_EXTENSIONS) |
+ notification.set_context_message( |
+ display_source, !origin.SchemeIs(extensions::kExtensionScheme)); |
+#else |
+ notification.set_context_message(display_source, true); |
+#endif |
notification.set_vibration_pattern(notification_data.vibration_pattern); |
notification.set_silent(notification_data.silent); |
@@ -362,7 +367,7 @@ void PlatformNotificationServiceImpl::SetNotificationUIManagerForTesting( |
notification_ui_manager_for_tests_ = manager; |
} |
-base::string16 PlatformNotificationServiceImpl::DisplayNameForOrigin( |
+std::string PlatformNotificationServiceImpl::DisplayNameForOrigin( |
Profile* profile, |
const GURL& origin) const { |
#if defined(ENABLE_EXTENSIONS) |
@@ -373,42 +378,9 @@ base::string16 PlatformNotificationServiceImpl::DisplayNameForOrigin( |
origin.host(), extensions::ExtensionRegistry::EVERYTHING); |
DCHECK(extension); |
- return base::UTF8ToUTF16(extension->name()); |
+ return extension->name(); |
} |
#endif |
- std::string languages = |
- profile->GetPrefs()->GetString(prefs::kAcceptLanguages); |
- |
- return WebOriginDisplayName(origin, languages); |
-} |
- |
-// static |
-// TODO(palmer): It might be good to replace this with a call to |
-// |FormatUrlForSecurityDisplay|. crbug.com/496965 |
-base::string16 PlatformNotificationServiceImpl::WebOriginDisplayName( |
- const GURL& origin, |
- const std::string& languages) { |
- if (origin.SchemeIsHTTPOrHTTPS()) { |
- base::string16 formatted_origin; |
- if (origin.SchemeIs(url::kHttpScheme)) { |
- const url::Parsed& parsed = origin.parsed_for_possibly_invalid_spec(); |
- const std::string& spec = origin.possibly_invalid_spec(); |
- formatted_origin.append( |
- spec.begin(), |
- spec.begin() + |
- parsed.CountCharactersBefore(url::Parsed::USERNAME, true)); |
- } |
- formatted_origin.append( |
- url_formatter::IDNToUnicode(origin.host(), languages)); |
- if (origin.has_port()) { |
- formatted_origin.push_back(':'); |
- formatted_origin.append(base::UTF8ToUTF16(origin.port())); |
- } |
- return formatted_origin; |
- } |
- |
- // TODO(dewittj): Once file:// URLs are passed in to the origin |
- // GURL here, begin returning the path as the display name. |
- return url_formatter::FormatUrl(origin, languages); |
+ return origin.spec(); |
} |