Index: chrome/browser/notifications/desktop_notification_service.cc |
diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc |
index 01bacf5b0ed5475fbc4331db316833a55611334c..79bfb3262defb604fa84e67256b4510fd7c981dc 100644 |
--- a/chrome/browser/notifications/desktop_notification_service.cc |
+++ b/chrome/browser/notifications/desktop_notification_service.cc |
@@ -31,6 +31,7 @@ |
#include "content/public/browser/render_view_host.h" |
#include "content/public/browser/web_contents.h" |
#include "content/public/common/show_desktop_notification_params.h" |
+#include "net/base/net_util.h" |
#include "ui/base/webui/web_ui_util.h" |
#include "ui/message_center/notifier_settings.h" |
@@ -162,12 +163,20 @@ void DesktopNotificationService::ShowDesktopNotification( |
NotificationObjectProxy* proxy = |
new NotificationObjectProxy(render_frame_host, delegate.Pass()); |
+ int process_id = render_frame_host->GetProcess()->GetID(); |
+ |
+ // TODO(dewittj): The origin of file:// URLs always appears to be the empty |
+ // URL. We need a better way to display this than returning an empty string. |
base::string16 display_source = DisplayNameForOriginInProcessId( |
- origin, render_frame_host->GetProcess()->GetID()); |
+ origin, process_id); |
+ |
Notification notification(origin, params.icon_url, params.title, |
params.body, params.direction, display_source, params.replace_id, |
proxy); |
+ // Web notifications should display their origin |
+ notification.set_context_message(display_source); |
+ |
// The webkit notification doesn't timeout. |
notification.set_never_timeout(true); |
@@ -205,7 +214,21 @@ base::string16 DesktopNotificationService::DisplayNameForOriginInProcessId( |
} |
#endif |
- return base::UTF8ToUTF16(origin.host()); |
+ std::string languages = |
+ profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); |
+ |
+ std::string displayed_origin; |
+ if (origin.SchemeIsHTTPOrHTTPS()) { |
+ base::string16 rv = net::IDNToUnicode(origin.host(), languages); |
Peter Beverloo
2014/10/17 11:17:59
What does |rv| stand for? Can we use a clearer nam
dewittj
2014/10/17 18:24:13
Done.
|
+ if (origin.has_port()) { |
+ rv.push_back(':'); |
+ std::string port = origin.port(); |
+ rv.insert(rv.end(), port.begin(), port.end()); |
Jun Mukai
2014/10/16 22:43:22
rv.append(base::UTF8ToUTF16(origin.port())) would
dewittj
2014/10/17 18:24:12
Done.
|
+ } |
+ return rv; |
+ } |
+ |
+ return net::FormatUrl(GURL(displayed_origin), languages); |
Peter Beverloo
2014/10/17 11:17:59
|displayed_origin| is guaranteed to be an empty st
dewittj
2014/10/17 18:24:13
Yes, I had some uncommitted fixes in my tree that
|
} |
bool DesktopNotificationService::IsNotifierEnabled( |