| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 93 |
| 94 if (message.type() == ViewMsg_Navigate::ID) | 94 if (message.type() == ViewMsg_Navigate::ID) |
| 95 OnNavigate(); // Don't want to swallow the message. | 95 OnNavigate(); // Don't want to swallow the message. |
| 96 | 96 |
| 97 return handled; | 97 return handled; |
| 98 } | 98 } |
| 99 | 99 |
| 100 bool NotificationProvider::ShowHTML(const WebNotification& notification, | 100 bool NotificationProvider::ShowHTML(const WebNotification& notification, |
| 101 int id) { | 101 int id) { |
| 102 DCHECK(notification.isHTML()); | 102 DCHECK(notification.isHTML()); |
| 103 DesktopNotificationHostMsg_Show_Params params; | 103 content::ShowDesktopNotificationHostMsgParams params; |
| 104 WebDocument document = render_view()->GetWebView()->mainFrame()->document(); | 104 WebDocument document = render_view()->GetWebView()->mainFrame()->document(); |
| 105 params.origin = GURL(document.securityOrigin().toString()); | 105 params.origin = GURL(document.securityOrigin().toString()); |
| 106 params.is_html = true; | 106 params.is_html = true; |
| 107 params.contents_url = notification.url(); | 107 params.contents_url = notification.url(); |
| 108 params.notification_id = id; | 108 params.notification_id = id; |
| 109 params.replace_id = notification.replaceId(); | 109 params.replace_id = notification.replaceId(); |
| 110 return Send(new DesktopNotificationHostMsg_Show(routing_id(), params)); | 110 return Send(new DesktopNotificationHostMsg_Show(routing_id(), params)); |
| 111 } | 111 } |
| 112 | 112 |
| 113 bool NotificationProvider::ShowText(const WebNotification& notification, | 113 bool NotificationProvider::ShowText(const WebNotification& notification, |
| 114 int id) { | 114 int id) { |
| 115 DCHECK(!notification.isHTML()); | 115 DCHECK(!notification.isHTML()); |
| 116 DesktopNotificationHostMsg_Show_Params params; | 116 content::ShowDesktopNotificationHostMsgParams params; |
| 117 params.is_html = false; | 117 params.is_html = false; |
| 118 WebDocument document = render_view()->GetWebView()->mainFrame()->document(); | 118 WebDocument document = render_view()->GetWebView()->mainFrame()->document(); |
| 119 params.origin = GURL(document.securityOrigin().toString()); | 119 params.origin = GURL(document.securityOrigin().toString()); |
| 120 params.icon_url = notification.iconURL(); | 120 params.icon_url = notification.iconURL(); |
| 121 params.title = notification.title(); | 121 params.title = notification.title(); |
| 122 params.body = notification.body(); | 122 params.body = notification.body(); |
| 123 params.direction = notification.direction(); | 123 params.direction = notification.direction(); |
| 124 params.notification_id = id; | 124 params.notification_id = id; |
| 125 params.replace_id = notification.replaceId(); | 125 params.replace_id = notification.replaceId(); |
| 126 return Send(new DesktopNotificationHostMsg_Show(routing_id(), params)); | 126 return Send(new DesktopNotificationHostMsg_Show(routing_id(), params)); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 void NotificationProvider::OnPermissionRequestComplete(int id) { | 167 void NotificationProvider::OnPermissionRequestComplete(int id) { |
| 168 WebNotificationPermissionCallback* callback = manager_.GetCallback(id); | 168 WebNotificationPermissionCallback* callback = manager_.GetCallback(id); |
| 169 DCHECK(callback); | 169 DCHECK(callback); |
| 170 callback->permissionRequestComplete(); | 170 callback->permissionRequestComplete(); |
| 171 manager_.OnPermissionRequestComplete(id); | 171 manager_.OnPermissionRequestComplete(id); |
| 172 } | 172 } |
| 173 | 173 |
| 174 void NotificationProvider::OnNavigate() { | 174 void NotificationProvider::OnNavigate() { |
| 175 manager_.Clear(); | 175 manager_.Clear(); |
| 176 } | 176 } |
| OLD | NEW |