OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/notification_provider.h" | 5 #include "content/renderer/notification_provider.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/task.h" | 8 #include "base/task.h" |
9 #include "content/common/desktop_notification_messages.h" | 9 #include "content/common/desktop_notification_messages.h" |
10 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 if (message.type() == ViewMsg_Navigate::ID) | 95 if (message.type() == ViewMsg_Navigate::ID) |
96 OnNavigate(); // Don't want to swallow the message. | 96 OnNavigate(); // Don't want to swallow the message. |
97 | 97 |
98 return handled; | 98 return handled; |
99 } | 99 } |
100 | 100 |
101 bool NotificationProvider::ShowHTML(const WebNotification& notification, | 101 bool NotificationProvider::ShowHTML(const WebNotification& notification, |
102 int id) { | 102 int id) { |
103 DCHECK(notification.isHTML()); | 103 DCHECK(notification.isHTML()); |
104 DesktopNotificationHostMsg_Show_Params params; | 104 DesktopNotificationHostMsg_Show_Params params; |
105 params.origin = | 105 WebDocument document = render_view()->webview()->mainFrame()->document(); |
106 GURL(render_view()->webview()->mainFrame()->url()).GetOrigin(); | 106 params.origin = GURL(document.securityOrigin().toString()); |
107 params.is_html = true; | 107 params.is_html = true; |
108 params.contents_url = notification.url(); | 108 params.contents_url = notification.url(); |
109 params.notification_id = id; | 109 params.notification_id = id; |
110 params.replace_id = notification.replaceId(); | 110 params.replace_id = notification.replaceId(); |
111 return Send(new DesktopNotificationHostMsg_Show(routing_id(), params)); | 111 return Send(new DesktopNotificationHostMsg_Show(routing_id(), params)); |
112 } | 112 } |
113 | 113 |
114 bool NotificationProvider::ShowText(const WebNotification& notification, | 114 bool NotificationProvider::ShowText(const WebNotification& notification, |
115 int id) { | 115 int id) { |
116 DCHECK(!notification.isHTML()); | 116 DCHECK(!notification.isHTML()); |
117 DesktopNotificationHostMsg_Show_Params params; | 117 DesktopNotificationHostMsg_Show_Params params; |
118 params.is_html = false; | 118 params.is_html = false; |
119 params.origin = GURL( | 119 WebDocument document = render_view()->webview()->mainFrame()->document(); |
120 render_view()->webview()->mainFrame()->url()).GetOrigin(); | 120 params.origin = GURL(document.securityOrigin().toString()); |
121 params.icon_url = notification.iconURL(); | 121 params.icon_url = notification.iconURL(); |
122 params.title = notification.title(); | 122 params.title = notification.title(); |
123 params.body = notification.body(); | 123 params.body = notification.body(); |
124 params.direction = notification.direction(); | 124 params.direction = notification.direction(); |
125 params.notification_id = id; | 125 params.notification_id = id; |
126 params.replace_id = notification.replaceId(); | 126 params.replace_id = notification.replaceId(); |
127 return Send(new DesktopNotificationHostMsg_Show(routing_id(), params)); | 127 return Send(new DesktopNotificationHostMsg_Show(routing_id(), params)); |
128 } | 128 } |
129 | 129 |
130 void NotificationProvider::OnDisplay(int id) { | 130 void NotificationProvider::OnDisplay(int id) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 void NotificationProvider::OnPermissionRequestComplete(int id) { | 168 void NotificationProvider::OnPermissionRequestComplete(int id) { |
169 WebNotificationPermissionCallback* callback = manager_.GetCallback(id); | 169 WebNotificationPermissionCallback* callback = manager_.GetCallback(id); |
170 DCHECK(callback); | 170 DCHECK(callback); |
171 callback->permissionRequestComplete(); | 171 callback->permissionRequestComplete(); |
172 manager_.OnPermissionRequestComplete(id); | 172 manager_.OnPermissionRequestComplete(id); |
173 } | 173 } |
174 | 174 |
175 void NotificationProvider::OnNavigate() { | 175 void NotificationProvider::OnNavigate() { |
176 manager_.Clear(); | 176 manager_.Clear(); |
177 } | 177 } |
OLD | NEW |