Commit 740ce383 authored by peter@chromium.org's avatar peter@chromium.org

Remove plumbing for showing HTML notifications from content/.

WebNotification::isHTML() has been returning false since late July when
we removed the Web Exposed entry point, so all of this is dead code. The
removal shipped in Chrome 30, so it's unlikely to return.

BUG=

Review URL: https://codereview.chromium.org/95223003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238415 0039d316-1c4b-4281-b951-d872f2087c98
parent 87f613cb
...@@ -494,17 +494,14 @@ bool DesktopNotificationService::ShowDesktopNotification( ...@@ -494,17 +494,14 @@ bool DesktopNotificationService::ShowDesktopNotification(
source == WorkerNotification); source == WorkerNotification);
string16 display_source = DisplayNameForOriginInProcessId(origin, process_id); string16 display_source = DisplayNameForOriginInProcessId(origin, process_id);
if (params.is_html) { Notification notification(origin, params.icon_url, params.title,
ShowNotification(Notification(origin, params.contents_url, display_source, params.body, params.direction, display_source, params.replace_id,
params.replace_id, proxy)); proxy);
} else {
Notification notification(origin, params.icon_url, params.title, // The webkit notification doesn't timeout.
params.body, params.direction, display_source, params.replace_id, notification.set_never_timeout(true);
proxy);
// The webkit notification doesn't timeout. ShowNotification(notification);
notification.set_never_timeout(true);
ShowNotification(notification);
}
return true; return true;
} }
......
...@@ -145,7 +145,6 @@ DesktopNotificationsTest::StandardTestNotification() { ...@@ -145,7 +145,6 @@ DesktopNotificationsTest::StandardTestNotification() {
content::ShowDesktopNotificationHostMsgParams params; content::ShowDesktopNotificationHostMsgParams params;
params.notification_id = 0; params.notification_id = 0;
params.origin = GURL("http://www.google.com"); params.origin = GURL("http://www.google.com");
params.is_html = false;
params.icon_url = GURL("/icon.png"); params.icon_url = GURL("/icon.png");
params.title = ASCIIToUTF16("Title"); params.title = ASCIIToUTF16("Title");
params.body = ASCIIToUTF16("Text"); params.body = ASCIIToUTF16("Text");
...@@ -163,11 +162,11 @@ TEST_F(DesktopNotificationsTest, TestShow) { ...@@ -163,11 +162,11 @@ TEST_F(DesktopNotificationsTest, TestShow) {
base::MessageLoopForUI::current()->RunUntilIdle(); base::MessageLoopForUI::current()->RunUntilIdle();
EXPECT_EQ(1, balloon_collection_->count()); EXPECT_EQ(1, balloon_collection_->count());
content::ShowDesktopNotificationHostMsgParams params2; content::ShowDesktopNotificationHostMsgParams params2 =
params2.origin = GURL("http://www.google.com"); StandardTestNotification();
params2.is_html = true;
params2.contents_url = GURL("http://www.google.com/notification.html");
params2.notification_id = 2; params2.notification_id = 2;
params2.origin = GURL("http://www.google.com");
params2.body = ASCIIToUTF16("Text");
EXPECT_TRUE(service_->ShowDesktopNotification( EXPECT_TRUE(service_->ShowDesktopNotification(
params2, 0, 0, DesktopNotificationService::PageNotification)); params2, 0, 0, DesktopNotificationService::PageNotification));
...@@ -254,7 +253,6 @@ TEST_F(DesktopNotificationsTest, TestPositioning) { ...@@ -254,7 +253,6 @@ TEST_F(DesktopNotificationsTest, TestPositioning) {
TEST_F(DesktopNotificationsTest, TestVariableSize) { TEST_F(DesktopNotificationsTest, TestVariableSize) {
content::ShowDesktopNotificationHostMsgParams params; content::ShowDesktopNotificationHostMsgParams params;
params.origin = GURL("http://long.google.com"); params.origin = GURL("http://long.google.com");
params.is_html = false;
params.icon_url = GURL("/icon.png"); params.icon_url = GURL("/icon.png");
params.title = ASCIIToUTF16("Really Really Really Really Really Really " params.title = ASCIIToUTF16("Really Really Really Really Really Really "
"Really Really Really Really Really Really " "Really Really Really Really Really Really "
......
...@@ -2203,15 +2203,6 @@ void RenderViewHostImpl::OnRequestDesktopNotificationPermission( ...@@ -2203,15 +2203,6 @@ void RenderViewHostImpl::OnRequestDesktopNotificationPermission(
void RenderViewHostImpl::OnShowDesktopNotification( void RenderViewHostImpl::OnShowDesktopNotification(
const ShowDesktopNotificationHostMsgParams& params) { const ShowDesktopNotificationHostMsgParams& params) {
// Disallow HTML notifications from javascript: and file: schemes as this
// allows unwanted cross-domain access.
GURL url = params.contents_url;
if (params.is_html &&
(url.SchemeIs(kJavaScriptScheme) ||
url.SchemeIs(chrome::kFileScheme))) {
return;
}
GetContentClient()->browser()->ShowDesktopNotification( GetContentClient()->browser()->ShowDesktopNotification(
params, GetProcess()->GetID(), GetRoutingID(), false); params, GetProcess()->GetID(), GetRoutingID(), false);
} }
......
...@@ -12,8 +12,6 @@ ...@@ -12,8 +12,6 @@
IPC_STRUCT_TRAITS_BEGIN(content::ShowDesktopNotificationHostMsgParams) IPC_STRUCT_TRAITS_BEGIN(content::ShowDesktopNotificationHostMsgParams)
IPC_STRUCT_TRAITS_MEMBER(origin) IPC_STRUCT_TRAITS_MEMBER(origin)
IPC_STRUCT_TRAITS_MEMBER(is_html)
IPC_STRUCT_TRAITS_MEMBER(contents_url)
IPC_STRUCT_TRAITS_MEMBER(icon_url) IPC_STRUCT_TRAITS_MEMBER(icon_url)
IPC_STRUCT_TRAITS_MEMBER(title) IPC_STRUCT_TRAITS_MEMBER(title)
IPC_STRUCT_TRAITS_MEMBER(body) IPC_STRUCT_TRAITS_MEMBER(body)
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
namespace content { namespace content {
ShowDesktopNotificationHostMsgParams::ShowDesktopNotificationHostMsgParams() ShowDesktopNotificationHostMsgParams::ShowDesktopNotificationHostMsgParams()
: is_html(false), direction(blink::WebTextDirectionDefault), : direction(blink::WebTextDirectionDefault),
notification_id(0) { notification_id(0) {
} }
......
...@@ -19,12 +19,6 @@ struct CONTENT_EXPORT ShowDesktopNotificationHostMsgParams { ...@@ -19,12 +19,6 @@ struct CONTENT_EXPORT ShowDesktopNotificationHostMsgParams {
// URL which is the origin that created this notification. // URL which is the origin that created this notification.
GURL origin; GURL origin;
// True if this is HTML
bool is_html;
// URL which contains the HTML contents (if is_html is true), otherwise empty.
GURL contents_url;
// Contents of the notification if is_html is false. // Contents of the notification if is_html is false.
GURL icon_url; GURL icon_url;
string16 title; string16 title;
......
...@@ -35,11 +35,18 @@ NotificationProvider::~NotificationProvider() { ...@@ -35,11 +35,18 @@ NotificationProvider::~NotificationProvider() {
} }
bool NotificationProvider::show(const WebNotification& notification) { bool NotificationProvider::show(const WebNotification& notification) {
WebDocument document = render_view()->GetWebView()->mainFrame()->document();
int notification_id = manager_.RegisterNotification(notification); int notification_id = manager_.RegisterNotification(notification);
if (notification.isHTML())
return ShowHTML(notification, notification_id); ShowDesktopNotificationHostMsgParams params;
else params.origin = GURL(document.securityOrigin().toString());
return ShowText(notification, notification_id); params.icon_url = notification.iconURL();
params.title = notification.title();
params.body = notification.body();
params.direction = notification.direction();
params.notification_id = notification_id;
params.replace_id = notification.replaceId();
return Send(new DesktopNotificationHostMsg_Show(routing_id(), params));
} }
void NotificationProvider::cancel(const WebNotification& notification) { void NotificationProvider::cancel(const WebNotification& notification) {
...@@ -100,35 +107,6 @@ bool NotificationProvider::OnMessageReceived(const IPC::Message& message) { ...@@ -100,35 +107,6 @@ bool NotificationProvider::OnMessageReceived(const IPC::Message& message) {
return handled; return handled;
} }
bool NotificationProvider::ShowHTML(const WebNotification& notification,
int id) {
DCHECK(notification.isHTML());
ShowDesktopNotificationHostMsgParams params;
WebDocument document = render_view()->GetWebView()->mainFrame()->document();
params.origin = GURL(document.securityOrigin().toString());
params.is_html = true;
params.contents_url = notification.url();
params.notification_id = id;
params.replace_id = notification.replaceId();
return Send(new DesktopNotificationHostMsg_Show(routing_id(), params));
}
bool NotificationProvider::ShowText(const WebNotification& notification,
int id) {
DCHECK(!notification.isHTML());
ShowDesktopNotificationHostMsgParams params;
params.is_html = false;
WebDocument document = render_view()->GetWebView()->mainFrame()->document();
params.origin = GURL(document.securityOrigin().toString());
params.icon_url = notification.iconURL();
params.title = notification.title();
params.body = notification.body();
params.direction = notification.direction();
params.notification_id = id;
params.replace_id = notification.replaceId();
return Send(new DesktopNotificationHostMsg_Show(routing_id(), params));
}
void NotificationProvider::OnDisplay(int id) { void NotificationProvider::OnDisplay(int id) {
WebNotification notification; WebNotification notification;
bool found = manager_.GetNotification(id, &notification); bool found = manager_.GetNotification(id, &notification);
......
...@@ -38,10 +38,6 @@ class NotificationProvider : public RenderViewObserver, ...@@ -38,10 +38,6 @@ class NotificationProvider : public RenderViewObserver,
virtual void requestPermission(const blink::WebSecurityOrigin& origin, virtual void requestPermission(const blink::WebSecurityOrigin& origin,
blink::WebNotificationPermissionCallback* callback); blink::WebNotificationPermissionCallback* callback);
// Internal methods used to show notifications.
bool ShowHTML(const blink::WebNotification& notification, int id);
bool ShowText(const blink::WebNotification& notification, int id);
// IPC handlers. // IPC handlers.
void OnDisplay(int id); void OnDisplay(int id);
void OnError(int id, const blink::WebString& message); void OnError(int id, const blink::WebString& message);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment