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

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

Issue 901843006: Allow the embedder to disable the Notification constructor. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months 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
« no previous file with comments | « Source/modules/notifications/Notification.h ('k') | Source/modules/notifications/Notification.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/notifications/Notification.cpp
diff --git a/Source/modules/notifications/Notification.cpp b/Source/modules/notifications/Notification.cpp
index 0b06e7432c57bf49d97dadededf07bbe52f831c7..4fbf7eb9b9f1481742549890101193ebfc5d26f2 100644
--- a/Source/modules/notifications/Notification.cpp
+++ b/Source/modules/notifications/Notification.cpp
@@ -40,6 +40,7 @@
#include "core/frame/UseCounter.h"
#include "modules/notifications/NotificationOptions.h"
#include "modules/notifications/NotificationPermissionClient.h"
+#include "platform/RuntimeEnabledFeatures.h"
#include "platform/UserGestureIndicator.h"
#include "public/platform/Platform.h"
#include "public/platform/WebSerializedOrigin.h"
@@ -56,8 +57,15 @@ WebNotificationManager* notificationManager()
} // namespace
-Notification* Notification::create(ExecutionContext* context, const String& title, const NotificationOptions& options)
+Notification* Notification::create(ExecutionContext* context, const String& title, const NotificationOptions& options, ExceptionState& exceptionState)
{
+ // The Web Notification constructor may be disabled through a runtime feature. The
+ // behavior of the constructor is changing, but not completely agreed upon yet.
+ if (!RuntimeEnabledFeatures::notificationConstructorEnabled()) {
+ exceptionState.throwTypeError("Illegal constructor. Use ServiceWorkerRegistration.showNotification() instead.");
+ return nullptr;
+ }
+
Notification* notification = new Notification(title, context);
notification->setBody(options.body());
« no previous file with comments | « Source/modules/notifications/Notification.h ('k') | Source/modules/notifications/Notification.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698