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

Unified Diff: chrome/browser/notifications/platform_notification_service_impl.cc

Issue 1292003004: Elide origins displayed on web notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Style nit Created 5 years, 4 months 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 side-by-side diff with in-line comments
Download patch
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..560fa06a4895842b35789cd800836a542d8ee8fb 100644
--- a/chrome/browser/notifications/platform_notification_service_impl.cc
+++ b/chrome/browser/notifications/platform_notification_service_impl.cc
@@ -323,17 +323,17 @@ 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);
+ notification.set_context_message(
+ DisplayNameForContextMessage(profile, origin));
notification.set_vibration_pattern(notification_data.vibration_pattern);
notification.set_silent(notification_data.silent);
@@ -362,7 +362,7 @@ void PlatformNotificationServiceImpl::SetNotificationUIManagerForTesting(
notification_ui_manager_for_tests_ = manager;
}
-base::string16 PlatformNotificationServiceImpl::DisplayNameForOrigin(
+base::string16 PlatformNotificationServiceImpl::DisplayNameForContextMessage(
Profile* profile,
const GURL& origin) const {
#if defined(ENABLE_EXTENSIONS)
@@ -377,38 +377,5 @@ base::string16 PlatformNotificationServiceImpl::DisplayNameForOrigin(
}
#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 base::string16();
}

Powered by Google App Engine
This is Rietveld 408576698