Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2345)

Unified Diff: Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp

Issue 717273002: Implement the ServiceWorkerRegistration.showNotification() method. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: adds a test Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp
diff --git a/Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp b/Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ce61ae67fc88484b98092d2f13fd1d3ecfdeda2f
--- /dev/null
+++ b/Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp
@@ -0,0 +1,32 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "modules/notifications/ServiceWorkerRegistrationNotifications.h"
+
+#include "core/dom/DOMException.h"
+#include "core/dom/ExceptionCode.h"
+#include "core/dom/ExecutionContext.h"
+#include "modules/notifications/NotificationOptions.h"
+#include "platform/weborigin/KURL.h"
+#include "public/platform/WebNotificationData.h"
+
+namespace blink {
+
+ScriptPromise ServiceWorkerRegistrationNotifications::showNotification(ScriptState* scriptState, ServiceWorkerRegistration& serviceWorkerRegistration, const String& title, const NotificationOptions& options)
+{
+ KURL iconUrl;
+ if (options.hasIcon() && !options.icon().isEmpty()) {
+ iconUrl = scriptState->executionContext()->completeURL(options.icon());
+ if (!iconUrl.isValid())
+ iconUrl = KURL();
+ }
+
+ WebNotificationData notification(title, WebNotificationData::DirectionLeftToRight, options.lang(), options.body(), options.tag(), iconUrl);
+
+ // FIXME: Hook this up with the Blink API once it's been implemented.
+ return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(NotSupportedError, "showNotification is not implemented yet."));
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698