Changeset 60960 in webkit


Ignore:
Timestamp:
Jun 10, 2010 9:32:09 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-06-10 Yael Aharon <yael.aharon@nokia.com>

Reviewed by Kenneth Rohde Christiansen.

Support for loading notification icons
https://bugs.webkit.org/show_bug.cgi?id=40396

  • http/tests/notifications: Added.
  • http/tests/notifications/icon-does-not-exist-expected.txt: Added.
  • http/tests/notifications/icon-does-not-exist.html: Added.
  • http/tests/notifications/icon-exists-cancel-expected.txt: Added.
  • http/tests/notifications/icon-exists-cancel.html: Added.
  • http/tests/notifications/icon-exists-expected.txt: Added.
  • http/tests/notifications/icon-exists-show-alert-during-load-expected.txt: Added.
  • http/tests/notifications/icon-exists-show-alert-during-load.html: Added.
  • http/tests/notifications/icon-exists.html: Added.
  • http/tests/notifications/icon-requires-auth-expected.txt: Added.
  • http/tests/notifications/icon-requires-auth.html: Added.
  • http/tests/notifications/resources: Added.
  • http/tests/notifications/resources/icon-exists.png: Added.
  • http/tests/notifications/resources/icon-requires-auth.php: Added.
  • platform/chromium/test_expectations.txt:
  • platform/gtk/Skipped:
  • platform/mac/Skipped:
  • platform/win/Skipped:

2010-06-10 Yael Aharon <yael.aharon@nokia.com>

Reviewed by Kenneth Rohde Christiansen.

Support for loading notification icons
https://bugs.webkit.org/show_bug.cgi?id=40396

Make notification objects download the icon needed for displaying the
notification before calling the NotificationPresenter to display the
notification.

An error during the download would cause the notification to be displayed
without an icon.

If a notification is in the process of download, and a new notification
is created with the same ReplaceId, the download is not cancelled
immediately and the notification is removed only after the download is
complete.

Tests: http/tests/notifications/icon-does-not-exist.html

http/tests/notifications/icon-exists-cancel.html
http/tests/notifications/icon-exists-show-alert-during-load.html
http/tests/notifications/icon-exists.html
http/tests/notifications/icon-requires-auth.html

  • notifications/Notification.cpp: (WebCore::Notification::Notification): (WebCore::Notification::~Notification): (WebCore::Notification::show): (WebCore::Notification::cancel): (WebCore::Notification::startLoading): (WebCore::Notification::stopLoading): (WebCore::Notification::didReceiveResponse): (WebCore::Notification::didReceiveData): (WebCore::Notification::didFinishLoading): (WebCore::Notification::didFail): (WebCore::Notification::didFailRedirectCheck): (WebCore::Notification::didReceiveAuthenticationCancellation): (WebCore::Notification::finishLoading):
  • notifications/Notification.h: (WebCore::Notification::iconData): (WebCore::Notification::releaseIconData): (WebCore::Notification::):
Location:
trunk
Files:
14 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r60957 r60960  
     12010-06-10  Yael Aharon  <yael.aharon@nokia.com>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        Support for loading notification icons
     6        https://bugs.webkit.org/show_bug.cgi?id=40396
     7
     8        * http/tests/notifications: Added.
     9        * http/tests/notifications/icon-does-not-exist-expected.txt: Added.
     10        * http/tests/notifications/icon-does-not-exist.html: Added.
     11        * http/tests/notifications/icon-exists-cancel-expected.txt: Added.
     12        * http/tests/notifications/icon-exists-cancel.html: Added.
     13        * http/tests/notifications/icon-exists-expected.txt: Added.
     14        * http/tests/notifications/icon-exists-show-alert-during-load-expected.txt: Added.
     15        * http/tests/notifications/icon-exists-show-alert-during-load.html: Added.
     16        * http/tests/notifications/icon-exists.html: Added.
     17        * http/tests/notifications/icon-requires-auth-expected.txt: Added.
     18        * http/tests/notifications/icon-requires-auth.html: Added.
     19        * http/tests/notifications/resources: Added.
     20        * http/tests/notifications/resources/icon-exists.png: Added.
     21        * http/tests/notifications/resources/icon-requires-auth.php: Added.
     22        * platform/chromium/test_expectations.txt:
     23        * platform/gtk/Skipped:
     24        * platform/mac/Skipped:
     25        * platform/win/Skipped:
     26
    1272010-06-10  Daniel Cheng  <dcheng@chromium.org>
    228
  • trunk/LayoutTests/platform/chromium/test_expectations.txt

    r60956 r60960  
    28492849// Flaky since at least r60276
    28502850BUG46157 WIN RELEASE : transforms/2d/transform-value-types.html = PASS TEXT
     2851
     2852// Chromium does not use the icon loader in WebCore for loading notifications.
     2853WONTFIX SKIP : http/tests/notifications = FAIL
     2854
  • trunk/LayoutTests/platform/gtk/Skipped

    r60957 r60960  
    12901290fast/fast-mobile-scrolling/no-fixed-position-elements.html
    12911291fast/notifications
     1292http/tests/notifications
    12921293fast/regex/test1.html
    12931294fast/regex/test4.html
  • trunk/LayoutTests/platform/mac/Skipped

    r60957 r60960  
    7070# This port doesn't support Notifications.
    7171fast/notifications
     72http/tests/notifications
    7273
    7374# Skipped while Eric Carlson works on a fix.
  • trunk/LayoutTests/platform/win/Skipped

    r60957 r60960  
    645645# This port doesn't support Notifications.
    646646fast/notifications
     647http/tests/notifications
    647648
    648649# MediaPlayerPrivateQuickTimeWin doesn't return to NETWORK_IDLE and hence doesn't fire a suspend event
  • trunk/WebCore/ChangeLog

    r60958 r60960  
     12010-06-10  Yael Aharon  <yael.aharon@nokia.com>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        Support for loading notification icons
     6        https://bugs.webkit.org/show_bug.cgi?id=40396
     7
     8        Make notification objects download the icon needed for displaying the
     9        notification before calling the NotificationPresenter to display the
     10        notification.
     11
     12        An error during the download would cause the notification to be displayed
     13        without an icon.
     14
     15        If a notification is in the process of download, and a new notification
     16        is created with the same ReplaceId, the download is not cancelled
     17        immediately and the notification is removed only after the download is
     18        complete.
     19 
     20        Tests: http/tests/notifications/icon-does-not-exist.html
     21               http/tests/notifications/icon-exists-cancel.html
     22               http/tests/notifications/icon-exists-show-alert-during-load.html
     23               http/tests/notifications/icon-exists.html
     24               http/tests/notifications/icon-requires-auth.html
     25
     26        * notifications/Notification.cpp:
     27        (WebCore::Notification::Notification):
     28        (WebCore::Notification::~Notification):
     29        (WebCore::Notification::show):
     30        (WebCore::Notification::cancel):
     31        (WebCore::Notification::startLoading):
     32        (WebCore::Notification::stopLoading):
     33        (WebCore::Notification::didReceiveResponse):
     34        (WebCore::Notification::didReceiveData):
     35        (WebCore::Notification::didFinishLoading):
     36        (WebCore::Notification::didFail):
     37        (WebCore::Notification::didFailRedirectCheck):
     38        (WebCore::Notification::didReceiveAuthenticationCancellation):
     39        (WebCore::Notification::finishLoading):
     40        * notifications/Notification.h:
     41        (WebCore::Notification::iconData):
     42        (WebCore::Notification::releaseIconData):
     43        (WebCore::Notification::):
     44
    1452010-06-10  Raine Makelainen  <raine.makelainen@nokia.com>
    246
  • trunk/WebCore/notifications/Notification.cpp

    r57604 r60960  
    3939#include "Document.h"
    4040#include "EventNames.h"
     41#include "ResourceRequest.h"
     42#include "ResourceResponse.h"
     43#include "ThreadableLoader.h"
    4144#include "WorkerContext.h"
    4245
     
    4649    : ActiveDOMObject(context, this)
    4750    , m_isHTML(true)
    48     , m_isShowing(false)
     51    , m_state(Idle)
    4952    , m_presenter(provider)
    5053{
     
    6770    , m_isHTML(false)
    6871    , m_contents(contents)
    69     , m_isShowing(false)
     72    , m_state(Idle)
    7073    , m_presenter(provider)
    7174{
     
    8487Notification::~Notification()
    8588{
     89    if (m_state == Loading) {
     90        ASSERT_NOT_REACHED();
     91        cancel();
     92    }
    8693    m_presenter->notificationObjectDestroyed(this);
    8794}
     
    8996void Notification::show()
    9097{
     98#if PLATFORM(QT)
     99    if (iconURL().isEmpty()) {
     100        // Set the state before actually showing, because
     101        // handling of ondisplay may rely on that.
     102        if (m_state == Idle) {
     103            m_state = Showing;
     104            m_presenter->show(this);
     105        }
     106    } else
     107        startLoading();
     108#else
    91109    // prevent double-showing
    92     if (!m_isShowing)
    93         m_isShowing = m_presenter->show(this);
     110    if (m_state == Idle && m_presenter->show(this))
     111        m_state = Showing;
     112#endif
    94113}
    95114
    96115void Notification::cancel()
    97116{
    98     if (m_isShowing)
     117    switch (m_state) {
     118    case Idle:
     119        break;
     120    case Loading:
     121        m_state = Cancelled;
     122        stopLoading();
     123        break;
     124    case Showing:
    99125        m_presenter->cancel(this);
     126        break;
     127    case Cancelled:
     128        break;
     129    }
    100130}
    101131
     
    110140}
    111141
     142
     143void Notification::startLoading()
     144{
     145    if (m_state != Idle)
     146        return;
     147    setPendingActivity(this);
     148    m_state = Loading;
     149    ThreadableLoaderOptions options;
     150    options.sendLoadCallbacks = false;
     151    options.sniffContent = false;
     152    options.forcePreflight = false;
     153    options.allowCredentials = AllowStoredCredentials;
     154    options.crossOriginRequestPolicy = AllowCrossOriginRequests;
     155    m_loader = ThreadableLoader::create(scriptExecutionContext(), this, ResourceRequest(iconURL()), options);
     156}
     157
     158void Notification::stopLoading()
     159{
     160    m_iconData = 0;
     161    RefPtr<ThreadableLoader> protect(m_loader);
     162    m_loader->cancel();
     163}
     164
     165void Notification::didReceiveResponse(const ResourceResponse& response)
     166{
     167    int status = response.httpStatusCode();
     168    if (status && (status < 200 || status > 299)) {
     169        stopLoading();
     170        return;
     171    }
     172    m_iconData = SharedBuffer::create();
     173}
     174
     175void Notification::didReceiveData(const char* data, int lengthReceived)
     176{
     177    m_iconData->append(data, lengthReceived);
     178}
     179
     180void Notification::didFinishLoading(unsigned long)
     181{
     182    finishLoading();
     183}
     184
     185void Notification::didFail(const ResourceError&)
     186{
     187    finishLoading();
     188}
     189
     190void Notification::didFailRedirectCheck()
     191{
     192    finishLoading();
     193}
     194
     195void Notification::didReceiveAuthenticationCancellation(const ResourceResponse&)
     196{
     197    finishLoading();
     198}
     199
     200void Notification::finishLoading()
     201{
     202    if (m_state == Loading) {
     203        if (m_presenter->show(this))
     204            m_state = Showing;
     205    }
     206    unsetPendingActivity(this);
     207}
     208
    112209} // namespace WebCore
    113210
  • trunk/WebCore/notifications/Notification.h

    r60569 r60960  
    4444#include "NotificationContents.h"
    4545#include "RegisteredEventListener.h"
     46#include "SharedBuffer.h"
     47#include "ThreadableLoader.h"
     48#include "ThreadableLoaderClient.h"
    4649#include <wtf/OwnPtr.h>
    4750#include <wtf/PassRefPtr.h>
     
    5457    class WorkerContext;
    5558
    56     class Notification : public RefCounted<Notification>, public ActiveDOMObject, public EventTarget {
     59    class Notification : public RefCounted<Notification>, public ActiveDOMObject, public ThreadableLoaderClient, public EventTarget {
    5760    public:
    5861        static PassRefPtr<Notification> create(const KURL& url, ScriptExecutionContext* context, ExceptionCode& ec, NotificationPresenter* provider) { return adoptRef(new Notification(url, context, ec, provider)); }
     
    8588        virtual Notification* toNotification() { return this; }
    8689
     90        void stopLoading();
     91
     92        SharedBuffer* iconData() { return m_iconData.get(); }
     93        void releaseIconData() { m_iconData = 0; }
     94
     95        virtual void didReceiveResponse(const ResourceResponse&);
     96        virtual void didReceiveData(const char* data, int lengthReceived);
     97        virtual void didFinishLoading(unsigned long identifier);
     98        virtual void didFail(const ResourceError&);
     99        virtual void didFailRedirectCheck();
     100        virtual void didReceiveAuthenticationCancellation(const ResourceResponse&);
     101
    87102    private:
    88103        Notification(const KURL&, ScriptExecutionContext*, ExceptionCode&, NotificationPresenter*);
     
    95110        virtual EventTargetData* ensureEventTargetData();
    96111
     112        void startLoading();
     113        void finishLoading();
     114
    97115        bool m_isHTML;
    98116        KURL m_notificationURL;
     
    101119        String m_direction;
    102120        String m_replaceId;
    103      
    104         bool m_isShowing;
     121
     122
     123        enum NotificationState {
     124            Idle = 0,
     125            Loading = 1,
     126            Showing = 2,
     127            Cancelled = 3
     128        };
     129
     130        NotificationState m_state;
    105131
    106132        NotificationPresenter* m_presenter;
    107133       
    108134        EventTargetData m_eventTargetData;
     135
     136        RefPtr<ThreadableLoader> m_loader;
     137        RefPtr<SharedBuffer> m_iconData;
    109138    };
    110139
Note: See TracChangeset for help on using the changeset viewer.