summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorpeter <peter@chromium.org>2014-10-15 08:14:22 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-15 15:15:06 +0000
commitd17f01a45c92d94869750d7cefb23aa73ed9514d (patch)
tree95e85246d315c46035b97951e0146f7a83a5f06d /chrome
parent743a470b92f42a50664b8aa48151638ed3607868 (diff)
downloadchromium_src-d17f01a45c92d94869750d7cefb23aa73ed9514d.zip
chromium_src-d17f01a45c92d94869750d7cefb23aa73ed9514d.tar.gz
chromium_src-d17f01a45c92d94869750d7cefb23aa73ed9514d.tar.bz2
Request the icon of a Web Notification in the renderer process.
This will allow us to move the URL fetching logic out of /c/b/notifications/. Mind that this code will soon move to //content/child/, so we can't re-use some of the existing image fetching logic in //content/renderer/. BUG= Review URL: https://codereview.chromium.org/554213003 Cr-Commit-Position: refs/heads/master@{#299685}
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/notifications/desktop_notification_service.cc11
-rw-r--r--chrome/browser/notifications/message_center_notification_manager.cc9
-rw-r--r--chrome/browser/notifications/message_center_notifications_browsertest.cc3
-rw-r--r--chrome/browser/notifications/message_center_notifications_unittest.cc3
-rw-r--r--chrome/browser/notifications/notification.cc14
-rw-r--r--chrome/browser/notifications/notification.h15
-rw-r--r--chrome/browser/notifications/notification_test_util.cc4
-rw-r--r--chrome/browser/ui/views/message_center/web_notification_tray_browsertest.cc14
8 files changed, 22 insertions, 51 deletions
diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc
index 01bacf5..48dc1e5 100644
--- a/chrome/browser/notifications/desktop_notification_service.cc
+++ b/chrome/browser/notifications/desktop_notification_service.cc
@@ -164,9 +164,14 @@ void DesktopNotificationService::ShowDesktopNotification(
base::string16 display_source = DisplayNameForOriginInProcessId(
origin, render_frame_host->GetProcess()->GetID());
- Notification notification(origin, params.icon_url, params.title,
- params.body, params.direction, display_source, params.replace_id,
- proxy);
+
+ // 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, params.title, params.body,
+ gfx::Image::CreateFrom1xBitmap(params.icon),
+ display_source, params.replace_id, proxy);
// The webkit notification doesn't timeout.
notification.set_never_timeout(true);
diff --git a/chrome/browser/notifications/message_center_notification_manager.cc b/chrome/browser/notifications/message_center_notification_manager.cc
index 7a0a0a5..e4f20c2 100644
--- a/chrome/browser/notifications/message_center_notification_manager.cc
+++ b/chrome/browser/notifications/message_center_notification_manager.cc
@@ -379,15 +379,6 @@ void MessageCenterNotificationManager::ImageDownloads::StartDownloads(
// In case all downloads are synchronous, assume a pending download.
AddPendingDownload();
- // Notification primary icon.
- StartDownloadWithImage(
- notification,
- &notification.icon(),
- notification.icon_url(),
- base::Bind(&message_center::MessageCenter::SetNotificationIcon,
- base::Unretained(message_center_),
- notification.id()));
-
// Notification image.
StartDownloadWithImage(
notification,
diff --git a/chrome/browser/notifications/message_center_notifications_browsertest.cc b/chrome/browser/notifications/message_center_notifications_browsertest.cc
index 9563d61..3b0fcd0 100644
--- a/chrome/browser/notifications/message_center_notifications_browsertest.cc
+++ b/chrome/browser/notifications/message_center_notifications_browsertest.cc
@@ -107,10 +107,9 @@ class MessageCenterNotificationsTest : public InProcessBrowserTest {
}
return Notification(GURL("chrome-test://testing/"),
- GURL(),
base::ASCIIToUTF16("title"),
base::ASCIIToUTF16("message"),
- blink::WebTextDirectionDefault,
+ gfx::Image(),
base::UTF8ToUTF16("chrome-test://testing/"),
base::UTF8ToUTF16("REPLACE-ME"),
new_delegate);
diff --git a/chrome/browser/notifications/message_center_notifications_unittest.cc b/chrome/browser/notifications/message_center_notifications_unittest.cc
index 0e958b9f..8403880 100644
--- a/chrome/browser/notifications/message_center_notifications_unittest.cc
+++ b/chrome/browser/notifications/message_center_notifications_unittest.cc
@@ -101,10 +101,9 @@ class MessageCenterNotificationManagerTest : public BrowserWithTestWindowTest {
const ::Notification GetANotification(const std::string& id) {
return ::Notification(
GURL("chrome-extension://adflkjsdflkdsfdsflkjdsflkdjfs"),
- GURL(),
base::string16(),
base::string16(),
- blink::WebTextDirectionDefault,
+ gfx::Image(),
base::string16(),
base::UTF8ToUTF16(id),
new MockNotificationDelegate(id));
diff --git a/chrome/browser/notifications/notification.cc b/chrome/browser/notifications/notification.cc
index efa2332..22e79e4 100644
--- a/chrome/browser/notifications/notification.cc
+++ b/chrome/browser/notifications/notification.cc
@@ -5,10 +5,9 @@
#include "chrome/browser/notifications/notification.h"
Notification::Notification(const GURL& origin_url,
- const GURL& icon_url,
const base::string16& title,
const base::string16& body,
- blink::WebTextDirection dir,
+ const gfx::Image& icon,
const base::string16& display_source,
const base::string16& replace_id,
NotificationDelegate* delegate)
@@ -16,13 +15,12 @@ Notification::Notification(const GURL& origin_url,
delegate->id(),
title,
body,
- gfx::Image(),
+ icon,
display_source,
message_center::NotifierId(origin_url),
message_center::RichNotificationData(),
delegate),
origin_url_(origin_url),
- icon_url_(icon_url),
replace_id_(replace_id),
delegate_(delegate) {}
@@ -49,16 +47,12 @@ Notification::Notification(
delegate),
origin_url_(origin_url),
replace_id_(replace_id),
- delegate_(delegate) {
- // It's important to leave |icon_url_| empty with rich notifications enabled,
- // to prevent "Downloading" the data url and overwriting the existing |icon|.
-}
+ delegate_(delegate) {}
Notification::Notification(const std::string& id,
const Notification& notification)
: message_center::Notification(id, notification),
origin_url_(notification.origin_url()),
- icon_url_(notification.icon_url()),
button_one_icon_url_(notification.button_one_icon_url()),
button_two_icon_url_(notification.button_two_icon_url()),
image_url_(notification.image_url()),
@@ -69,7 +63,6 @@ Notification::Notification(const std::string& id,
Notification::Notification(const Notification& notification)
: message_center::Notification(notification),
origin_url_(notification.origin_url()),
- icon_url_(notification.icon_url()),
button_one_icon_url_(notification.button_one_icon_url()),
button_two_icon_url_(notification.button_two_icon_url()),
image_url_(notification.image_url()),
@@ -81,7 +74,6 @@ Notification::~Notification() {}
Notification& Notification::operator=(const Notification& notification) {
message_center::Notification::operator=(notification);
origin_url_ = notification.origin_url();
- icon_url_ = notification.icon_url();
button_one_icon_url_ = notification.button_one_icon_url();
button_two_icon_url_ = notification.button_two_icon_url();
image_url_ = notification.image_url();
diff --git a/chrome/browser/notifications/notification.h b/chrome/browser/notifications/notification.h
index b612595..c2db1f2 100644
--- a/chrome/browser/notifications/notification.h
+++ b/chrome/browser/notifications/notification.h
@@ -22,18 +22,12 @@ class Image;
}
// Representation of a notification to be shown to the user.
-// On non-Ash platforms these are rendered as HTML, sometimes described by a
-// data url converted from text + icon data. On Ash they are rendered as
-// formated text and icon data.
class Notification : public message_center::Notification {
public:
- // Initializes a notification with text content. On non-ash platforms, this
- // creates an HTML representation using a data: URL for display.
Notification(const GURL& origin_url,
- const GURL& icon_url,
const base::string16& title,
const base::string16& body,
- blink::WebTextDirection dir,
+ const gfx::Image& icon,
const base::string16& display_source,
const base::string16& replace_id,
NotificationDelegate* delegate);
@@ -60,9 +54,6 @@ class Notification : public message_center::Notification {
// The origin URL of the script which requested the notification.
const GURL& origin_url() const { return origin_url_; }
- // A url for the icon to be shown (optional).
- const GURL& icon_url() const { return icon_url_; }
-
// A unique identifier used to update (replace) or remove a notification.
const base::string16& replace_id() const { return replace_id_; }
@@ -82,10 +73,6 @@ class Notification : public message_center::Notification {
// The Origin of the page/worker which created this notification.
GURL origin_url_;
- // URL for the icon associated with the notification. Requires delegate_
- // to have a non NULL RenderViewHost.
- GURL icon_url_;
-
// The URLs of the button images for a rich notification.
GURL button_one_icon_url_;
GURL button_two_icon_url_;
diff --git a/chrome/browser/notifications/notification_test_util.cc b/chrome/browser/notifications/notification_test_util.cc
index 6c1a66a..71a0d06 100644
--- a/chrome/browser/notifications/notification_test_util.cc
+++ b/chrome/browser/notifications/notification_test_util.cc
@@ -15,12 +15,12 @@ content::WebContents* MockNotificationDelegate::GetWebContents() const {
return NULL;
}
+// TODO(peter): |notification_| should be initialized with the correct origin.
StubNotificationUIManager::StubNotificationUIManager(const GURL& welcome_origin)
: notification_(GURL(),
- GURL(),
base::string16(),
base::string16(),
- blink::WebTextDirectionDefault,
+ gfx::Image(),
base::string16(),
base::string16(),
new MockNotificationDelegate("stub")),
diff --git a/chrome/browser/ui/views/message_center/web_notification_tray_browsertest.cc b/chrome/browser/ui/views/message_center/web_notification_tray_browsertest.cc
index 5abddd0..e2d1c6d 100644
--- a/chrome/browser/ui/views/message_center/web_notification_tray_browsertest.cc
+++ b/chrome/browser/ui/views/message_center/web_notification_tray_browsertest.cc
@@ -66,16 +66,15 @@ class WebNotificationTrayTest : public InProcessBrowserTest {
const std::string& replace_id) {
::Notification notification(
GURL("chrome-extension://abbccedd"),
- GURL(),
base::ASCIIToUTF16("Test Web Notification"),
base::ASCIIToUTF16("Notification message body."),
- blink::WebTextDirectionDefault,
+ gfx::Image(),
base::string16(),
base::ASCIIToUTF16(replace_id),
new TestNotificationDelegate(delegate_id));
- g_browser_process->notification_ui_manager()->Add(
- notification, browser()->profile());
+ g_browser_process->notification_ui_manager()->Add(notification,
+ browser()->profile());
}
std::string FindNotificationIdByDelegateId(const std::string& delegate_id) {
@@ -90,16 +89,15 @@ class WebNotificationTrayTest : public InProcessBrowserTest {
void UpdateNotification(const std::string& replace_id,
const std::string& new_id) {
::Notification notification(GURL("chrome-extension://abbccedd"),
- GURL(""),
base::ASCIIToUTF16("Updated Web Notification"),
base::ASCIIToUTF16("Updated message body."),
- blink::WebTextDirectionDefault,
+ gfx::Image(),
base::string16(),
base::ASCIIToUTF16(replace_id),
new TestNotificationDelegate(new_id));
- g_browser_process->notification_ui_manager()->Add(
- notification, browser()->profile());
+ g_browser_process->notification_ui_manager()->Add(notification,
+ browser()->profile());
}
void RemoveNotification(const std::string& id) {