Skip to content

Commit 5dddaaa

Browse files
authored
Merge pull request #808 from FabioPinheiro/navigator_protocol_handler_methods
Add Navigator's ProtocolHandler methods
2 parents ca3914d + 4a0df2b commit 5dddaaa

File tree

3 files changed

+79
-3
lines changed

3 files changed

+79
-3
lines changed

api-reports/2_12.txt

+8-1
Original file line numberDiff line numberDiff line change
@@ -16477,13 +16477,20 @@ Navigator[JC] def mediaDevices: MediaDevices
1647716477
Navigator[JC] def onLine: Boolean
1647816478
Navigator[JC] val permissions: Permissions
1647916479
Navigator[JC] def platform: String
16480+
Navigator[JC] def registerProtocolHandler(scheme: String, url: String): Unit
16481+
Navigator[JC] def registerProtocolHandler(scheme: String, url: URL): Unit
1648016482
Navigator[JC] def sendBeacon(url: String, data: BodyInit?): Boolean
1648116483
Navigator[JC] val serviceWorker: ServiceWorkerContainer
1648216484
Navigator[JC] def storage: StorageManager
16485+
Navigator[JC] def unregisterProtocolHandler(scheme: String, url: String): Unit
16486+
Navigator[JC] def unregisterProtocolHandler(scheme: String, url: URL): Unit
1648316487
Navigator[JC] def userAgent: String
1648416488
Navigator[JC] def vibrate(duration: Double): Boolean
1648516489
Navigator[JC] def vibrate(pattern: js.Array[Double]): Boolean
16486-
NavigatorContentUtils[JT]
16490+
NavigatorContentUtils[JT] def registerProtocolHandler(scheme: String, url: String): Unit
16491+
NavigatorContentUtils[JT] def registerProtocolHandler(scheme: String, url: URL): Unit
16492+
NavigatorContentUtils[JT] def unregisterProtocolHandler(scheme: String, url: String): Unit
16493+
NavigatorContentUtils[JT] def unregisterProtocolHandler(scheme: String, url: URL): Unit
1648716494
NavigatorGeolocation[JT] def geolocation: Geolocation
1648816495
NavigatorID[JT] def appName: String
1648916496
NavigatorID[JT] def appVersion: String

api-reports/2_13.txt

+8-1
Original file line numberDiff line numberDiff line change
@@ -16477,13 +16477,20 @@ Navigator[JC] def mediaDevices: MediaDevices
1647716477
Navigator[JC] def onLine: Boolean
1647816478
Navigator[JC] val permissions: Permissions
1647916479
Navigator[JC] def platform: String
16480+
Navigator[JC] def registerProtocolHandler(scheme: String, url: String): Unit
16481+
Navigator[JC] def registerProtocolHandler(scheme: String, url: URL): Unit
1648016482
Navigator[JC] def sendBeacon(url: String, data: BodyInit?): Boolean
1648116483
Navigator[JC] val serviceWorker: ServiceWorkerContainer
1648216484
Navigator[JC] def storage: StorageManager
16485+
Navigator[JC] def unregisterProtocolHandler(scheme: String, url: String): Unit
16486+
Navigator[JC] def unregisterProtocolHandler(scheme: String, url: URL): Unit
1648316487
Navigator[JC] def userAgent: String
1648416488
Navigator[JC] def vibrate(duration: Double): Boolean
1648516489
Navigator[JC] def vibrate(pattern: js.Array[Double]): Boolean
16486-
NavigatorContentUtils[JT]
16490+
NavigatorContentUtils[JT] def registerProtocolHandler(scheme: String, url: String): Unit
16491+
NavigatorContentUtils[JT] def registerProtocolHandler(scheme: String, url: URL): Unit
16492+
NavigatorContentUtils[JT] def unregisterProtocolHandler(scheme: String, url: String): Unit
16493+
NavigatorContentUtils[JT] def unregisterProtocolHandler(scheme: String, url: URL): Unit
1648716494
NavigatorGeolocation[JT] def geolocation: Geolocation
1648816495
NavigatorID[JT] def appName: String
1648916496
NavigatorID[JT] def appVersion: String

dom/src/main/scala/org/scalajs/dom/NavigatorContentUtils.scala

+63-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,66 @@ package org.scalajs.dom
99
import scala.scalajs.js
1010

1111
@js.native
12-
trait NavigatorContentUtils extends js.Object
12+
trait NavigatorContentUtils extends js.Object {
13+
14+
/** The Navigator method registerProtocolHandler() lets websites register their ability to open or handle particular
15+
* URL schemes (aka protocols).
16+
*
17+
* For example, this API lets webmail sites open mailto: URLs, or VoIP sites open tel: URLs.
18+
*
19+
* @see
20+
* https://developer.mozilla.org/en-US/docs/Web/API/Navigator/registerProtocolHandler
21+
*
22+
* @param scheme
23+
* A string containing the permitted scheme for the protocol that the site wishes to handle. For example, you can
24+
* register to handle SMS text message links by passing the "sms" scheme.
25+
* @param url
26+
* A string containing the URL of the handler. This URL must include %s, as a placeholder that will be replaced
27+
* with the escaped URL to be handled.
28+
* @return
29+
* undefined
30+
*
31+
* @throws DOMException.SECURITY_ERR
32+
* The user agent blocked the registration. This might happen if:
33+
* - The registered scheme (protocol) is invalid, such as a scheme the browser handles itself (https:, about:,
34+
* etc.)
35+
* - The handler URL's origin does not match the origin of the page calling this API.
36+
* - The browser requires that this function is called from a secure context.
37+
* - The browser requires that the handler's URL be over HTTPS.
38+
*
39+
* @throws DOMException.SYNTAX_ERR
40+
* The %s placeholder is missing from the handler URL
41+
*/
42+
def registerProtocolHandler(scheme: String, url: String): Unit = js.native
43+
def registerProtocolHandler(scheme: String, url: URL): Unit = js.native
44+
45+
/** The Navigator method unregisterProtocolHandler() removes a protocol handler for a given URL scheme.
46+
*
47+
* This method is the inverse of registerProtocolHandler().
48+
*
49+
* @see
50+
* https://developer.mozilla.org/en-US/docs/Web/API/Navigator/unregisterProtocolHandler
51+
*
52+
* @param scheme
53+
* A string containing the permitted scheme in the protocol handler that will be unregistered. For example, you can
54+
* unregister the handler for SMS text message links by passing the "sms" scheme.
55+
* @param url
56+
* A string containing the URL of the handler. This URL should match the one that was used to register the handler
57+
* (e.g. it must include %s).
58+
* @return
59+
* undefined
60+
*
61+
* @throws DOMException.SECURITY_ERR
62+
* The user agent blocked unregistration. This might happen if:
63+
* - The registered scheme (protocol) is invalid, such as a scheme the browser handles itself (https:, about:,
64+
* etc.)
65+
* - The handler URL's origin does not match the origin of the page calling this API.
66+
* - The browser requires that this function is called from a secure context.
67+
* - The browser requires that the handler's URL be over HTTPS.
68+
*
69+
* @throws DOMException.SYNTAX_ERR
70+
* The %s placeholder is missing from the handler URL
71+
*/
72+
def unregisterProtocolHandler(scheme: String, url: String): Unit = js.native
73+
def unregisterProtocolHandler(scheme: String, url: URL): Unit = js.native
74+
}

0 commit comments

Comments
 (0)