プロトコル取扱器

プロトコル取扱器

[3] NavigatorContentUtils インターフェイスregisterProtocolHandler メソッドは、 プロトコル取扱器利用者に提示するものです。

仕様書

メソッド

[47] HTML Standard 改訂により、 secure context 専用の機能に変更されました。 >>46

[48] この変更により、HTTPS ではこれまで通り使えますが、 素のHTTP では使えなくなりました。

[49] この変更はメソッドを実行する環境の制限についてのものですが、 メソッド引数に指定する URL には (従前通り) 同一起源ポリシーが適用されるので、 自動的にそちらも HTTPS 専用に制限されます。

処理

[44] 一般的事項はハンドラー

[27] registerProtocolHandler メソッドは、 次のようにしなければなりません >>4

  1. [30] scheme を、必須の第1引数を DOMString として解釈した結果に設定します。
  2. [31] URL を、必須の第2引数を USVString として解釈した結果に設定します。
  3. [32] 題名を、必須の第3引数を DOMString として解釈した結果に設定します。
  4. [37] 絶対URL を、URL文脈オブジェクト設定群オブジェクトに対して構文解析した結果に設定します。
  5. [33]
    ... のいずれかを満たすなら、
    1. [34] SyntaxError投げ、ここで停止します。
  6. [39] 絶対URL起源文脈オブジェクト設定群オブジェクト起源同じ起源でなければ、
    1. [40] SecurityError投げ、ここで停止します。
  7. [42] 取扱器を、取扱器に設定します。
    取扱器
    種別
    プロトコル取扱器
    proto-URL
    絶対URL
    題名
    題名
  8. [43] 取扱器について、取扱器の登録をします。

関連

[45] 標準のWebブラウザー

歴史

[6] Firefox3navigator.registerProtocolHandler メソッドを呼び出すと、閲覧領域上部にメッセージ欄が現れて、 プロトコル取扱器が提供されている旨とそれを追加するボタンが現れます。 ボタンを押すと Webブラウザーにインストールされます。

一度インストールすると設定画面から削除しない限りずっと有効なようです。
インストール後にまったく同じ引数メソッドを呼び出すと、 ボタンなしでインストール済みですというメッセージが出てくるようです。

[7] その後登録した URL scheme を使おうとするとプログラム選択のが出てきて、 そこから選ぶと引数で指定した URL が使われます。この選択のには「以後表示しない」 というチェックがついていて、それをチェックしておくと次からは聞かれません。

[8] 同じ URL scheme について別の URL を登録すると、 >>7 の選択肢として新たに追加されます。 以後表示しないとしていてもまた勝手に聞かれるようになるみたいです。

[19] Chrome では、複数登録されていても、いずれか標準で選択されたものが使われるようです。 どれを選択するかは設定画面で決定できます。

[18] Windows 上の Chrome は、 OSURL scheme取扱器としても登録するようです。

[20] Windows 上の Firefox は、 OSURL scheme取扱器Firefox取扱器の一覧を非モーダルなダイアログで表示し、選択させるようです。 OSURL scheme として登録はしないようです。

[1] Web-based protocol handlers - MDC ( 版) https://developer.mozilla.org/ja/Web-based_protocol_handlers

[2] registerProtocolHandler - MDC ( 版) https://developer.mozilla.org/ja/DOM/window.navigator.registerProtocolHandler

[5] 登録が有効なのは登録した文書ないし起源だけかと思い込んでいましたが、 そうではなく Webブラウザー上のほぼあらゆる URL 処理に適用されるのですね。 Firefox3 で試しましたが、起源に関わらず a, img, iframe, WebブラウザーURL 入力欄などいろいろな場所で使えました。

[9] : ぐぐってみると、 mailto:GMail を登録するために使っている人が多いみたいですね。他には msnim: に使っている例も見かけました。 それ以外は見てないなあ。

[10] IRC logs: freenode / #whatwg / 20100111 ( 版) http://krijnhoetmer.nl/irc-logs/whatwg/20100111

[11] Web Applications 1.0 r6523 registerProtocolHandler() and registerContentHandler() security updates ( ( 版)) http://html5.org/tools/web-apps-tracker?from=6522&to=6523

[12] [whatwg] Proposal to extend registerProtocolHandler ( ( 版)) http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-August/032986.html

[13] Web Applications 1.0 r6524 Add an API to unregister a handler and an API to check if a handler is registered. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=6523&to=6524

[14] Web Applications 1.0 r8051 Add more schemes to the registerProtocolHandler whitelist ( ( 版)) http://html5.org/tools/web-apps-tracker?from=8050&to=8051

[15] Re: Allow javascript: URIs for registerProtocolHandler ( (Ian Hickson 著, 版)) http://lists.w3.org/Archives/Public/public-webapps/2013OctDec/0622.html

[16] registerProtocolHandler() & registerContentHandler() — Anne’s Blog ( ( 版)) http://annevankesteren.nl/2014/08/registerprotocolhandler

[17] 1056860 – Improve registerProtocolHandler() ( ( 版)) https://bugzilla.mozilla.org/show_bug.cgi?id=1056860

[21] Fate of registerProtocolHandler() / registerContentHandler() and friends? · Issue #630 · whatwg/html ( 版) https://github.com/whatwg/html/issues/630

[22] 26876 – Title argument for both registerProtoclHandler() and registerContentHandler() should be removed as i [...] ( 版) https://www.w3.org/Bugs/Public/show_bug.cgi?id=26876

[23] URLs are parsed and produce records · whatwg/html@30bc255 ( 版) https://github.com/whatwg/html/commit/30bc2557105ad62881ec9670f253febbc9761b44

[24] Use USVString for all URLs ( (domenic著, )) https://github.com/whatwg/html/commit/018b983b77b2cd908f6d00100e7e0abe893dd2c3

[25] Use URL's HTTP(S) scheme concept and define rel=icon better ( (annevk著, )) https://github.com/whatwg/html/commit/a932f7dfd5e50101db47a373cee27b04ed108934

[26] Use relevant settings object in protocol handlers (domenic著, ) https://github.com/whatwg/html/commit/413c1ccc43c9b16ff5c73585092f8721dea305c7

[28] Add version control URI schemes to registerProtocolHandler safelist by joshtriplett · Pull Request #1829 · whatwg/html () https://github.com/whatwg/html/pull/1829

[29] URL scheme for remote follow, share buttons · Issue #2291 · tootsuite/mastodon ( ()) https://github.com/tootsuite/mastodon/issues/2291

[41] Fate of registerProtocolHandler() / registerContentHandler() and friends? · Issue #630 · whatwg/html () https://github.com/whatwg/html/issues/630

[46] Restrict (un)registerProtocolHandler to secure contexts (ericlaw1979, , ) https://github.com/whatwg/html/commit/6772a0342e6ffebc922c60c770dce87371b6c968

[50] registerProtocolHandler and unregisterProtocolHandler should require SecureContext · Issue #5068 · whatwg/html () https://github.com/whatwg/html/issues/5068

[51] Restrict use of `registerProtocolHandler` to secure contexts · Issue #4017 · whatwg/html () https://github.com/whatwg/html/issues/4017

[52] Add SecureContext limitation for [un]registerProtocolHandler API by ericlaw1979 · Pull Request #5080 · whatwg/html () https://github.com/whatwg/html/pull/5080