bool WebNotificationManager::show(Notification* notification, WebPage* page) { #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) if (!notification || !page->corePage()->settings()->notificationsEnabled()) return false; uint64_t notificationID = generateNotificationID(); m_notificationMap.set(notification, notificationID); m_notificationIDMap.set(notificationID, notification); NotificationContextMap::iterator it = m_notificationContextMap.add(notification->scriptExecutionContext(), Vector<uint64_t>()).iterator; it->value.append(notificationID); #if ENABLE(NOTIFICATIONS) m_process->parentProcessConnection()->send(Messages::WebPageProxy::ShowNotification(notification->title(), notification->body(), notification->iconURL().string(), notification->tag(), notification->lang(), notification->dir(), notification->scriptExecutionContext()->securityOrigin()->toString(), notificationID), page->pageID()); #else m_process->parentProcessConnection()->send(Messages::WebPageProxy::ShowNotification(notification->title(), notification->body(), notification->iconURL().string(), notification->replaceId(), notification->lang(), notification->dir(), notification->scriptExecutionContext()->securityOrigin()->toString(), notificationID), page->pageID()); #endif return true; #else UNUSED_PARAM(notification); UNUSED_PARAM(page); return false; #endif }
bool WebNotificationManager::show(Notification* notification, WebPage* page) { #if ENABLE(NOTIFICATIONS) if (!notification || !page->corePage()->settings()->notificationsEnabled()) return true; uint64_t notificationID = generateNotificationID(); m_notificationMap.set(notification, notificationID); m_notificationIDMap.set(notificationID, notification); NotificationContextMap::iterator it = m_notificationContextMap.find(notification->scriptExecutionContext()); if (it == m_notificationContextMap.end()) { pair<NotificationContextMap::iterator, bool> addedPair = m_notificationContextMap.add(notification->scriptExecutionContext(), Vector<uint64_t>()); it = addedPair.first; } it->second.append(notificationID); m_process->connection()->send(Messages::WebPageProxy::ShowNotification(notification->contents().title, notification->contents().body, notification->iconURL().string(), notification->scriptExecutionContext()->securityOrigin()->toString(), notificationID), page->pageID()); return true; #else return false; #endif }