Bug 44800 - Notifications should support a click event
Summary: Notifications should support a click event
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other OS X 10.5
: P2 Normal
Assignee: John Gregg
URL:
Keywords:
Depends on:
Blocks: 44836
  Show dependency treegraph
 
Reported: 2010-08-27 15:52 PDT by John Gregg
Modified: 2010-09-13 07:22 PDT (History)
2 users (show)

See Also:


Attachments
Patch (14.55 KB, patch)
2010-08-27 16:26 PDT, John Gregg
no flags Details | Formatted Diff | Diff
Patch (15.03 KB, patch)
2010-08-30 18:13 PDT, John Gregg
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Gregg 2010-08-27 15:52:30 PDT
Notifications should support a click event
Comment 1 John Gregg 2010-08-27 16:26:37 PDT
Created attachment 65782 [details]
Patch
Comment 2 David Levin 2010-08-30 14:28:51 PDT
Comment on attachment 65782 [details]
Patch

Before landing let's get a quick ok from Darin on the public api change.


> Index: WebKitTools/ChangeLog
> ===================================================================
> --- WebKitTools/ChangeLog	(revision 66270)
> +++ WebKitTools/ChangeLog	(working copy)
> @@ -1,3 +1,24 @@
> +2010-08-27  John Gregg  <johnnyg@google.com>
> +
> +        Reviewed by NOBODY (OOPS!).
> +
> +        Notifications should support a click event.
> +        Adds necessary hooks to chromium's DRT so that clicks on desktop notifications
> +        can be simulated during a layout test.  Requires storing a list of active
> +        notifications so that they can be referred to later for clicking.
> +        https://bugs.webkit.org/show_bug.cgi?id=44800
> +
> +        * DumpRenderTree/chromium/LayoutTestController.cpp:
> +        (LayoutTestController::LayoutTestController):
> +        (LayoutTestController::simulateDesktopNotificationClick):
> +        * DumpRenderTree/chromium/LayoutTestController.h:
> +        * DumpRenderTree/chromium/NotificationPresenter.cpp:
> +        (NotificationPresenter::simulateClick):
> +        (NotificationPresenter::show):
> +        (NotificationPresenter::cancel):
> +        (NotificationPresenter::objectDestroyed):
> +        * DumpRenderTree/chromium/NotificationPresenter.h:

Please consider switching to a per function comment style here in the future (and trimming the overall summary as a result).


>  
> Index: WebKitTools/DumpRenderTree/chromium/NotificationPresenter.cpp
> ===================================================================
> --- WebKitTools/DumpRenderTree/chromium/NotificationPresenter.cpp	(revision 66183)
> +++ WebKitTools/DumpRenderTree/chromium/NotificationPresenter.cpp	(working copy)
> @@ -50,17 +50,33 @@ void NotificationPresenter::grantPermiss
>      m_allowedOrigins.add(WTF::String(url.GetOrigin().spec().c_str()));
>  }
>  
> +bool NotificationPresenter::simulateClick(const WebString& title)
> +{
> +    WTF::String id(title.data(), title.length());
> +    if (m_activeNotifications.find(id) != m_activeNotifications.end()) {

Please consider a fail fast approach.

    if (m_activeNotifications.find(id) == m_activeNotifications.end())
        return false;
....

> +    WebString identifier;
> +    if (notification.isHTML())
> +        identifier = notification.url().spec().utf16();
> +    else
> +        identifier = notification.title();
> +

Consider making a function out of this, since the same thing is done at least twice.



> Index: LayoutTests/fast/notifications/notifications-click-event.html
> +            var N = window.webkitNotifications.createNotification("", "New E-mail", "Meet me tonight at 8!");
> +            N.onclick = function() { log("PASS: click event fired."); N.cancel();  }
> +            N.show();
> +	    if (window.layoutTestController) {

The formatting is a bit odd here due to TABs.
Comment 3 Darin Fisher (:fishd, Google) 2010-08-30 15:59:46 PDT
API change LGTM
Comment 4 John Gregg 2010-08-30 18:13:38 PDT
Created attachment 65990 [details]
Patch
Comment 5 John Gregg 2010-08-30 20:49:42 PDT
Updated the patch with the changes you suggested.
Comment 6 John Gregg 2010-08-31 01:59:25 PDT
Committed r66470: <http://trac.webkit.org/changeset/66470>
Comment 7 David Levin 2010-08-31 07:24:09 PDT
Comment on attachment 65990 [details]
Patch

Cleared cq+ since John landed this.
Comment 8 Ademar Reis 2010-09-13 07:22:41 PDT
Revision r66470 cherry-picked into qtwebkit-2.1 with commit d11109dced53426ff19d0e89c133cb49fac0a2c8