bool NotificationPresenterImpl::show(PassRefPtr<Notification> notification)
{
    WebCore::Notification* notify = notification.get();
    ScriptExecutionContext* sec = notify->scriptExecutionContext();
    String originStr = sec->securityOrigin()->toString();
    ALOGV("Inside NotificationPresenterImpl::show notification pointer is %u and ScriptExecutionContext is %u", notify, sec);
    s_counter++;
    s_notificationMap.set(s_counter, notification);

    RefPtr<Notification> notificationptr = s_notificationMap.get(s_counter);
    ALOGV("NotificationPresenterImpl::show with res as %d, size as %d ",
        s_notificationMap.isEmpty(), s_notificationMap.size());

    KURL iconURL = notify->iconURL();
    String iconURLStr = iconURL.string();
    NotificationContents notcontent = notify->contents();
    String titleStr = notcontent.title();
    String bodyStr = notcontent.body();
    ALOGV("NotificationPresenterImpl::show is ICONURL is %s, COUNTER is %d ", iconURLStr.utf8().data(), s_counter);

    bool allow = s_notificationPermissions.get(originStr);
    if (allow || m_notificationState == NotificationPresenterImpl::AlwaysON )
         m_webViewCore->notificationManagerShow(iconURLStr, titleStr, bodyStr, s_counter);

    return true;
}
Esempio n. 2
0
Notification::Notification(const NotificationContents& contents, ScriptExecutionContext* context, ExceptionCode& ec, PassRefPtr<NotificationCenter> provider)
    : ActiveDOMObject(context, this)
    , m_isHTML(false)
    , m_contents(contents)
    , m_state(Idle)
    , m_notificationCenter(provider)
{
    ASSERT(m_notificationCenter->presenter());
    if (m_notificationCenter->presenter()->checkPermission(context) != NotificationPresenter::PermissionAllowed) {
        ec = SECURITY_ERR;
        return;
    }

    if (!contents.icon().isEmpty() && !contents.icon().isValid()) {
        ec = SYNTAX_ERR;
        return;
    }
}
Esempio n. 3
0
Notification::Notification(const NotificationContents& contents, ScriptExecutionContext* context, ExceptionCode& ec, NotificationPresenter* provider)
    : ActiveDOMObject(context, this)
    , m_isHTML(false)
    , m_contents(contents)
    , m_isShowing(false)
    , m_presenter(provider)
{
    if (m_presenter->checkPermission(context->securityOrigin()) != NotificationPresenter::PermissionAllowed) {
        ec = SECURITY_ERR;
        return;
    }

    KURL icon = context->completeURL(contents.icon());
    if (!icon.isEmpty() && !icon.isValid()) {
        ec = SYNTAX_ERR;
        return;
    }
}
Notification::Notification(const NotificationContents& contents, ScriptExecutionContext* context, ExceptionCode& ec, NotificationPresenter* provider)
    : ActiveDOMObject(context, this)
    , m_isHTML(false)
    , m_contents(contents)
    , m_isShowing(false)
    , m_presenter(provider)
{
    ASSERT(m_presenter);
    Document* document = context->isDocument() ? static_cast<Document*>(context) : 0;
    if (m_presenter->checkPermission(context->url(), document) != NotificationPresenter::PermissionAllowed) {
        ec = SECURITY_ERR;
        return;
    }
    
    KURL icon = context->completeURL(contents.icon());
    if (!icon.isEmpty() && !icon.isValid()) {
        ec = SYNTAX_ERR;
        return;
    }
}