1 /*
2 * Copyright (c) 2002-2026 Gargoyle Software Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 * https://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 package org.htmlunit.javascript.host;
16
17 import static org.htmlunit.javascript.configuration.SupportedBrowser.CHROME;
18 import static org.htmlunit.javascript.configuration.SupportedBrowser.EDGE;
19 import static org.htmlunit.javascript.configuration.SupportedBrowser.FF;
20
21 import org.htmlunit.corejs.javascript.Scriptable;
22 import org.htmlunit.javascript.configuration.JsxClass;
23 import org.htmlunit.javascript.configuration.JsxConstant;
24 import org.htmlunit.javascript.configuration.JsxConstructor;
25 import org.htmlunit.javascript.configuration.JsxStaticFunction;
26 import org.htmlunit.javascript.configuration.JsxStaticGetter;
27 import org.htmlunit.javascript.host.event.EventTarget;
28
29 /**
30 * JavaScript host object for {@code Notification}.
31 *
32 * @author Marc Guillemot
33 * @author Ronald Brill
34 * @author Ahmed Ashour
35 *
36 * @see <a href="https://developer.mozilla.org/en-US/docs/Web/API/Notification">MDN Documentation</a>
37 */
38 @JsxClass
39 public class Notification extends EventTarget {
40
41 /**
42 * The maximum number of actions supported.
43 */
44 @JsxConstant({CHROME, EDGE, FF})
45 public static final int maxActions = 2;
46
47 /**
48 * Creates an instance of this object.
49 *
50 * @param title the notification title
51 */
52 @JsxConstructor
53 public void jsConstructor(final String title) {
54 // Empty.
55 }
56
57 /**
58 * Returns the {@code permission} static property.
59 *
60 * @param thisObj the scriptable
61 * @return the current permission level
62 */
63 @JsxStaticGetter
64 public static String getPermission(final Scriptable thisObj) {
65 return "default";
66 }
67
68 /**
69 * Requests the user's permission to display notifications.
70 */
71 @JsxStaticFunction
72 public static void requestPermission() {
73 // TODO
74 }
75 }