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

Side by Side Diff: third_party/WebKit/Source/modules/notifications/NotificationData.cpp

Issue 1656243002: Implementation of renotify flag for Notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/notifications/NotificationData.h" 5 #include "modules/notifications/NotificationData.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/SerializedScriptValue.h" 8 #include "bindings/core/v8/SerializedScriptValue.h"
9 #include "bindings/core/v8/SerializedScriptValueFactory.h" 9 #include "bindings/core/v8/SerializedScriptValueFactory.h"
10 #include "core/dom/ExecutionContext.h" 10 #include "core/dom/ExecutionContext.h"
(...skipping 19 matching lines...) Expand all
30 } // namespace 30 } // namespace
31 31
32 WebNotificationData createWebNotificationData(ExecutionContext* executionContext , const String& title, const NotificationOptions& options, ExceptionState& excep tionState) 32 WebNotificationData createWebNotificationData(ExecutionContext* executionContext , const String& title, const NotificationOptions& options, ExceptionState& excep tionState)
33 { 33 {
34 // If silent is true, the notification must not have a vibration pattern. 34 // If silent is true, the notification must not have a vibration pattern.
35 if (options.hasVibrate() && options.silent()) { 35 if (options.hasVibrate() && options.silent()) {
36 exceptionState.throwTypeError("Silent notifications must not specify vib ration patterns."); 36 exceptionState.throwTypeError("Silent notifications must not specify vib ration patterns.");
37 return WebNotificationData(); 37 return WebNotificationData();
38 } 38 }
39 39
40 // If renotify is true, the notification must have a tag.
41 if (options.renotify() && options.tag().isEmpty()) {
42 exceptionState.throwTypeError("Notifications which set the renotify flag must specify a non-empty tag.");
43 return WebNotificationData();
44 }
45
40 WebNotificationData webData; 46 WebNotificationData webData;
41 47
42 webData.title = title; 48 webData.title = title;
43 webData.direction = toDirectionEnumValue(options.dir()); 49 webData.direction = toDirectionEnumValue(options.dir());
44 webData.lang = options.lang(); 50 webData.lang = options.lang();
45 webData.body = options.body(); 51 webData.body = options.body();
46 webData.tag = options.tag(); 52 webData.tag = options.tag();
47 53
48 KURL iconUrl; 54 KURL iconUrl;
49 55
50 if (options.hasIcon() && !options.icon().isEmpty()) { 56 if (options.hasIcon() && !options.icon().isEmpty()) {
51 iconUrl = executionContext->completeURL(options.icon()); 57 iconUrl = executionContext->completeURL(options.icon());
52 if (!iconUrl.isValid()) 58 if (!iconUrl.isValid())
53 iconUrl = KURL(); 59 iconUrl = KURL();
54 } 60 }
55 61
56 webData.icon = iconUrl; 62 webData.icon = iconUrl;
57 webData.vibrate = NavigatorVibration::sanitizeVibrationPattern(options.vibra te()); 63 webData.vibrate = NavigatorVibration::sanitizeVibrationPattern(options.vibra te());
58 webData.timestamp = options.hasTimestamp() ? static_cast<double>(options.tim estamp()) : WTF::currentTimeMS(); 64 webData.timestamp = options.hasTimestamp() ? static_cast<double>(options.tim estamp()) : WTF::currentTimeMS();
65 webData.renotify = options.renotify();
59 webData.silent = options.silent(); 66 webData.silent = options.silent();
60 webData.requireInteraction = options.requireInteraction(); 67 webData.requireInteraction = options.requireInteraction();
61 68
62 if (options.hasData()) { 69 if (options.hasData()) {
63 RefPtr<SerializedScriptValue> serializedScriptValue = SerializedScriptVa lueFactory::instance().create(options.data().isolate(), options.data(), nullptr, exceptionState); 70 RefPtr<SerializedScriptValue> serializedScriptValue = SerializedScriptVa lueFactory::instance().create(options.data().isolate(), options.data(), nullptr, exceptionState);
64 if (exceptionState.hadException()) 71 if (exceptionState.hadException())
65 return WebNotificationData(); 72 return WebNotificationData();
66 73
67 Vector<char> serializedData; 74 Vector<char> serializedData;
68 serializedScriptValue->toWireBytes(serializedData); 75 serializedScriptValue->toWireBytes(serializedData);
(...skipping 22 matching lines...) Expand all
91 98
92 actions.append(webAction); 99 actions.append(webAction);
93 } 100 }
94 101
95 webData.actions = actions; 102 webData.actions = actions;
96 103
97 return webData; 104 return webData;
98 } 105 }
99 106
100 } // namespace blink 107 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698