Diff
Modified: trunk/LayoutTests/ChangeLog (216966 => 216967)
--- trunk/LayoutTests/ChangeLog 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/LayoutTests/ChangeLog 2017-05-17 03:22:38 UTC (rev 216967)
@@ -1,3 +1,14 @@
+2017-05-16 Sam Weinig <s...@webkit.org>
+
+ Bring Notification.idl up to spec
+ https://bugs.webkit.org/show_bug.cgi?id=172156
+
+ Reviewed by Chris Dumez.
+
+ * http/tests/notifications/notification-expected.txt: Added.
+ * http/tests/notifications/notification.html: Added.
+ Add test for basic Notification API functionality.
+
2017-05-16 Zalan Bujtas <za...@apple.com>
Do not skip <slot> children when collecting content for innerText.
Added: trunk/LayoutTests/http/tests/notifications/notification-expected.txt (0 => 216967)
--- trunk/LayoutTests/http/tests/notifications/notification-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/notifications/notification-expected.txt 2017-05-17 03:22:38 UTC (rev 216967)
@@ -0,0 +1,6 @@
+
+PASS The Notification constructor requires at least one argument.
+PASS The Notification object initializes its properties to their default values from the NotificationOptions dictionary if it is not provided.
+PASS The Notification object initializes its properties to the values from NotificationOptions dictionary if it is provided.
+PASS The NotificationOptions dictionary only accepts valid NotificationDirection values.
+
Added: trunk/LayoutTests/http/tests/notifications/notification.html (0 => 216967)
--- trunk/LayoutTests/http/tests/notifications/notification.html (rev 0)
+++ trunk/LayoutTests/http/tests/notifications/notification.html 2017-05-17 03:22:38 UTC (rev 216967)
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <script src=""
+ <script src=""
+</head>
+<body>
+ <div id="log"></div>
+ <div id="container"></div>
+<script>
+
+test(function() {
+ assert_throws(new TypeError(), function() { new Notification(); });
+}, "The Notification constructor requires at least one argument.");
+
+test(function() {
+ let notification = new Notification("test title");
+
+ assert_class_string(notification, "Notification");
+ assert_equals(notification.title, "test title");
+ assert_equals(notification.dir, "auto");
+ assert_equals(notification.lang, "");
+ assert_equals(notification.body, "");
+ assert_equals(notification.tag, "");
+ assert_equals(notification.icon, "");
+}, "The Notification object initializes its properties to their default values from the NotificationOptions dictionary if it is not provided.");
+
+test(function() {
+ let notification = new Notification("test title", {
+ dir: "ltr",
+ lang: "en",
+ body: "test body",
+ tag: "test tag",
+ icon: "foo.png"
+ });
+
+ assert_equals(notification.title, "test title");
+ assert_equals(notification.dir, "ltr");
+ assert_equals(notification.lang, "en");
+ assert_equals(notification.body, "test body");
+ assert_equals(notification.tag, "test tag");
+ assert_equals(notification.icon, "http://127.0.0.1:8000/notifications/foo.png");
+}, "The Notification object initializes its properties to the values from NotificationOptions dictionary if it is provided.");
+
+test(function() {
+ let notification1 = new Notification("test title", { dir: "auto" });
+ assert_equals(notification1.dir, "auto");
+
+ let notification2 = new Notification("test title", { dir: "ltr" });
+ assert_equals(notification2.dir, "ltr");
+
+ let notification3 = new Notification("test title", { dir: "rtl" });
+ assert_equals(notification3.dir, "rtl");
+
+ assert_throws(new TypeError(), function() { new Notification("test title", { dir: "foo" }) });
+}, "The NotificationOptions dictionary only accepts valid NotificationDirection values.");
+
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/CMakeLists.txt (216966 => 216967)
--- trunk/Source/WebCore/CMakeLists.txt 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebCore/CMakeLists.txt 2017-05-17 03:22:38 UTC (rev 216967)
@@ -260,6 +260,7 @@
Modules/navigatorcontentutils/NavigatorContentUtils.idl
Modules/notifications/Notification.idl
+ Modules/notifications/NotificationPermission.idl
Modules/notifications/NotificationPermissionCallback.idl
Modules/proximity/DeviceProximityEvent.idl
Modified: trunk/Source/WebCore/ChangeLog (216966 => 216967)
--- trunk/Source/WebCore/ChangeLog 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebCore/ChangeLog 2017-05-17 03:22:38 UTC (rev 216967)
@@ -1,3 +1,36 @@
+2017-05-16 Sam Weinig <s...@webkit.org>
+
+ Bring Notification.idl up to spec
+ https://bugs.webkit.org/show_bug.cgi?id=172156
+
+ Reviewed by Chris Dumez.
+
+ Test: http/tests/notifications/notification.html
+
+ * CMakeLists.txt:
+ * DerivedSources.make:
+ * WebCore.xcodeproj/project.pbxproj:
+ Add new files.
+
+ * Modules/notifications/Notification.cpp:
+ (WebCore::Notification::create):
+ (WebCore::Notification::Notification):
+ (WebCore::Notification::show):
+ (WebCore::directionString): Deleted.
+ (WebCore::Notification::permission): Deleted.
+ (WebCore::Notification::permissionString): Deleted.
+ * Modules/notifications/Notification.h:
+ * Modules/notifications/Notification.idl:
+ * Modules/notifications/NotificationClient.h:
+ * Modules/notifications/NotificationDirection.h: Added.
+ * Modules/notifications/NotificationPermission.h: Added.
+ * Modules/notifications/NotificationPermission.idl: Added.
+ * Modules/notifications/NotificationPermissionCallback.h:
+ * Modules/notifications/NotificationPermissionCallback.idl:
+ Bring up to spec, replacing DOMStrings with enums where appropriate and adding
+ additional readonly properties to Notification to mirror options provided
+ in construction.
+
2017-05-16 Zalan Bujtas <za...@apple.com>
Do not skip <slot> children when collecting content for innerText.
Modified: trunk/Source/WebCore/DerivedSources.make (216966 => 216967)
--- trunk/Source/WebCore/DerivedSources.make 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebCore/DerivedSources.make 2017-05-17 03:22:38 UTC (rev 216967)
@@ -203,6 +203,7 @@
$(WebCore)/Modules/mediastream/RTCStatsReport.idl \
$(WebCore)/Modules/mediastream/RTCTrackEvent.idl \
$(WebCore)/Modules/notifications/Notification.idl \
+ $(WebCore)/Modules/notifications/NotificationPermission.idl \
$(WebCore)/Modules/notifications/NotificationPermissionCallback.idl \
$(WebCore)/Modules/plugins/QuickTimePluginReplacement.idl \
$(WebCore)/Modules/quota/DOMWindowQuota.idl \
Modified: trunk/Source/WebCore/Modules/notifications/Notification.cpp (216966 => 216967)
--- trunk/Source/WebCore/Modules/notifications/Notification.cpp 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebCore/Modules/notifications/Notification.cpp 2017-05-17 03:22:38 UTC (rev 216967)
@@ -39,6 +39,7 @@
#include "Event.h"
#include "EventNames.h"
#include "ExceptionCode.h"
+#include "NotificationClient.h"
#include "NotificationController.h"
#include "NotificationPermissionCallback.h"
#include "WindowFocusAllowedIndicator.h"
@@ -45,12 +46,29 @@
namespace WebCore {
-Notification::Notification(Document& document, const String& title)
+Ref<Notification> Notification::create(Document& context, const String& title, const Options& options)
+{
+ auto notification = adoptRef(*new Notification(context, title, options));
+ notification->suspendIfNeeded();
+ return notification;
+}
+
+Notification::Notification(Document& document, const String& title, const Options& options)
: ActiveDOMObject(&document)
, m_title(title)
+ , m_direction(options.dir)
+ , m_lang(options.lang)
+ , m_body(options.body)
+ , m_tag(options.tag)
, m_state(Idle)
, m_taskTimer(std::make_unique<Timer>([this] () { show(); }))
{
+ if (!options.icon.isEmpty()) {
+ auto iconURL = document.completeURL(options.icon);
+ if (iconURL.isValid())
+ m_icon = iconURL;
+ }
+
m_taskTimer->startOneShot(0_s);
}
@@ -58,40 +76,8 @@
{
}
-static String directionString(Notification::Direction direction)
+void Notification::show()
{
- // FIXME: Storing this as a string is not the right way to do it.
- // FIXME: Seems highly unlikely that this does the right thing for Auto.
- switch (direction) {
- case Notification::Direction::Auto:
- return ASCIILiteral("auto");
- case Notification::Direction::Ltr:
- return ASCIILiteral("ltr");
- case Notification::Direction::Rtl:
- return ASCIILiteral("rtl");
- }
- ASSERT_NOT_REACHED();
- return { };
-}
-
-Ref<Notification> Notification::create(Document& context, const String& title, const Options& options)
-{
- auto notification = adoptRef(*new Notification(context, title));
- notification->m_body = options.body;
- notification->m_tag = options.tag;
- notification->m_lang = options.lang;
- notification->m_direction = directionString(options.dir);
- if (!options.icon.isEmpty()) {
- auto iconURL = context.completeURL(options.icon);
- if (iconURL.isValid())
- notification->m_icon = iconURL;
- }
- notification->suspendIfNeeded();
- return notification;
-}
-
-void Notification::show()
-{
// prevent double-showing
if (m_state != Idle)
return;
@@ -102,7 +88,7 @@
auto& client = NotificationController::from(page)->client();
- if (client.checkPermission(scriptExecutionContext()) != NotificationClient::PermissionAllowed) {
+ if (client.checkPermission(scriptExecutionContext()) != Permission::Granted) {
dispatchErrorEvent();
return;
}
@@ -178,25 +164,11 @@
dispatchEvent(Event::create(eventNames().errorEvent, false, false));
}
-String Notification::permission(Document& document)
+auto Notification::permission(Document& document) -> Permission
{
- return permissionString(NotificationController::from(document.page())->client().checkPermission(&document));
+ return NotificationController::from(document.page())->client().checkPermission(&document);
}
-String Notification::permissionString(NotificationClient::Permission permission)
-{
- switch (permission) {
- case NotificationClient::PermissionAllowed:
- return ASCIILiteral("granted");
- case NotificationClient::PermissionDenied:
- return ASCIILiteral("denied");
- case NotificationClient::PermissionNotAllowed:
- return ASCIILiteral("default");
- }
- ASSERT_NOT_REACHED();
- return { };
-}
-
void Notification::requestPermission(Document& document, RefPtr<NotificationPermissionCallback>&& callback)
{
NotificationController::from(document.page())->client().requestPermission(&document, WTFMove(callback));
Modified: trunk/Source/WebCore/Modules/notifications/Notification.h (216966 => 216967)
--- trunk/Source/WebCore/Modules/notifications/Notification.h 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebCore/Modules/notifications/Notification.h 2017-05-17 03:22:38 UTC (rev 216967)
@@ -36,7 +36,8 @@
#include "ActiveDOMObject.h"
#include "EventTarget.h"
#include "ExceptionOr.h"
-#include "NotificationClient.h"
+#include "NotificationDirection.h"
+#include "NotificationPermission.h"
#include "Timer.h"
#include "URL.h"
#include "WritingMode.h"
@@ -49,7 +50,9 @@
class Notification final : public RefCounted<Notification>, public ActiveDOMObject, public EventTargetWithInlineData {
WTF_MAKE_FAST_ALLOCATED;
public:
- enum class Direction { Auto, Ltr, Rtl };
+ using Permission = NotificationPermission;
+ using Direction = NotificationDirection;
+
struct Options {
Direction dir;
String lang;
@@ -64,21 +67,14 @@
void show();
void close();
- const URL& iconURL() const { return m_icon; }
const String& title() const { return m_title; }
+ Direction dir() const { return m_direction; }
const String& body() const { return m_body; }
const String& lang() const { return m_lang; }
-
- const String& dir() const { return m_direction; }
- void setDir(const String& dir) { m_direction = dir; }
-
- const String& replaceId() const { return m_tag; }
- void setReplaceId(const String& replaceId) { m_tag = replaceId; }
-
const String& tag() const { return m_tag; }
- void setTag(const String& tag) { m_tag = tag; }
+ const URL& icon() const { return m_icon; }
- TextDirection direction() const { return m_direction == "rtl" ? RTL : LTR; }
+ TextDirection direction() const { return m_direction == Direction::Rtl ? RTL : LTR; }
WEBCORE_EXPORT void dispatchClickEvent();
WEBCORE_EXPORT void dispatchCloseEvent();
@@ -87,8 +83,7 @@
WEBCORE_EXPORT void finalize();
- static String permission(Document&);
- WEBCORE_EXPORT static String permissionString(NotificationClient::Permission);
+ static Permission permission(Document&);
static void requestPermission(Document&, RefPtr<NotificationPermissionCallback>&&);
ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); }
@@ -97,7 +92,7 @@
using RefCounted::deref;
private:
- Notification(Document&, const String& title);
+ Notification(Document&, const String& title, const Options&);
EventTargetInterface eventTargetInterface() const final { return NotificationEventTargetInterfaceType; }
@@ -109,12 +104,12 @@
void refEventTarget() final { ref(); }
void derefEventTarget() final { deref(); }
- URL m_icon;
String m_title;
+ Direction m_direction;
+ String m_lang;
String m_body;
- String m_direction;
- String m_lang;
String m_tag;
+ URL m_icon;
enum State { Idle, Showing, Closed };
State m_state { Idle };
Modified: trunk/Source/WebCore/Modules/notifications/Notification.idl (216966 => 216967)
--- trunk/Source/WebCore/Modules/notifications/Notification.idl 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebCore/Modules/notifications/Notification.idl 2017-05-17 03:22:38 UTC (rev 216967)
@@ -36,19 +36,59 @@
Constructor(DOMString title, optional NotificationOptions options),
ConstructorCallWith=Document,
] interface Notification : EventTarget {
- void show();
- void close();
+ [CallWith=Document] static readonly attribute NotificationPermission permission;
+ [CallWith=Document] static void requestPermission(optional NotificationPermissionCallback? deprecatedCallback); // FIXME: This should return a Promise<NotificationPermission>.
- [CallWith=Document] static readonly attribute DOMString permission;
- [CallWith=Document] static void requestPermission(optional NotificationPermissionCallback? callback);
+ // static readonly attribute unsigned long maxActions;
attribute EventHandler onclick;
attribute EventHandler onerror;
+
+ readonly attribute DOMString title;
+ readonly attribute NotificationDirection dir;
+ readonly attribute DOMString lang;
+ readonly attribute DOMString body;
+ readonly attribute DOMString tag;
+ // readonly attribute USVString image;
+ readonly attribute USVString icon;
+ // readonly attribute USVString badge;
+ // readonly attribute USVString sound;
+ // [SameObject] readonly attribute FrozenArray<unsigned long> vibrate;
+ // readonly attribute DOMTimeStamp timestamp;
+ // readonly attribute boolean renotify;
+ // readonly attribute boolean silent;
+ // readonly attribute boolean requireInteraction;
+ // [SameObject] readonly attribute any data;
+ // [SameObject] readonly attribute FrozenArray<NotificationAction> actions;
+
+ void close();
+
+ // Legacy. Not in the specification.
+ void show();
+
attribute EventHandler onclose;
[ImplementedAs=onshow] attribute EventHandler ondisplay;
attribute EventHandler onshow;
+};
- attribute DOMString tag;
+[
+ Conditional=NOTIFICATIONS
+] dictionary NotificationOptions {
+ NotificationDirection dir = "auto";
+ DOMString lang = "";
+ DOMString body = "";
+ DOMString tag = "";
+ // USVString image;
+ USVString icon;
+ // USVString badge;
+ // USVString sound;
+ // VibratePattern vibrate;
+ // DOMTimeStamp timestamp;
+ // boolean renotify = false;
+ // boolean silent = false;
+ // boolean requireInteraction = false;
+ // any data = ""
+ // sequence<NotificationAction> actions = [];
};
[
@@ -58,13 +98,3 @@
"ltr",
"rtl"
};
-
-[
- Conditional=NOTIFICATIONS
-] dictionary NotificationOptions {
- NotificationDirection dir = "auto";
- DOMString lang = "";
- DOMString body = "";
- DOMString tag = "";
- DOMString icon;
-};
Modified: trunk/Source/WebCore/Modules/notifications/NotificationClient.h (216966 => 216967)
--- trunk/Source/WebCore/Modules/notifications/NotificationClient.h 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebCore/Modules/notifications/NotificationClient.h 2017-05-17 03:22:38 UTC (rev 216967)
@@ -31,6 +31,7 @@
#pragma once
+#include "NotificationPermission.h"
#include <wtf/Forward.h>
namespace WebCore {
@@ -39,15 +40,10 @@
class NotificationPermissionCallback;
class Page;
class ScriptExecutionContext;
-class VoidCallback;
class NotificationClient {
public:
- enum Permission {
- PermissionAllowed, // User has allowed notifications
- PermissionNotAllowed, // User has not yet allowed
- PermissionDenied // User has explicitly denied permission
- };
+ using Permission = NotificationPermission;
// Requests that a notification be shown.
virtual bool show(Notification*) = 0;
Copied: trunk/Source/WebCore/Modules/notifications/NotificationDirection.h (from rev 216966, trunk/Source/WebKit2/UIProcess/Notifications/WebNotification.cpp) (0 => 216967)
--- trunk/Source/WebCore/Modules/notifications/NotificationDirection.h (rev 0)
+++ trunk/Source/WebCore/Modules/notifications/NotificationDirection.h 2017-05-17 03:22:38 UTC (rev 216967)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace WebCore {
+
+enum class NotificationDirection {
+ Auto,
+ Ltr,
+ Rtl
+};
+
+}
Copied: trunk/Source/WebCore/Modules/notifications/NotificationPermission.h (from rev 216966, trunk/Source/WebKit2/UIProcess/Notifications/WebNotification.cpp) (0 => 216967)
--- trunk/Source/WebCore/Modules/notifications/NotificationPermission.h (rev 0)
+++ trunk/Source/WebCore/Modules/notifications/NotificationPermission.h 2017-05-17 03:22:38 UTC (rev 216967)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace WebCore {
+
+enum class NotificationPermission {
+ Default,
+ Denied,
+ Granted
+};
+
+}
Copied: trunk/Source/WebCore/Modules/notifications/NotificationPermission.idl (from rev 216966, trunk/Source/WebKit2/UIProcess/Notifications/WebNotification.cpp) (0 => 216967)
--- trunk/Source/WebCore/Modules/notifications/NotificationPermission.idl (rev 0)
+++ trunk/Source/WebCore/Modules/notifications/NotificationPermission.idl 2017-05-17 03:22:38 UTC (rev 216967)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+ Conditional=NOTIFICATIONS,
+] enum NotificationPermission {
+ "default",
+ "denied",
+ "granted"
+};
Modified: trunk/Source/WebCore/Modules/notifications/NotificationPermissionCallback.h (216966 => 216967)
--- trunk/Source/WebCore/Modules/notifications/NotificationPermissionCallback.h 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebCore/Modules/notifications/NotificationPermissionCallback.h 2017-05-17 03:22:38 UTC (rev 216967)
@@ -27,6 +27,7 @@
#if ENABLE(NOTIFICATIONS)
+#include "Notification.h"
#include <wtf/Forward.h>
#include <wtf/RefCounted.h>
@@ -35,7 +36,7 @@
class NotificationPermissionCallback : public RefCounted<NotificationPermissionCallback> {
public:
virtual ~NotificationPermissionCallback() { }
- virtual bool handleEvent(const String& permission) = 0;
+ virtual bool handleEvent(Notification::Permission) = 0;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/notifications/NotificationPermissionCallback.idl (216966 => 216967)
--- trunk/Source/WebCore/Modules/notifications/NotificationPermissionCallback.idl 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebCore/Modules/notifications/NotificationPermissionCallback.idl 2017-05-17 03:22:38 UTC (rev 216967)
@@ -25,5 +25,4 @@
[
Conditional=NOTIFICATIONS,
-] callback NotificationPermissionCallback = void (DOMString permission);
-
+] callback NotificationPermissionCallback = void (NotificationPermission permission);
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (216966 => 216967)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-05-17 03:22:38 UTC (rev 216967)
@@ -3212,6 +3212,10 @@
7CC01D0B1E4A7B0400E529CC /* JSDOMConstructorBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C0CEF2F1E4A58AD008DEB80 /* JSDOMConstructorBase.cpp */; };
7CC01D0C1E4A7B0400E529CC /* JSDOMConstructorWithDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C0CEF301E4A58F1008DEB80 /* JSDOMConstructorWithDocument.cpp */; };
7CC289DF1AA0FE5D009A9CE3 /* URLRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = CDEE393817974274001D7580 /* URLRegistry.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 7CC2DDFB1EC9415A0027B774 /* NotificationPermission.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CC2DDF81EC9415A0027B774 /* NotificationPermission.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 7CC2DE001EC95A440027B774 /* JSNotificationPermission.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CC2DDFE1EC95A440027B774 /* JSNotificationPermission.cpp */; };
+ 7CC2DE011EC95A440027B774 /* JSNotificationPermission.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CC2DDFF1EC95A440027B774 /* JSNotificationPermission.h */; };
+ 7CC2DE031ECA04A50027B774 /* NotificationDirection.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CC2DE021ECA04A50027B774 /* NotificationDirection.h */; settings = {ATTRIBUTES = (Private, ); }; };
7CC564B818BABEA6001B9652 /* TelephoneNumberDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CC564B618BABEA6001B9652 /* TelephoneNumberDetector.h */; };
7CC564BA18BAC720001B9652 /* TelephoneNumberDetectorCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CC564B918BAC720001B9652 /* TelephoneNumberDetectorCocoa.cpp */; };
7CC69940191EC5F500AF2270 /* JSWebKitNamespace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CC6993E191EC5F500AF2270 /* JSWebKitNamespace.cpp */; };
@@ -11241,6 +11245,11 @@
7C9DBFEC1A9C49B1000D6B25 /* JSHTMLAttachmentElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLAttachmentElement.h; sourceTree = "<group>"; };
7CB5CA3D1E525C6C00FAEF13 /* MediaQueryExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaQueryExpression.cpp; sourceTree = "<group>"; };
7CB5CA3E1E525C6C00FAEF13 /* MediaQueryExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaQueryExpression.h; sourceTree = "<group>"; };
+ 7CC2DDF81EC9415A0027B774 /* NotificationPermission.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NotificationPermission.h; sourceTree = "<group>"; };
+ 7CC2DDFA1EC9415A0027B774 /* NotificationPermission.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = NotificationPermission.idl; sourceTree = "<group>"; };
+ 7CC2DDFE1EC95A440027B774 /* JSNotificationPermission.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSNotificationPermission.cpp; sourceTree = "<group>"; };
+ 7CC2DDFF1EC95A440027B774 /* JSNotificationPermission.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSNotificationPermission.h; sourceTree = "<group>"; };
+ 7CC2DE021ECA04A50027B774 /* NotificationDirection.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NotificationDirection.h; sourceTree = "<group>"; };
7CC564B618BABEA6001B9652 /* TelephoneNumberDetector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TelephoneNumberDetector.h; sourceTree = "<group>"; };
7CC564B918BAC720001B9652 /* TelephoneNumberDetectorCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TelephoneNumberDetectorCocoa.cpp; sourceTree = "<group>"; };
7CC6993E191EC5F500AF2270 /* JSWebKitNamespace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitNamespace.cpp; sourceTree = "<group>"; };
@@ -17495,6 +17504,9 @@
33503C9910179A74003B47E1 /* NotificationClient.h */,
3128CA67147331520074C72A /* NotificationController.cpp */,
3128CA6A147331630074C72A /* NotificationController.h */,
+ 7CC2DE021ECA04A50027B774 /* NotificationDirection.h */,
+ 7CC2DDF81EC9415A0027B774 /* NotificationPermission.h */,
+ 7CC2DDFA1EC9415A0027B774 /* NotificationPermission.idl */,
31EC1DAC14FF26EA00C94662 /* NotificationPermissionCallback.h */,
31EC1D5014FEFD0800C94662 /* NotificationPermissionCallback.idl */,
);
@@ -17506,6 +17518,8 @@
children = (
33503C9F10179AD7003B47E1 /* JSNotification.cpp */,
33503CA010179AD7003B47E1 /* JSNotification.h */,
+ 7CC2DDFE1EC95A440027B774 /* JSNotificationPermission.cpp */,
+ 7CC2DDFF1EC95A440027B774 /* JSNotificationPermission.h */,
31EC1E2614FF60EE00C94662 /* JSNotificationPermissionCallback.cpp */,
31EC1E2714FF60EE00C94662 /* JSNotificationPermissionCallback.h */,
);
@@ -27428,6 +27442,7 @@
5126E6BC0A2E3B12005C29FA /* IconDatabase.h in Headers */,
516953981329A3C800B92D04 /* IconDatabaseBase.h in Headers */,
51E1ECBE0C91C90400DC255B /* IconDatabaseClient.h in Headers */,
+ 7CC2DE031ECA04A50027B774 /* NotificationDirection.h in Headers */,
513F14540AB634C400094DDF /* IconLoader.h in Headers */,
51E1ECC10C91C90400DC255B /* IconRecord.h in Headers */,
51714EA81CF4E4B1004723C4 /* IDBActiveDOMObject.h in Headers */,
@@ -27803,6 +27818,7 @@
8E4C96DD1AD4483500365A50 /* JSFetchResponse.h in Headers */,
BC00F0150E0A189500FD04E3 /* JSFile.h in Headers */,
2E3BC0CB117D3E0800B9409A /* JSFileError.h in Headers */,
+ 7CC2DE011EC95A440027B774 /* JSNotificationPermission.h in Headers */,
898785F1122E1E87003AABDA /* JSFileException.h in Headers */,
BC00F0170E0A189500FD04E3 /* JSFileList.h in Headers */,
2E94F43C119207DA00B7F75D /* JSFileReader.h in Headers */,
@@ -29525,6 +29541,7 @@
436708EE12D9CA4B00044234 /* SVGMarkerData.h in Headers */,
B2227A440D00BF220071B782 /* SVGMarkerElement.h in Headers */,
B2227A470D00BF220071B782 /* SVGMaskElement.h in Headers */,
+ 7CC2DDFB1EC9415A0027B774 /* NotificationPermission.h in Headers */,
0806E57A12893045007CED32 /* SVGMatrix.h in Headers */,
08CA3D4412894A3800FFF260 /* SVGMatrixTearOff.h in Headers */,
7CE58D5C1DD7EC9C00128552 /* SVGMatrixValue.h in Headers */,
@@ -31740,6 +31757,7 @@
836D032F1DA8A13A00FFD96B /* JSEventInit.cpp in Sources */,
93B70D6909EB0C7C009D8468 /* JSEventListener.cpp in Sources */,
E0FEF372B47C53EAC1C1FBEE /* JSEventSource.cpp in Sources */,
+ 7CC2DE001EC95A440027B774 /* JSNotificationPermission.cpp in Sources */,
C6A703325C9D0B6CDCBC4D77 /* JSEventTarget.cpp in Sources */,
BC6090200E91B8EC000C68B5 /* JSEventTargetCustom.cpp in Sources */,
3314ACEB10892086000F0E56 /* JSExceptionBase.cpp in Sources */,
Modified: trunk/Source/WebKit/mac/ChangeLog (216966 => 216967)
--- trunk/Source/WebKit/mac/ChangeLog 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebKit/mac/ChangeLog 2017-05-17 03:22:38 UTC (rev 216967)
@@ -1,3 +1,27 @@
+2017-05-16 Sam Weinig <s...@webkit.org>
+
+ Bring Notification.idl up to spec
+ https://bugs.webkit.org/show_bug.cgi?id=172156
+
+ Reviewed by Chris Dumez.
+
+ * WebCoreSupport/WebNotificationClient.h:
+ * WebCoreSupport/WebNotificationClient.mm:
+ (generateNotificationID):
+ (WebNotificationClient::show):
+ (WebNotificationClient::cancel):
+ (WebNotificationClient::clearNotifications):
+ (WebNotificationClient::notificationObjectDestroyed):
+ (WebNotificationClient::requestPermission):
+ (WebNotificationClient::hasPendingPermissionRequests):
+ (WebNotificationClient::checkPermission):
+ (-[WebNotificationPolicyListener allow]):
+ (-[WebNotificationPolicyListener deny]):
+ * WebView/WebNotification.mm:
+ (-[WebNotification iconURL]):
+ (-[WebNotification dir]):
+ Simplify #ifdefs and update for enum vs String usage.
+
2017-05-15 Said Abou-Hallawa <sabouhall...@apple.com>
Do not delete asynchronously decoded frames for large images if their clients are in the viewport
Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebNotificationClient.h (216966 => 216967)
--- trunk/Source/WebKit/mac/WebCoreSupport/WebNotificationClient.h 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebNotificationClient.h 2017-05-17 03:22:38 UTC (rev 216967)
@@ -23,22 +23,14 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#import <WebCore/NotificationClient.h>
+#if ENABLE(NOTIFICATIONS)
-#if ENABLE(NOTIFICATIONS)
#import <WebCore/Notification.h>
+#import <WebCore/NotificationClient.h>
#import <wtf/HashMap.h>
#import <wtf/RefPtr.h>
#import <wtf/RetainPtr.h>
-#endif
-namespace WebCore {
-class Notification;
-class NotificationPermissionCallback;
-class ScriptExecutionContext;
-class VoidCallback;
-}
-
@class WebNotification;
@class WebNotificationPolicyListener;
@class WebView;
@@ -48,10 +40,8 @@
WebNotificationClient(WebView *);
WebView *webView() { return m_webView; }
-#if ENABLE(NOTIFICATIONS)
// For testing purposes.
uint64_t notificationIDForTesting(WebCore::Notification*);
-#endif
private:
bool show(WebCore::Notification*) override;
@@ -59,19 +49,14 @@
void clearNotifications(WebCore::ScriptExecutionContext*) override;
void notificationObjectDestroyed(WebCore::Notification*) override;
void notificationControllerDestroyed() override;
-#if ENABLE(NOTIFICATIONS)
void requestPermission(WebCore::ScriptExecutionContext*, RefPtr<WebCore::NotificationPermissionCallback>&&) override;
-#endif
void cancelRequestsForPermission(WebCore::ScriptExecutionContext*) override { }
bool hasPendingPermissionRequests(WebCore::ScriptExecutionContext*) const override;
WebCore::NotificationClient::Permission checkPermission(WebCore::ScriptExecutionContext*) override;
-#if ENABLE(NOTIFICATIONS)
void requestPermission(WebCore::ScriptExecutionContext*, WebNotificationPolicyListener *);
-#endif
WebView *m_webView;
-#if ENABLE(NOTIFICATIONS)
HashMap<RefPtr<WebCore::Notification>, RetainPtr<WebNotification>> m_notificationMap;
typedef HashMap<RefPtr<WebCore::ScriptExecutionContext>, Vector<RetainPtr<WebNotification>>> NotificationContextMap;
@@ -78,5 +63,6 @@
NotificationContextMap m_notificationContextMap;
bool m_everRequestedPermission { false };
+};
+
#endif
-};
Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebNotificationClient.mm (216966 => 216967)
--- trunk/Source/WebKit/mac/WebCoreSupport/WebNotificationClient.mm 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebNotificationClient.mm 2017-05-17 03:22:38 UTC (rev 216967)
@@ -26,6 +26,7 @@
#import "WebNotificationClient.h"
#if ENABLE(NOTIFICATIONS)
+
#import "WebDelegateImplementationCaching.h"
#import "WebNotificationInternal.h"
#import "WebPreferencesPrivate.h"
@@ -35,11 +36,9 @@
#import <WebCore/NotificationPermissionCallback.h>
#import <WebCore/ScriptExecutionContext.h>
#import <wtf/BlockObjCExceptions.h>
-#endif
using namespace WebCore;
-#if ENABLE(NOTIFICATIONS)
@interface WebNotificationPolicyListener : NSObject <WebAllowDenyPolicyListener>
{
RefPtr<NotificationPermissionCallback> _callback;
@@ -46,15 +45,12 @@
}
- (id)initWithCallback:(RefPtr<NotificationPermissionCallback>&&)callback;
@end
-#endif
-#if ENABLE(NOTIFICATIONS)
static uint64_t generateNotificationID()
{
static uint64_t uniqueNotificationID = 1;
return uniqueNotificationID++;
}
-#endif
WebNotificationClient::WebNotificationClient(WebView *webView)
: m_webView(webView)
@@ -63,7 +59,6 @@
bool WebNotificationClient::show(Notification* notification)
{
-#if ENABLE(NOTIFICATIONS)
if (![m_webView _notificationProvider])
return false;
@@ -76,28 +71,19 @@
[[m_webView _notificationProvider] showNotification:webNotification.get() fromWebView:m_webView];
return true;
-#else
- UNUSED_PARAM(notification);
- return false;
-#endif
}
void WebNotificationClient::cancel(Notification* notification)
{
-#if ENABLE(NOTIFICATIONS)
WebNotification *webNotification = m_notificationMap.get(notification).get();
if (!webNotification)
return;
[[m_webView _notificationProvider] cancelNotification:webNotification];
-#else
- UNUSED_PARAM(notification);
-#endif
}
void WebNotificationClient::clearNotifications(ScriptExecutionContext* context)
{
-#if ENABLE(NOTIFICATIONS)
auto it = m_notificationContextMap.find(context);
if (it == m_notificationContextMap.end())
return;
@@ -114,14 +100,10 @@
[[m_webView _notificationProvider] clearNotifications:nsIDs];
m_notificationContextMap.remove(it);
-#else
- UNUSED_PARAM(context);
-#endif
}
void WebNotificationClient::notificationObjectDestroyed(Notification* notification)
{
-#if ENABLE(NOTIFICATIONS)
RetainPtr<WebNotification> webNotification = m_notificationMap.take(notification);
if (!webNotification)
return;
@@ -135,9 +117,6 @@
m_notificationContextMap.remove(it);
[[m_webView _notificationProvider] notificationDestroyed:webNotification.get()];
-#else
- UNUSED_PARAM(notification);
-#endif
}
void WebNotificationClient::notificationControllerDestroyed()
@@ -145,7 +124,6 @@
delete this;
}
-#if ENABLE(NOTIFICATIONS)
void WebNotificationClient::requestPermission(ScriptExecutionContext* context, WebNotificationPolicyListener *listener)
{
SEL selector = @selector(webView:decidePolicyForNotificationRequestFromOrigin:listener:);
@@ -160,20 +138,14 @@
[webOrigin release];
}
-#endif
bool WebNotificationClient::hasPendingPermissionRequests(ScriptExecutionContext*) const
{
-#if ENABLE(NOTIFICATIONS)
// We know permission was requested but we don't know if the client responded. In this case, we play it
// safe and presume there is one pending so that ActiveDOMObjects don't get suspended.
return m_everRequestedPermission;
-#else
- return false;
-#endif
}
-#if ENABLE(NOTIFICATIONS)
void WebNotificationClient::requestPermission(ScriptExecutionContext* context, RefPtr<NotificationPermissionCallback>&& callback)
{
BEGIN_BLOCK_OBJC_EXCEPTIONS;
@@ -182,36 +154,28 @@
[listener release];
END_BLOCK_OBJC_EXCEPTIONS;
}
-#endif
NotificationClient::Permission WebNotificationClient::checkPermission(ScriptExecutionContext* context)
{
-#if ENABLE(NOTIFICATIONS)
if (!context || !context->isDocument())
- return NotificationClient::PermissionDenied;
+ return NotificationClient::Permission::Denied;
if (![[m_webView preferences] notificationsEnabled])
- return NotificationClient::PermissionDenied;
+ return NotificationClient::Permission::Denied;
WebSecurityOrigin *webOrigin = [[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:context->securityOrigin()];
WebNotificationPermission permission = [[m_webView _notificationProvider] policyForOrigin:webOrigin];
[webOrigin release];
switch (permission) {
case WebNotificationPermissionAllowed:
- return NotificationClient::PermissionAllowed;
+ return NotificationClient::Permission::Granted;
case WebNotificationPermissionDenied:
- return NotificationClient::PermissionDenied;
+ return NotificationClient::Permission::Denied;
case WebNotificationPermissionNotAllowed:
- return NotificationClient::PermissionNotAllowed;
+ return NotificationClient::Permission::Default;
default:
- return NotificationClient::PermissionNotAllowed;
+ return NotificationClient::Permission::Default;
}
-#else
- UNUSED_PARAM(context);
- return NotificationClient::PermissionDenied;
-#endif
}
-#if ENABLE(NOTIFICATIONS)
-
uint64_t WebNotificationClient::notificationIDForTesting(WebCore::Notification* notification)
{
return [m_notificationMap.get(notification).get() notificationID];
@@ -231,13 +195,13 @@
- (void)allow
{
if (_callback)
- _callback->handleEvent(Notification::permissionString(NotificationClient::PermissionAllowed));
+ _callback->handleEvent(NotificationClient::Permission::Granted);
}
- (void)deny
{
if (_callback)
- _callback->handleEvent(Notification::permissionString(NotificationClient::PermissionDenied));
+ _callback->handleEvent(NotificationClient::Permission::Denied);
}
#if PLATFORM(IOS)
@@ -254,4 +218,5 @@
#endif
@end
+
#endif
Modified: trunk/Source/WebKit/mac/WebView/WebNotification.mm (216966 => 216967)
--- trunk/Source/WebKit/mac/WebView/WebNotification.mm 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebKit/mac/WebView/WebNotification.mm 2017-05-17 03:22:38 UTC (rev 216967)
@@ -116,7 +116,7 @@
- (NSString *)iconURL
{
#if ENABLE(NOTIFICATIONS)
- return core(self)->iconURL();
+ return core(self)->icon();
#else
return nil;
#endif
@@ -134,7 +134,14 @@
- (NSString *)dir
{
#if ENABLE(NOTIFICATIONS)
- return core(self)->dir();
+ switch (core(self)->dir()) {
+ case Notification::Direction::Auto:
+ return @"auto";
+ case Notification::Direction::Ltr:
+ return @"ltr";
+ case Notification::Direction::Rtl:
+ return @"rtl";
+ }
#else
return nil;
#endif
Modified: trunk/Source/WebKit2/ChangeLog (216966 => 216967)
--- trunk/Source/WebKit2/ChangeLog 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebKit2/ChangeLog 2017-05-17 03:22:38 UTC (rev 216967)
@@ -1,3 +1,37 @@
+2017-05-16 Sam Weinig <s...@webkit.org>
+
+ Bring Notification.idl up to spec
+ https://bugs.webkit.org/show_bug.cgi?id=172156
+
+ Reviewed by Chris Dumez.
+
+ * Shared/WebCoreArgumentCoders.h:
+ * UIProcess/API/C/WKNotification.cpp:
+ (WKNotificationCopyDir):
+ * UIProcess/Notifications/WebNotification.cpp:
+ (WebKit::WebNotification::WebNotification):
+ * UIProcess/Notifications/WebNotification.h:
+ (WebKit::WebNotification::create):
+ (WebKit::WebNotification::dir):
+ * UIProcess/Notifications/WebNotificationManagerProxy.cpp:
+ (WebKit::WebNotificationManagerProxy::show):
+ * UIProcess/Notifications/WebNotificationManagerProxy.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::showNotification):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+ * WebProcess/Notifications/NotificationPermissionRequestManager.cpp:
+ (WebKit::NotificationPermissionRequestManager::startRequest):
+ (WebKit::NotificationPermissionRequestManager::permissionLevel):
+ (WebKit::NotificationPermissionRequestManager::didReceiveNotificationPermissionDecision):
+ * WebProcess/Notifications/WebNotificationManager.cpp:
+ (WebKit::WebNotificationManager::policyForOrigin):
+ (WebKit::WebNotificationManager::show):
+ * WebProcess/WebCoreSupport/WebNotificationClient.cpp:
+ (WebKit::WebNotificationClient::checkPermission):
+ * WebProcess/WebCoreSupport/WebNotificationClient.h:
+ Update for enum vs String usage.
+
2017-05-16 Youenn Fablet <you...@apple.com>
Modernize WebKit2 getUserMedia passing of parameters
Modified: trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.h (216966 => 216967)
--- trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.h 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.h 2017-05-17 03:22:38 UTC (rev 216967)
@@ -34,6 +34,7 @@
#include <WebCore/IndexedDB.h>
#include <WebCore/MediaSelectionOption.h>
#include <WebCore/NetworkLoadMetrics.h>
+#include <WebCore/NotificationDirection.h>
#include <WebCore/PaymentHeaders.h>
#include <WebCore/RealtimeMediaSource.h>
#include <WebCore/ScrollSnapOffsetsInfo.h>
@@ -724,6 +725,15 @@
>;
};
+template<> struct EnumTraits<WebCore::NotificationDirection> {
+ using values = EnumValues<
+ WebCore::NotificationDirection,
+ WebCore::NotificationDirection::Auto,
+ WebCore::NotificationDirection::Ltr,
+ WebCore::NotificationDirection::Rtl
+ >;
+};
+
#if ENABLE(INDEXED_DATABASE)
template<> struct EnumTraits<WebCore::IndexedDB::GetAllType> {
using values = EnumValues<
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKNotification.cpp (216966 => 216967)
--- trunk/Source/WebKit2/UIProcess/API/C/WKNotification.cpp 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKNotification.cpp 2017-05-17 03:22:38 UTC (rev 216967)
@@ -28,7 +28,9 @@
#include "APISecurityOrigin.h"
#include "WKAPICast.h"
+#include "WKString.h"
#include "WebNotification.h"
+#include <WebCore/NotificationDirection.h>
using namespace WebKit;
@@ -64,7 +66,14 @@
WKStringRef WKNotificationCopyDir(WKNotificationRef notification)
{
- return toCopiedAPI(toImpl(notification)->dir());
+ switch (toImpl(notification)->dir()) {
+ case WebCore::NotificationDirection::Auto:
+ return WKStringCreateWithUTF8CString("auto");
+ case WebCore::NotificationDirection::Ltr:
+ return WKStringCreateWithUTF8CString("ltr");
+ case WebCore::NotificationDirection::Rtl:
+ return WKStringCreateWithUTF8CString("rtl");
+ }
}
WKSecurityOriginRef WKNotificationGetSecurityOrigin(WKNotificationRef notification)
Modified: trunk/Source/WebKit2/UIProcess/Notifications/WebNotification.cpp (216966 => 216967)
--- trunk/Source/WebKit2/UIProcess/Notifications/WebNotification.cpp 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebKit2/UIProcess/Notifications/WebNotification.cpp 2017-05-17 03:22:38 UTC (rev 216967)
@@ -28,7 +28,7 @@
namespace WebKit {
-WebNotification::WebNotification(const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, const String& dir, const String& originString, uint64_t notificationID)
+WebNotification::WebNotification(const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, WebCore::NotificationDirection dir, const String& originString, uint64_t notificationID)
: m_title(title)
, m_body(body)
, m_iconURL(iconURL)
Modified: trunk/Source/WebKit2/UIProcess/Notifications/WebNotification.h (216966 => 216967)
--- trunk/Source/WebKit2/UIProcess/Notifications/WebNotification.h 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebKit2/UIProcess/Notifications/WebNotification.h 2017-05-17 03:22:38 UTC (rev 216967)
@@ -31,11 +31,15 @@
#include <wtf/RefPtr.h>
#include <wtf/text/WTFString.h>
+namespace WebCore {
+enum class NotificationDirection;
+}
+
namespace WebKit {
class WebNotification : public API::ObjectImpl<API::Object::Type::Notification> {
public:
- static Ref<WebNotification> create(const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, const String& dir, const String& originString, uint64_t notificationID)
+ static Ref<WebNotification> create(const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, WebCore::NotificationDirection dir, const String& originString, uint64_t notificationID)
{
return adoptRef(*new WebNotification(title, body, iconURL, tag, lang, dir, originString, notificationID));
}
@@ -45,13 +49,13 @@
const String& iconURL() const { return m_iconURL; }
const String& tag() const { return m_tag; }
const String& lang() const { return m_lang; }
- const String& dir() const { return m_dir; }
+ WebCore::NotificationDirection dir() const { return m_dir; }
API::SecurityOrigin* origin() const { return m_origin.get(); }
uint64_t notificationID() const { return m_notificationID; }
private:
- WebNotification(const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, const String& dir, const String& originString, uint64_t notificationID);
+ WebNotification(const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, WebCore::NotificationDirection, const String& originString, uint64_t notificationID);
String m_title;
String m_body;
@@ -58,7 +62,7 @@
String m_iconURL;
String m_tag;
String m_lang;
- String m_dir;
+ WebCore::NotificationDirection m_dir;
RefPtr<API::SecurityOrigin> m_origin;
uint64_t m_notificationID;
};
Modified: trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp (216966 => 216967)
--- trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp 2017-05-17 03:22:38 UTC (rev 216967)
@@ -98,7 +98,7 @@
}
}
-void WebNotificationManagerProxy::show(WebPageProxy* webPage, const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, const String& dir, const String& originString, uint64_t pageNotificationID)
+void WebNotificationManagerProxy::show(WebPageProxy* webPage, const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, WebCore::NotificationDirection dir, const String& originString, uint64_t pageNotificationID)
{
uint64_t globalNotificationID = generateGlobalNotificationID();
RefPtr<WebNotification> notification = WebNotification::create(title, body, iconURL, tag, lang, dir, originString, globalNotificationID);
Modified: trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h (216966 => 216967)
--- trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h 2017-05-17 03:22:38 UTC (rev 216967)
@@ -34,6 +34,10 @@
#include <wtf/HashMap.h>
#include <wtf/text/StringHash.h>
+namespace WebCore {
+enum class NotificationDirection;
+}
+
namespace API {
class Array;
class SecurityOrigin;
@@ -54,7 +58,7 @@
void initializeProvider(const WKNotificationProviderBase*);
void populateCopyOfNotificationPermissions(HashMap<String, bool>&);
- void show(WebPageProxy*, const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, const String& dir, const String& originString, uint64_t pageNotificationID);
+ void show(WebPageProxy*, const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, WebCore::NotificationDirection, const String& originString, uint64_t pageNotificationID);
void cancel(WebPageProxy*, uint64_t pageNotificationID);
void clearNotifications(WebPageProxy*);
void clearNotifications(WebPageProxy*, const Vector<uint64_t>& pageNotificationIDs);
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (216966 => 216967)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2017-05-17 03:22:38 UTC (rev 216967)
@@ -5794,7 +5794,7 @@
request->deny();
}
-void WebPageProxy::showNotification(const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, const String& dir, const String& originString, uint64_t notificationID)
+void WebPageProxy::showNotification(const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, WebCore::NotificationDirection dir, const String& originString, uint64_t notificationID)
{
m_process->processPool().supplement<WebNotificationManagerProxy>()->show(this, title, body, iconURL, tag, lang, dir, originString, notificationID);
}
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (216966 => 216967)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2017-05-17 03:22:38 UTC (rev 216967)
@@ -173,6 +173,7 @@
enum class AutoplayEvent;
enum class HasInsecureContent;
+enum class NotificationDirection;
enum class ShouldSample;
template <typename> class BoxExtent;
@@ -1334,7 +1335,7 @@
RefPtr<API::Navigation> reattachToWebProcessWithItem(WebBackForwardListItem*);
void requestNotificationPermission(uint64_t notificationID, const String& originString);
- void showNotification(const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, const String& dir, const String& originString, uint64_t notificationID);
+ void showNotification(const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, WebCore::NotificationDirection, const String& originString, uint64_t notificationID);
void cancelNotification(uint64_t notificationID);
void clearNotifications(const Vector<uint64_t>& notificationIDs);
void didDestroyNotification(uint64_t notificationID);
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (216966 => 216967)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in 2017-05-17 03:22:38 UTC (rev 216967)
@@ -274,7 +274,7 @@
# Notification messages
RequestNotificationPermission(uint64_t requestID, String originIdentifier)
- ShowNotification(String title, String body, String iconURL, String tag, String lang, String dir, String originIdentifier, uint64_t notificationID)
+ ShowNotification(String title, String body, String iconURL, String tag, String lang, enum WebCore::NotificationDirection dir, String originIdentifier, uint64_t notificationID)
CancelNotification(uint64_t notificationID)
ClearNotifications(Vector<uint64_t> notificationIDs)
DidDestroyNotification(uint64_t notificationID)
Modified: trunk/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.cpp (216966 => 216967)
--- trunk/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.cpp 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.cpp 2017-05-17 03:22:38 UTC (rev 216967)
@@ -71,10 +71,10 @@
#if ENABLE(NOTIFICATIONS)
void NotificationPermissionRequestManager::startRequest(SecurityOrigin* origin, RefPtr<NotificationPermissionCallback>&& callback)
{
- NotificationClient::Permission permission = permissionLevel(origin);
- if (permission != NotificationClient::PermissionNotAllowed) {
+ auto permission = permissionLevel(origin);
+ if (permission != NotificationClient::Permission::Default) {
if (callback)
- callback->handleEvent(Notification::permissionString(permission));
+ callback->handleEvent(permission);
return;
}
@@ -114,12 +114,12 @@
{
#if ENABLE(NOTIFICATIONS)
if (!m_page->corePage()->settings().notificationsEnabled())
- return NotificationClient::PermissionDenied;
+ return NotificationClient::Permission::Denied;
return WebProcess::singleton().supplement<WebNotificationManager>()->policyForOrigin(securityOrigin);
#else
UNUSED_PARAM(securityOrigin);
- return NotificationClient::PermissionDenied;
+ return NotificationClient::Permission::Denied;
#endif
}
@@ -158,7 +158,7 @@
if (!callback)
return;
- callback->handleEvent(Notification::permissionString(allowed ? NotificationClient::PermissionAllowed : NotificationClient::PermissionDenied));
+ callback->handleEvent(allowed ? NotificationClient::Permission::Granted : NotificationClient::Permission::Denied);
#else
UNUSED_PARAM(requestID);
UNUSED_PARAM(allowed);
Modified: trunk/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp (216966 => 216967)
--- trunk/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp 2017-05-17 03:22:38 UTC (rev 216967)
@@ -105,17 +105,17 @@
{
#if ENABLE(NOTIFICATIONS)
if (!origin)
- return NotificationClient::PermissionNotAllowed;
+ return NotificationClient::Permission::Default;
ASSERT(!origin->isUnique());
auto it = m_permissionsMap.find(origin->toRawString());
if (it != m_permissionsMap.end())
- return it->value ? NotificationClient::PermissionAllowed : NotificationClient::PermissionDenied;
+ return it->value ? NotificationClient::Permission::Granted : NotificationClient::Permission::Denied;
#else
UNUSED_PARAM(origin);
#endif
- return NotificationClient::PermissionNotAllowed;
+ return NotificationClient::Permission::Default;
}
void WebNotificationManager::removeAllPermissionsForTesting()
@@ -150,7 +150,7 @@
auto it = m_notificationContextMap.add(notification->scriptExecutionContext(), Vector<uint64_t>()).iterator;
it->value.append(notificationID);
- 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());
+ m_process->parentProcessConnection()->send(Messages::WebPageProxy::ShowNotification(notification->title(), notification->body(), notification->icon().string(), notification->tag(), notification->lang(), notification->dir(), notification->scriptExecutionContext()->securityOrigin()->toString(), notificationID), page->pageID());
return true;
#else
UNUSED_PARAM(notification);
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.cpp (216966 => 216967)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.cpp 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.cpp 2017-05-17 03:22:38 UTC (rev 216967)
@@ -90,7 +90,7 @@
NotificationClient::Permission WebNotificationClient::checkPermission(ScriptExecutionContext* context)
{
if (!context || !context->isDocument())
- return NotificationClient::PermissionDenied;
+ return NotificationClient::Permission::Denied;
return m_page->notificationPermissionRequestManager()->permissionLevel(context->securityOrigin());
}
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.h (216966 => 216967)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.h 2017-05-17 02:33:28 UTC (rev 216966)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.h 2017-05-17 03:22:38 UTC (rev 216967)
@@ -54,7 +54,7 @@
void requestPermission(WebCore::ScriptExecutionContext*, RefPtr<WebCore::NotificationPermissionCallback>&&) override;
void cancelRequestsForPermission(WebCore::ScriptExecutionContext*) override;
bool hasPendingPermissionRequests(WebCore::ScriptExecutionContext*) const override;
- NotificationClient::Permission checkPermission(WebCore::ScriptExecutionContext*) override;
+ WebCore::NotificationClient::Permission checkPermission(WebCore::ScriptExecutionContext*) override;
WebPage* m_page;
};