diff options
Diffstat (limited to 'files/fr/mozilla/add-ons/webextensions/api/runtime')
37 files changed, 4249 insertions, 0 deletions
diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/connect/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/connect/index.html new file mode 100644 index 0000000000..d92f50c9cd --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/connect/index.html @@ -0,0 +1,161 @@ +--- +title: runtime.connect() +slug: Mozilla/Add-ons/WebExtensions/API/runtime/connect +tags: + - API + - Add-ons + - Extensions + - Method + - Non-standard + - Reference + - WebExtensions + - connect + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/connect +--- +<div>{{AddonSidebar()}}</div> + +<div></div> + +<p>Créer une connexion pour plusieurs cas d'utilisation pout votre extension.</p> + +<p>Vous pouvez utiliser cette facilité dans les situations suivantes:</p> + +<ul> + <li>Dans un script de contenu, pour établir une connexion avec le script d'arrière plan (ou tout script priviligié, comme les scripts de popup ou scripts de page d'option)</li> + <li>Dans un script d'arrière plan (ou script priviligié équivalent), pour établir une connexion avec une extension différente.</li> +</ul> + +<p>Attention, vous ne pouvez pas utiliser cette fonctionnalité pour connecter une extension à son script de contenu. Pour réaliser cette opération, il vaut mieux utiliser {{WebExtAPIRef('tabs.connect()')}}.</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">var port = browser.runtime.connect( + extensionId, // optional string + connectInfo // optional object +) +</pre> + +<h3 id="Paramètres">Paramètres</h3> + +<dl> + <dt><code>extensionId</code>{{optional_inline}}</dt> + <dd><code>string</code>. L'ID de l'extension à laquelle se connecter. Si la cible à défini un ID dans la clé <a href="/fr/Add-ons/WebExtensions/manifest.json/applications">applications</a> du fichier manifest.json, alors <code>extensionId</code> doit avoir cette valeur. Autrement, il doit avoir l'ID qui a été généré pour la cible.</dd> + <dt><code>connectInfo</code>{{optional_inline}}</dt> + <dd><code>object</code>. Détails de la connexion:</dd> + <dd> + <dl class="reference-values"> + <dt><code>name</code>{{optional_inline}}</dt> + <dd><code>string</code>. Sera passé dans {{WebExtAPIRef("runtime.onConnect")}} pour les processus qui écoutent un évènement de type connexion.</dd> + <dt><code>includeTlsChannelId</code>{{optional_inline}}</dt> + <dd><code>boolean</code>. indique si l'ID du canal TLS sera transmis à {{WebExtAPIRef("runtime.onConnectExternal")}} pour le processus qui écoutent l'événement de connexion.</dd> + </dl> + </dd> +</dl> + +<h3 id="Valeur_retournée">Valeur retournée</h3> + +<p>{{WebExtAPIRef('runtime.Port')}}. Port à travers lequel les messages peuvent être envoyés et reçus. L'événement <code>onDisconnect</code> du port est déclenché si l'extension n'existe pas.</p> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.connect")}}</p> + +<h2 id="Exemples">Exemples</h2> + +<p>Le script de contenu :</p> + +<ul> + <li>se connecte au script d'arrière-plan et stocke le port dans une variable appelée <code>myPort</code>.</li> + <li>Ecoute les messages sur <code>myPort</code> et les enregistre</li> + <li>Envoie des messages au script d'arrière pla, en utilisant <code>myPort</code>, lorsque l'utilisateur clique sur le document.</li> +</ul> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="comment token">// content-script.js</span> + +<span class="keyword token">var</span> myPort <span class="operator token">=</span> browser<span class="punctuation token">.</span>runtime<span class="punctuation token">.</span><span class="function token">connect</span><span class="punctuation token">(</span><span class="punctuation token">{</span>name<span class="punctuation token">:</span><span class="string token">"port-from-cs"</span><span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> +myPort<span class="punctuation token">.</span><span class="function token">postMessage</span><span class="punctuation token">(</span><span class="punctuation token">{</span>greeting<span class="punctuation token">:</span> <span class="string token">"hello from content script"</span><span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + +myPort<span class="punctuation token">.</span>onMessage<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span><span class="keyword token">function</span><span class="punctuation token">(</span>m<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"In content script, received message from background script: "</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>m<span class="punctuation token">.</span>greeting<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + +document<span class="punctuation token">.</span>body<span class="punctuation token">.</span><span class="function token">addEventListener</span><span class="punctuation token">(</span><span class="string token">"click"</span><span class="punctuation token">,</span> <span class="keyword token">function</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> + myPort<span class="punctuation token">.</span><span class="function token">postMessage</span><span class="punctuation token">(</span><span class="punctuation token">{</span>greeting<span class="punctuation token">:</span> <span class="string token">"they clicked the page!"</span><span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<p>Les scripts d'arrière plan correspondant :</p> + +<ul> + <li>Ecoute les tentatives de connexion du script de contenu.</li> + <li>Quand il reçoit une tentative de connexion : + <ul> + <li>Stocke le port dans une variable nommé <code>portFromCS</code>.</li> + <li>envoie un message au script de contenu en utiliant le port.</li> + <li>Commence à écouter les messages reçus sur le port, et les enregistre.</li> + </ul> + </li> + <li>Envoie des messages au script de contenu, à l'aide de <code>portFromCS</code>, lorsque l'utilisateur clique sur l'action du navigateur de l'extension.</li> +</ul> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="comment token">// background-script.js</span> + +<span class="keyword token">var</span> portFromCS<span class="punctuation token">;</span> + +<span class="keyword token">function</span> <span class="function token">connected</span><span class="punctuation token">(</span>p<span class="punctuation token">)</span> <span class="punctuation token">{</span> + portFromCS <span class="operator token">=</span> p<span class="punctuation token">;</span> + portFromCS<span class="punctuation token">.</span><span class="function token">postMessage</span><span class="punctuation token">(</span><span class="punctuation token">{</span>greeting<span class="punctuation token">:</span> <span class="string token">"hi there content script!"</span><span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + portFromCS<span class="punctuation token">.</span>onMessage<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span><span class="keyword token">function</span><span class="punctuation token">(</span>m<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"In background script, received message from content script"</span><span class="punctuation token">)</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>m<span class="punctuation token">.</span>greeting<span class="punctuation token">)</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +browser<span class="punctuation token">.</span>runtime<span class="punctuation token">.</span>onConnect<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>connected<span class="punctuation token">)</span><span class="punctuation token">;</span> + +browser<span class="punctuation token">.</span>browserAction<span class="punctuation token">.</span>onClicked<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span><span class="keyword token">function</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> + portFromCS<span class="punctuation token">.</span><span class="function token">postMessage</span><span class="punctuation token">(</span><span class="punctuation token">{</span>greeting<span class="punctuation token">:</span> <span class="string token">"they clicked the button!"</span><span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/connectnative/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/connectnative/index.html new file mode 100644 index 0000000000..1371a06683 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/connectnative/index.html @@ -0,0 +1,122 @@ +--- +title: runtime.connectNative() +slug: Mozilla/Add-ons/WebExtensions/API/runtime/connectNative +tags: + - API + - Add-ons + - Extensions + - Méthode + - Non-standard + - Reference + - WebExtensions + - connectNative + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/connectNative +--- +<div>{{AddonSidebar()}}</div> + +<div>Connecte l'extension à une appplication native sur l'ordinateur de l'utilisateur.</div> + +<div></div> + +<div>Cela prend le nom d'une application native en tant que paramètre. Il démarre l'application native et retourne un objet {{WebExtAPIRef("runtime.Port")}} à l'appelant.</div> + +<div></div> + +<div>L'appelant peut utiliser le <code>Port</code> pour échanger des messages avec l'application native utilisant <code>Port.postMessage()</code> et <code>port.onMessage</code>.</div> + +<div></div> + +<div>L'application native s'exécute jusqu'à ce qu'elle se termine, ou l'appelant appelle <code>Port.disconnect()</code>, ou la page qui a créé le <code>Port</code> est détruite. Une fois le <code>Port</code> est déconnecté, le navigateur mettra quelques secondes à se terminer pour quitter le processus, puis le désactiver s'il ne s'est pas arrêté.</div> + +<div></div> + +<p>Pour plus d'informations, voir <a href="/fr/Add-ons/WebExtensions/Native_messaging">messagerie native</a>.</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">var port = browser.runtime.connectNative( + application // string +) +</pre> + +<h3 id="Paramètres">Paramètres</h3> + +<dl> + <dt><code>application</code></dt> + <dd><code>string</code>. Le nom de l'application native à laquelle se connecter. Cela doit correspondre à la propriété "name" dans le <a href="/fr/Add-ons/WebExtensions/Native_messaging#App_manifest">fichier manifest de l'application native</a>.</dd> +</dl> + +<h3 id="Valeur_retournée">Valeur retournée</h3> + +<p>Un objet {{WebExtAPIRef('runtime.Port')}}. Le port que l'appelant peut utiliser pour échanger des messages avec l'application native.</p> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.connectNative")}}</p> + +<h2 id="Exemples">Exemples</h2> + +<p>Cet exemple se connecte à l'appplication native "ping_pong" et commence à en écouter les messages. Il envoie également un message à l'application native lorsque l'utilisateur clique sur l'icône d'une action du navigateur :</p> + +<pre class="brush: js">/* +On startup, connect to the "ping_pong" app. +*/ +var port = <code class="language-js">browser</code>.runtime.connectNative("ping_pong"); + +/* +Listen for messages from the app. +*/ +port.onMessage.addListener((response) => { + console.log("Received: " + response); +}); + +/* +On a click on the browser action, send the app a message. +*/ +<code class="language-js">browser</code>.browserAction.onClicked.addListener(() => { + console.log("Sending: ping"); + port.postMessage("ping"); +});</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/getbackgroundpage/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/getbackgroundpage/index.html new file mode 100644 index 0000000000..229d43adc7 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/getbackgroundpage/index.html @@ -0,0 +1,112 @@ +--- +title: runtime.getBackgroundPage() +slug: Mozilla/Add-ons/WebExtensions/API/runtime/getBackgroundPage +tags: + - API + - Add-ons + - Extensions + - Method + - Non-standard + - Reference + - WebExtensions + - getBackgroundPage + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/getBackgroundPage +--- +<div>{{AddonSidebar()}}</div> + +<p>Récupère l'objet <code><a href="/fr/docs/Web/API/Window">Window</a></code> pour la page d'arrière-plan qui s'exécute dans l'extension en cours.</p> + +<p>Cela consiste un moyen pratique pour d'autres scripts d'extension privilégiés d'accéder directement à la portée du script d'arrière plan. Cela leur permet d'accéder aux variables ou aux fonctions d'appel définies dans cette portée. Le "script privilégié" inclut ici les scripts s'exécutant dans les <a href="/fr/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Options_pages">pages d'options</a>, ou les scripts s'exécutant dans les fenêtres d'<a href="/fr/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Browser_actions_2">action du navigateur</a> ou d'<a href="/fr/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Page_actions">action page</a>, mais n'inclut pas les <a href="/fr/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Content_scripts">scripts de contenu</a>.</p> + +<p>Notez que les variables déclarées à l'aide de <code><a href="/fr/docs/Web/JavaScript/Reference/Instructions/const">const</a></code> ou <code><a href="/fr/docs/Web/JavaScript/Reference/Instructions/let">let</a></code> n'apparaissaient pas dans l'objet window retourné par cette fonction.</p> + +<p><strong>Notez également que cette méthode ne peut pas être utilisée dans une fenêtre privée dans Firefox</strong>—Elle renvoie toujours <code>null</code>. Pour plus d'informations voir le <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1329304">bug lié à bugzilla</a>.</p> + +<p>Si la page d'arrière plan est une page événement, le système s'assuera qu'il est chargé avant de résoudre la promise.</p> + +<p>C'est une fonction asynchrone qui renvoie une <code><a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/Promise">Promise</a></code>.</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">var gettingPage = browser.runtime.getBackgroundPage() +</pre> + +<h3 id="Paramètres">Paramètres</h3> + +<p>None.</p> + +<h3 id="Valeur_retournée">Valeur retournée</h3> + +<p>Une <code><a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/Promise">Promise</a></code> qui sera remplie avec l'objet <a href="/fr/docs/User%3Amaybe/webidl_mdn/Window">Window</a> pour la page d'arrière plan, s'il y en a une. Si l'extension n'inclut pas de page d'arrière-plan, la promise est rejetée avec un message d'erreur.</p> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.getBackgroundPage")}}</p> + +<h2 id="Exemples">Exemples</h2> + +<p>Supposons un <a href="/fr/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Background_scripts">script d'arrière-plan</a> définisse une fonction <code>foo()</code>:</p> + +<pre class="brush: js">// background.js + +function foo() { + console.log("I'm defined in background.js"); +}</pre> + +<p>Un script exécuté dans un <a href="/fr/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Browser_actions_2">popup</a> peut appeler cette fonction directement comme ceci :</p> + +<pre class="brush: js">// popup.js + +function onGot(page) { + page.foo(); +} + +function onError(error) { + console.log(`Error: ${error}`); +} + +var getting = browser.runtime.getBackgroundPage(); +getting.then(onGot, onError);</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/getbrowserinfo/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/getbrowserinfo/index.html new file mode 100644 index 0000000000..f54d20f368 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/getbrowserinfo/index.html @@ -0,0 +1,63 @@ +--- +title: runtime.getBrowserInfo() +slug: Mozilla/Add-ons/WebExtensions/API/runtime/getBrowserInfo +tags: + - API + - Add-ons + - Extensions + - Method + - Reference + - WebExtensions + - getBrowserInfo + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/getBrowserInfo +--- +<div>{{AddonSidebar}}</div> + +<p>Renvoie les informations sur le navigateur dans lequel l'extension est installée.</p> + +<p>Il s'agit d'une fonction asynchrone qui renvoie une {{JSxRef("Promise")}}.</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">var gettingInfo = browser.runtime.getBrowserInfo() +</pre> + +<h3 id="Paramètres">Paramètres</h3> + +<p>None.</p> + +<h3 id="valeur_retournée">valeur retournée</h3> + +<p>Une <code><a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/Promise">Promise</a></code> qui sera remplie avec un objet qui a les propriétés suivantes :</p> + +<ul> + <li><strong><code>name</code></strong>: Valeur de chaîne représentant le nom du navigateur, par exemple "Firefox".</li> + <li><strong><code>vendor</code></strong>: Valeur de chaîne représentant le fournisseur du navigateur, par exemple "Mozilla".</li> + <li><strong><code>version</code></strong>: Chaîne représentant la version du navigateur, par exemple "51.0" or "51.0a2".</li> + <li><strong><code>buildID</code></strong>: Chaine représentant la version spécifique du navigateur, par exemple "20161018004015".</li> +</ul> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + + + +<p>{{Compat("webextensions.api.runtime.getBrowserInfo")}}</p> + +<h2 id="Exemples">Exemples</h2> + +<p>Obtenir et enregistrer le nom du navigateur :</p> + +<pre class="brush: js">function gotBrowserInfo(info) { + console.log(info.name); +} + +var gettingInfo = browser.runtime.getBrowserInfo(); +gettingInfo.then(gotBrowserInfo);</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/getmanifest/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/getmanifest/index.html new file mode 100644 index 0000000000..39f49a1749 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/getmanifest/index.html @@ -0,0 +1,86 @@ +--- +title: runtime.getManifest() +slug: Mozilla/Add-ons/WebExtensions/API/runtime/getManifest +tags: + - API + - Add-ons + - Extensions + - Method + - Non-standard + - Reference + - WebExtensions + - getManifest + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/getManifest +--- +<div>{{AddonSidebar()}}</div> + +<div>Obtenez le fichier <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json">manifest.json</a> complet, sérialisé à un objet JSON.</div> + +<div></div> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">browser.runtime.getManifest() +</pre> + +<h3 id="Paramètres">Paramètres</h3> + +<p>None.</p> + +<h3 id="Valeur_retournée">Valeur retournée</h3> + +<p>Un <code>object</code> JSON représentant le manifest.</p> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.getManifest")}}</p> + +<h2 id="Exemples">Exemples</h2> + +<p>Récupère le manifest et consignez la propriété "name" :</p> + +<pre class="brush: js">var manifest = browser.runtime.getManifest(); +console.log(manifest.name);</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/getpackagedirectoryentry/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/getpackagedirectoryentry/index.html new file mode 100644 index 0000000000..68a338db30 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/getpackagedirectoryentry/index.html @@ -0,0 +1,88 @@ +--- +title: runtime.getPackageDirectoryEntry() +slug: Mozilla/Add-ons/WebExtensions/API/runtime/getPackageDirectoryEntry +tags: + - API + - Add-ons + - Extensions + - Méthode + - Non-standard + - Reference + - WebExtensions + - getPackageDirectoryEntry + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/getPackageDirectoryEntry +--- +<div>{{AddonSidebar()}}</div> + +<p>Renvoie un objet <code>DirectoryEntry</code> représentant le répertoire du package.</p> + +<p>C'est une fonction asynchrone qui renvoie une <code><a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/Promise">Promise</a></code>.</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">var gettingEntry = browser.runtime.getPackageDirectoryEntry() +</pre> + +<h3 id="Paramètres">Paramètres</h3> + +<p>None.</p> + +<h3 id="Valeur_retournée">Valeur retournée</h3> + +<p>Une <code><a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/Promise">Promise</a></code> qui sera remplie avec un objet <code>DirectoryEntry</code> représentant le répertoire du package.</p> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.getPackageDirectoryEntry")}}</p> + +<h2 id="Exemples">Exemples</h2> + +<pre class="brush: js">function gotDirectoryEntry(directoryEntry) { + console.log(directoryEntry); +} + +var gettingEntry = browser.runtime.getPackageDirectoryEntry(); +gettingEntry.then(gotDirectoryEntry);</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/getplatforminfo/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/getplatforminfo/index.html new file mode 100644 index 0000000000..1d78399d3e --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/getplatforminfo/index.html @@ -0,0 +1,90 @@ +--- +title: runtime.getPlatformInfo() +slug: Mozilla/Add-ons/WebExtensions/API/runtime/getPlatformInfo +tags: + - API + - Add-ons + - Extensions + - Method + - Non-standard + - Reference + - WebExtensions + - getPlatformInfo + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/getPlatformInfo +--- +<div>{{AddonSidebar()}}</div> + +<p>Renvoies des informations sur la plate-forme actuelle. Ceci ne peut être appelé que dans le contexte du script d'arrière-plan.</p> + +<p>Il s'agit d'une fonction asynchrone qui renvoie une <code><a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/Promise">Promise</a></code>.</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">var getting = browser.runtime.getPlatformInfo() +</pre> + +<h3 id="Paramètres">Paramètres</h3> + +<p>None.</p> + +<h3 id="Valeur_rentournée">Valeur rentournée</h3> + +<p>Une <code><a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/Promise">Promise</a></code> qui sera remplie avec une valeur {{WebExtAPIRef('runtime.PlatformInfo')}} représentant la plate-forme actuelle.</p> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p><span class="diff_add">{{Compat("webextensions.api.runtime.getPlatformInfo")}}</span></p> + +<h2 id="Exemples">Exemples</h2> + +<p>Obtenez et consignez le système d'exploitation de la plateforme :</p> + +<pre class="brush: js">function gotPlatformInfo(info) { + console.log(info.os); +} + +var gettingInfo = browser.runtime.getPlatformInfo(); +gettingInfo.then(gotPlatformInfo);</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/geturl/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/geturl/index.html new file mode 100644 index 0000000000..83f9546f21 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/geturl/index.html @@ -0,0 +1,97 @@ +--- +title: runtime.getURL() +slug: Mozilla/Add-ons/WebExtensions/API/runtime/getURL +tags: + - API + - Add-ons + - Extensions + - Méthode + - Non-standard + - Reference + - WebExtensions + - getURL + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/getURL +--- +<div>{{AddonSidebar()}}</div> + +<div>Etant donné un chemin relatif de <a href="/fr/Add-ons/WebExtensions/manifest.json">manifest.json</a> à une ressource empaquetée avec l'extension, renvoyez une URL complète.</div> + +<div></div> + +<div>Cette fonction ne vérifie pas que la ressource existe réellement à cette URL.</div> + +<div></div> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">browser.runtime.getURL( + path // string +) +</pre> + +<h3 id="Paramètres">Paramètres</h3> + +<dl> + <dt><code>path</code></dt> + <dd><code>string</code>. Un chemin relatif de <a href="/fr/Add-ons/WebExtensions/manifest.json">manifest.json</a> à une ressource empaquetée avec l'extension.</dd> +</dl> + +<h3 id="Valeur_retournée">Valeur retournée</h3> + +<p><code>string</code>. L'URL complète de la ressource.</p> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.getURL")}}</p> + +<h2 id="Exemples">Exemples</h2> + +<p>Etant donné un fichier empaqueté avec l'extension "beasts/frog.html", obtenez l'URL complète comme ceci :</p> + +<pre class="brush: js">var fullURL = browser.runtime.getURL("beasts/frog.html"); +console.log(fullURL); +// Returns something like: +// moz-extension://2c127fa4-62c7-7e4f-90e5-472b45eecfdc/beasts/frog.html</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/id/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/id/index.html new file mode 100644 index 0000000000..8bac893224 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/id/index.html @@ -0,0 +1,70 @@ +--- +title: runtime.id +slug: Mozilla/Add-ons/WebExtensions/API/runtime/id +tags: + - API + - Add-ons + - Extensions + - Non-standard + - Property + - Reference + - WebExtensions + - runtime + - §ID +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/id +--- +<div>{{AddonSidebar()}}</div> + +<p>L'ID de l'extension</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">var myAddonId = browser.runtime.id;</pre> + +<h3 id="Value">Value</h3> + +<p>Une <code>chaîne</code> représentant l'ID du module complémentaire. Si l'extension a spécifié un ID dans la clé manifest.json de ses <a href="/fr/Add-ons/WebExtensions/manifest.json/applications">applications</a>, <code>runtime.id</code> contiendra la valeur. SInon <code>runtime.id</code> contiendra l'ID généré pour l'extension.</p> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.id")}}</p> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/index.html new file mode 100644 index 0000000000..fb23d7cc7a --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/index.html @@ -0,0 +1,171 @@ +--- +title: runtime +slug: Mozilla/Add-ons/WebExtensions/API/runtime +tags: + - API + - Add-ons + - Extensions + - Interface + - Non-standard + - Reference + - WebExtensions + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime +--- +<div>{{AddonSidebar}}</div> + +<p><span class="seoSummary">Ce module fournit des informations sur votre extension et l'environnement dans lequel elle fonctionne.</span></p> + +<p>Il fournit également des API de messagerie vous permettant de:</p> + +<ul> + <li>Communiquer entre les différentes parties de votre extension.</li> + <li>Communiquer avec d'autres extensions.</li> + <li>Communiquer avec les applications natives.</li> +</ul> + +<h2 id="Types">Types</h2> + +<dl> + <dt>{{WebExtAPIRef("runtime.Port")}}</dt> + <dd>Représente une extrémité d'une connexion entre deux contextes spécifiques, qui peut être utilisée pour échanger des messages.</dd> + <dt>{{WebExtAPIRef("runtime.MessageSender")}}</dt> + <dd> + <p>Contient des informations sur l'expéditeur d'un message ou d'une demande de connexion.</p> + </dd> + <dt>{{WebExtAPIRef("runtime.PlatformOs")}}</dt> + <dd>Identifie le système d'exploitation du navigateur.</dd> + <dt>{{WebExtAPIRef("runtime.PlatformArch")}}</dt> + <dd>Identifie l'architecture du processeur du navigateur.</dd> + <dt>{{WebExtAPIRef("runtime.PlatformInfo")}}</dt> + <dd>Contient des informations sur la plate-forme utilisée par le navigateur.</dd> + <dt>{{WebExtAPIRef("runtime.RequestUpdateCheckStatus")}}</dt> + <dd>Résultat d'un appel à {{WebExtAPIRef("runtime.requestUpdateCheck()")}}.</dd> + <dt>{{WebExtAPIRef("runtime.OnInstalledReason")}}</dt> + <dd>La raison pour laquelle l'événement {{WebExtAPIRef("runtime.onInstalled")}} est en cours d'envoi.</dd> + <dt>{{WebExtAPIRef("runtime.OnRestartRequiredReason")}}</dt> + <dd>La raison pour laquelle l'événement {{WebExtAPIRef("runtime.onRestartRequired")}} est en cours d'expédition.</dd> +</dl> + +<h2 id="Propriétés">Propriétés</h2> + +<dl> + <dt>{{WebExtAPIRef("runtime.lastError")}}</dt> + <dd>Cette valeur est définie lorsqu'une fonction asynchrone a une condition d'erreur qu'elle doit signaler à son appelant</dd> + <dt>{{WebExtAPIRef("runtime.id")}}</dt> + <dd>L'ID de l'extension</dd> +</dl> + +<h2 id="Fonctions">Fonctions</h2> + +<dl> + <dt>{{WebExtAPIRef("runtime.getBackgroundPage()")}}</dt> + <dd>Récupère l'objet <a href="/fr/docs/Web/API/Window">Window</a> pour la page d'arrière-plan qui s'exécute dans l'extension en cours.</dd> + <dt>{{WebExtAPIRef("runtime.openOptionsPage()")}}</dt> + <dd> + <p>Ouvre une <a href="/fr/Add-ons/WebExtensions/user_interface/Options_pages">page d'options</a> de votre extension.</p> + </dd> + <dt>{{WebExtAPIRef("runtime.getManifest()")}}</dt> + <dd>Obtient le fichier <a href="/fr/Add-ons/WebExtensions/manifest.json">manifest.json</a> complet, sérialisé en tant qu'objet.</dd> + <dt>{{WebExtAPIRef("runtime.getURL()")}}</dt> + <dd>Etant donné un chemin relatif de <a href="/fr/Add-ons/WebExtensions/manifest.json">manifest.json</a> à une ressource empaquetée avec l'extension, renvoie une URL entièrement qualifiée.</dd> + <dt>{{WebExtAPIRef("runtime.setUninstallURL()")}}</dt> + <dd>Définit une URL à visiter lorsque l'extension est désinstallée.</dd> + <dt>{{WebExtAPIRef("runtime.reload()")}}</dt> + <dd>Recharge l'extension.</dd> + <dt>{{WebExtAPIRef("runtime.requestUpdateCheck()")}}</dt> + <dd>Vérifie les mises à jour de cette extension.</dd> + <dt>{{WebExtAPIRef("runtime.connect()")}}</dt> + <dd>Établit une connexion d'un script de contenu au processus d'extension principal ou d'une extension à une extension différente.</dd> + <dt>{{WebExtAPIRef("runtime.connectNative()")}}</dt> + <dd> + <div>Connecte l'extension à une application native sur l'ordinateur de l'utilisateur.</div> + </dd> + <dt>{{WebExtAPIRef("runtime.sendMessage()")}}</dt> + <dd>Envoie un seul message aux écouteurs d'événement dans votre extension ou une extension différente. Similaire à {{WebExtAPIRef('runtime.connect')}} mais n'envoie qu'un seul message, avec une réponse facultative.</dd> + <dt>{{WebExtAPIRef("runtime.sendNativeMessage()")}}</dt> + <dd>Envoie un seul message d'une extension à une application native.</dd> + <dt>{{WebExtAPIRef("runtime.getPlatformInfo()")}}</dt> + <dd>Renvoie des informations sur la plate-forme actuelle.</dd> + <dt>{{WebExtAPIRef("runtime.getBrowserInfo()")}}</dt> + <dd>Renvoie des informations sur le navigateur dans lequel cette extension est installée.</dd> + <dt>{{WebExtAPIRef("runtime.getPackageDirectoryEntry()")}}</dt> + <dd>Renvoie un DirectoryEntry pour le répertoire du package.</dd> +</dl> + +<h2 id="Evénements">Evénements</h2> + +<dl> + <dt>{{WebExtAPIRef("runtime.onStartup")}}</dt> + <dd>Lancé lorsqu'un premier profil a cette extension installée. Cet événement n'est pas déclenché lorsqu'un profil de navigation privée est démarré.</dd> + <dt>{{WebExtAPIRef("runtime.onInstalled")}}</dt> + <dd>Lancé lorsque l'extension est installée pour la première fois, lorsque l'extension est mise à jour vers une nouvelle version et lorsque le navigateur est mis à jour vers une nouvelle version.</dd> + <dt>{{WebExtAPIRef("runtime.onSuspend")}}</dt> + <dd>Envoyé sur la page de l'événement juste avant le déchargement de l'extension. Cela donne à l'extension l'opportunité de faire un peu de nettoyage.</dd> + <dt>{{WebExtAPIRef("runtime.onSuspendCanceled")}}</dt> + <dd>Envoyé après {{WebExtAPIRef("runtime.onSuspend")}} pour indiquer que l'extension ne sera pas déchargée après tout.</dd> + <dt>{{WebExtAPIRef("runtime.onUpdateAvailable")}}</dt> + <dd>Lancé lorsqu'une mise à jour est disponible, mais n'est pas installé immédiatement car l'extension est en cours d'exécution.</dd> + <dt>{{WebExtAPIRef("runtime.onBrowserUpdateAvailable")}} {{deprecated_inline}}</dt> + <dd>Lancé lorsqu'une mise à jour pour le navigateur est disponible, mais n'est pas installée immédiatement car un redémarrage du navigateur est requis.</dd> + <dt>{{WebExtAPIRef("runtime.onConnect")}}</dt> + <dd>Lancé lorsqu'une connexion est établie avec un processus d'extension ou un script de contenu.</dd> + <dt>{{WebExtAPIRef("runtime.onConnectExternal")}}</dt> + <dd>Lancé lorsqu'une connexion est établie avec une autre extension.</dd> + <dt>{{WebExtAPIRef("runtime.onMessage")}}</dt> + <dd>Lancé lorsqu'un message est envoyé par un processus d'extension ou un script de contenu.</dd> + <dt>{{WebExtAPIRef("runtime.onMessageExternal")}}</dt> + <dd>Lancé lorsqu'un message est envoyé depuis un autre poste. Ne peut pas être utilisé dans un script de contenu.</dd> + <dt>{{WebExtAPIRef("runtime.onRestartRequired")}}</dt> + <dd>Lancé lorsque le périphérique doit être redémarré.</dd> +</dl> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<div> + + +<p>{{Compat("webextensions.api.runtime")}}</p> + +<div>{{WebExtExamples("h2")}}</div> + +<div></div> +</div> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/lasterror/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/lasterror/index.html new file mode 100644 index 0000000000..0fa4362444 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/lasterror/index.html @@ -0,0 +1,124 @@ +--- +title: runtime.lastError +slug: Mozilla/Add-ons/WebExtensions/API/runtime/lastError +tags: + - API + - Add-ons + - Extensions + - Non-standard + - Property + - Reference + - WebExtensions + - lastError + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/lastError +--- +<div>{{AddonSidebar()}}</div> + +<div>Cette valeur est utilisée pour signaler un message d'erreur provenant d'une API asynchrone, lorsque l'API asynchrone reçoit un rappel. Cela est utile pour les extensions qui utilisent la valeur basée sur le rappel des API WebExtension.</div> + +<div></div> + +<div>Vpous n'avez pas besoin de vérifier cette propriété si vous utilisez la version basée sur la promesse des API : à la place, passez un gestionnaire d'erreurs à la promesse :</div> + +<div></div> + +<pre class="brush: js">var gettingCookies = browser.cookies.getAll(); +gettingCookies.then(onGot, onError);</pre> + +<p>La propriété <code>runtime.lastError</code> est définie lorsqu'une fonction asynchrone a une condition d'erreur qu'elle doit signaler à son appelant.</p> + +<div>Si vous applez une fonction asynchrone qui veut définir <code>lastError</code>, vous devez vérifier l'erreur lorsque vous gérez le résultat de la fonction. Si <code>lastError</code> a été défini et que vous ne cochez pas dans la fonction de rappel, une erreur sera générée.</div> + +<div></div> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">var myError = browser.runtime.lastError; // null or Error object</pre> + +<h3 id="Valeur">Valeur</h3> + +<p>Un objet <a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/Error">Error</a> représentant une erreur. La propriété <a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/Error/message"><code>message</code></a> est un <code>string</code> avec une description lisible par l'utilisateur de l'erreur. Si <code>lastError</code> n'a pas été défini, la valeur est <code>null</code>.</p> + +<h2 id="Examples">Examples</h2> + +<p>Définir un cookie, utiliser pour enregistrer le nouveau cookie ou signaler une erreur :</p> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">logCookie</span><span class="punctuation token">(</span>c<span class="punctuation token">)</span> <span class="punctuation token">{</span> + <span class="keyword token">if</span> <span class="punctuation token">(</span>browser<span class="punctuation token">.runtime.</span>lastError<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">error</span><span class="punctuation token">(</span>browser<span class="punctuation token">.runtime.</span>lastError<span class="punctuation token">)</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span> <span class="keyword token">else</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>c<span class="punctuation token">)</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span> +<span class="punctuation token">}</span> + +browser<span class="punctuation token">.</span>cookies<span class="punctuation token">.</span><span class="keyword token">set</span><span class="punctuation token">(</span> + <span class="punctuation token">{</span>url<span class="punctuation token">:</span> <span class="string token">"https://developer.mozilla.org/"</span><span class="punctuation token">}</span><span class="punctuation token">,</span> + logCookie +<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<p>La même chose, mais en utilisant une promesse de gérer le résultat de <code>setCookie()</code>:</p> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">logCookie</span><span class="punctuation token">(</span>c<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>c<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +<span class="keyword token">function</span> <span class="function token">logError</span><span class="punctuation token">(</span>e<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">error</span><span class="punctuation token">(</span>e<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +<span class="keyword token">var</span> setCookie <span class="operator token">=</span> browser<span class="punctuation token">.</span>cookies<span class="punctuation token">.</span><span class="keyword token">set</span><span class="punctuation token">(</span> + <span class="punctuation token">{</span>url<span class="punctuation token">:</span> <span class="string token">"https://developer.mozilla.org/"</span><span class="punctuation token">}</span> +<span class="punctuation token">)</span><span class="punctuation token">; +</span> +setCookie<span class="punctuation token">.</span><span class="function token">then</span><span class="punctuation token">(</span>logCookie<span class="punctuation token">,</span> logError<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<div class="note"> +<p>Note: <code>runtime.lastError</code> est un alias pour {{WebExtAPIRef("extension.lastError")}}: Ils sont ensemble, et la vérification de l'un fonctionnera.</p> +</div> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p><span class="diff_add">{{Compat("webextensions.api.runtime.lastError")}}</span></p> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/messagesender/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/messagesender/index.html new file mode 100644 index 0000000000..d73a519c45 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/messagesender/index.html @@ -0,0 +1,86 @@ +--- +title: runtime.MessageSender +slug: Mozilla/Add-ons/WebExtensions/API/runtime/MessageSender +tags: + - API + - Add-ons + - Extensions + - MessageSender + - Non-standard + - Reference + - Type + - WebExtensions + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/MessageSender +--- +<div>{{AddonSidebar()}}</div> + +<p>Un objet contenant des informations sur l'expéditeur d'un message ou d'une demande de connexion ; ceci est passé à l'écouteur {{WebExtAPIRef("runtime.onMessage()")}}.</p> + +<p>C'est aussi une propriété de {{WebExtAPIRef("runtime.Port")}}, mais seulement dans l'instance de <code>Port</code> passée dans les écouteurs {{WebExtAPIRef("runtime.onConnect()")}} ou {{WebExtAPIRef("runtime.onConnectExternal()")}}.</p> + +<h2 id="Type">Type</h2> + +<p>Les valeurs de ce type sont des objets. Ils contiennent les propriétés suivantes :</p> + +<dl class="reference-values"> + <dt><code>tab</code>{{optional_inline}}</dt> + <dd>{{WebExtAPIRef('tabs.Tab')}}. Le {{WebExtAPIRef('tabs.Tab')}} qui a ouvert la connexion. Cette propriété ne sera présente que lorsque la connexion a été ouverte à partir d'un onglet (y compris les scripts de contenu).</dd> + <dt><code>frameId</code>{{optional_inline}}</dt> + <dd><code>integer</code>. Le cadre qui a ouvert la connexion. Zéro pour les cadres de haut niveau, positif pour les cadres enfants. Cela ne sera défini que lorsque l'<code>onglet</code> est défini.</dd> + <dt><code>id</code>{{optional_inline}}</dt> + <dd><code>string</code>. L'ID de l'extension qui a envoyé le message, si le message a été envoyé par une extension. Si l'expéditeur définit explicitement un ID à l'aide de la clé des <a href="/fr/Add-ons/WebExtensions/manifest.json/applications">applications</a> dans manifest.json, then <code>id</code> aura cette valeur. Sinon, il aura l'ID qui a été généré pour l'expéditeur.</dd> + <dd>Notez que dans Firefox, avant la version 54, cette valeur était l'ID interne de l'extension (c'est-à-dire l'<a href="https://en.wikipedia.org/wiki/Universally_unique_identifier">UUID</a> qui apparaît dans l'URL de l'extension).</dd> + <dt><code>url</code>{{optional_inline}}</dt> + <dd><code>string</code>. L'URL de la page ou du cadre hébergeant le script qui a envoyé le message.</dd> + <dd>Si l'expéditeur est un script s'exécutant dans une page d'extension (telle qu'une <a href="/fr/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Background_scripts">page d'arrière-plan</a>, une <a href="/fr/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Options_pages">page d'options</a>, ou une <a href="/fr/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Browser_actions_2">action de navigateur</a> ou une <a href="/fr/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Page_actions">action contextuelle</a>), l'URL sera au format <code>"moz-extension://<extension-internal-id>/path/to/page.html"</code>. Si l'expéditeur est un script d'arrière-plan et que vous n'avez pas inclus une page d'arrière-plan, ce sera <code>"moz-extension://<extension-internal-id>/_generated_background_page.html"</code>.</dd> + <dd>Si l'expéditeur est un script s'exécutant sur une page Web (y compris les scripts de contenu et les scripts de page normaux), alors l'<code>url</code> sera l'URL de la page web. Si le script s'exécute dans un iframe, <code>url</code> sera l'URL de l'iframe.</dd> + <dt><code>tlsChannelId</code>{{optional_inline}}</dt> + <dd><code>string</code>. L'ID de canal TLS de la page ou du cadre qui a ouvert la connexion, si demandé par l'extension, et si disponible.</dd> +</dl> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p><span class="diff_add">{{Compat("webextensions.api.runtime.MessageSender")}}</span></p> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/onbrowserupdateavailable/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/onbrowserupdateavailable/index.html new file mode 100644 index 0000000000..357b3c9dec --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/onbrowserupdateavailable/index.html @@ -0,0 +1,103 @@ +--- +title: runtime.onBrowserUpdateAvailable +slug: Mozilla/Add-ons/WebExtensions/API/runtime/onBrowserUpdateAvailable +tags: + - API + - Add-ons + - Event + - Extensions + - Non-standard + - Reference + - WebExtensions + - onBrowserUpdateAvailable + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/onBrowserUpdateAvailable +--- +<p>{{AddonSidebar}}{{Deprecated_header}}</p> + +<p>Lancé lorsqu'une mise à jour pour le navigateur est disponible, mais qu'elle n'est pas installée immédiatement car un redémarrage du navigateur est requi.</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">browser.runtime.onBrowserUpdateAvailable.addListener(listener) +browser.runtime.onBrowserUpdateAvailable.removeListener(listener) +browser.runtime.onBrowserUpdateAvailable.hasListener(listener) +</pre> + +<p>Les événements ont trois fonctions :</p> + +<dl> + <dt><code>addListener(callback)</code></dt> + <dd>Ajoute un écouteur à cet événement.</dd> + <dt><code>removeListener(listener)</code></dt> + <dd>Arrestez d'écouter un événement. L'argument <code>listener</code> est l'écouteur à supprimer.</dd> + <dt><code>hasListener(listener)</code></dt> + <dd>Vérifie si un <code>écouteur</code> est enregistré pour cet événement. Retourne <code>true</code> s'il écoute, sinon <code>false</code>.</dd> +</dl> + +<h2 id="Syntaxe_addListener">Syntaxe addListener</h2> + +<h3 id="Paramètres">Paramètres</h3> + +<dl> + <dt><code>function</code></dt> + <dd> + <p>Une fonction de rappel qui sera appelée lorsque cet événement se produira.</p> + </dd> +</dl> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.onBrowserUpdateAvailable")}}</p> + +<h2 id="Exemples">Exemples</h2> + +<p>Ecoutez cet événement :</p> + +<pre class="brush: js">function handleBrowserUpdateAvailable() { + // handle event +} + +browser.runtime.onBrowserUpdateAvailable.addListener(handleBrowserUpdateAvailable);</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/onconnect/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/onconnect/index.html new file mode 100644 index 0000000000..31463f85c7 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/onconnect/index.html @@ -0,0 +1,155 @@ +--- +title: runtime.onConnect +slug: Mozilla/Add-ons/WebExtensions/API/runtime/onConnect +tags: + - API + - Add-ons + - Event + - Extensions + - Non-standard + - Reference + - WebExtensions + - onconnect + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/onConnect +--- +<div>{{AddonSidebar()}}</div> + +<p>Lancé quand une connexion est établie avec un processus d'extension ou un script de contenu.</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">browser.runtime.onConnect.addListener(listener) +browser.runtime.onConnect.removeListener(listener) +browser.runtime.onConnect.hasListener(listener) +</pre> + +<p>Les événements ont trois fonctions :</p> + +<dl> + <dt><code>addListener(callback)</code></dt> + <dd>Ajoute un écouteur à cet événement.</dd> + <dt><code>removeListener(listener)</code></dt> + <dd>Arrêtez d'écouter cet événement. L'argument de l'<code>écouteur</code> est l'écouteur à supprimer.</dd> + <dt><code>hasListener(listener)</code></dt> + <dd>Vérifie si un <code>écouteur</code> est enregistré pour cet événement. Renvoie <code>true</code> s'il écoute, sinon <code>false</code>.</dd> +</dl> + +<h2 id="Syntaxe_addListener">Syntaxe addListener</h2> + +<h3 id="Paramètres">Paramètres</h3> + +<dl> + <dt><code>fonction</code></dt> + <dd> + <p>Une fonction de rappel qui sera appelée lorsque cet événement se produira. La fonction recevra les arguments suivants:</p> + + <dl class="reference-values"> + <dt><code>port</code></dt> + <dd>Un objet {{WebExtAPIRef('runtime.Port')}} connectant le script courant à l'autre contexte auquel il se connecte.</dd> + </dl> + </dd> +</dl> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.onConnect")}}</p> + +<h2 id="Exemples">Exemples</h2> + +<p>Ce script de contenu :</p> + +<ul> + <li>Se connecte au script d'arrière-plan et stocke le <code>Port</code> dans une variable <code>myPort</code></li> + <li>Ecoute les messages sur <code>myPort</code>, et les enregistre</li> + <li>Envoie des messages au script d'arrière-plan, en utilisant <code>myPort</code>, lorsque l'utilisateur clique sur le document</li> +</ul> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="comment token">// content-script.js</span> + +<span class="keyword token">var</span> myPort <span class="operator token">=</span> browser<span class="punctuation token">.</span>runtime<span class="punctuation token">.</span><span class="function token">connect</span><span class="punctuation token">(</span><span class="punctuation token">{</span>name<span class="punctuation token">:</span><span class="string token">"port-from-cs"</span><span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> +myPort<span class="punctuation token">.</span><span class="function token">postMessage</span><span class="punctuation token">(</span><span class="punctuation token">{</span>greeting<span class="punctuation token">:</span> <span class="string token">"hello from content script"</span><span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + +myPort<span class="punctuation token">.</span>onMessage<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span><span class="keyword token">function</span><span class="punctuation token">(</span>m<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"In content script, received message from background script: "</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>m<span class="punctuation token">.</span>greeting<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + +document<span class="punctuation token">.</span>body<span class="punctuation token">.</span><span class="function token">addEventListener</span><span class="punctuation token">(</span><span class="string token">"click"</span><span class="punctuation token">,</span> <span class="keyword token">function</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> + myPort<span class="punctuation token">.</span><span class="function token">postMessage</span><span class="punctuation token">(</span><span class="punctuation token">{</span>greeting<span class="punctuation token">:</span> <span class="string token">"they clicked the page!"</span><span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<p>Le script d'arrière-plan correspondant :</p> + +<ul> + <li>Ecoute les tentatives de connexion de script de contenu</li> + <li>Quand il reçoit une tentative de connexion : + <ul> + <li>Stocke le port dans une variable nommée <code>portFromCS</code></li> + <li>Envoie un message au script de contenu en utilisant le port</li> + <li>Commence à écouter les messages reçus sur le port et les enregistre</li> + </ul> + </li> + <li>Envoie des messages au script de contenu, en utilisant <code>portFromCS</code>, quand l'utilisateur clique sur l'action du navigateur de l'extension</li> +</ul> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="comment token">// background-script.js</span> + +<span class="keyword token">var</span> portFromCS<span class="punctuation token">;</span> + +<span class="keyword token">function</span> <span class="function token">connected</span><span class="punctuation token">(</span>p<span class="punctuation token">)</span> <span class="punctuation token">{</span> + portFromCS <span class="operator token">=</span> p<span class="punctuation token">;</span> + portFromCS<span class="punctuation token">.</span><span class="function token">postMessage</span><span class="punctuation token">(</span><span class="punctuation token">{</span>greeting<span class="punctuation token">:</span> <span class="string token">"hi there content script!"</span><span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + portFromCS<span class="punctuation token">.</span>onMessage<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span><span class="keyword token">function</span><span class="punctuation token">(</span>m<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"In background script, received message from content script"</span><span class="punctuation token">)</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>m<span class="punctuation token">.</span>greeting<span class="punctuation token">)</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +browser<span class="punctuation token">.</span>runtime<span class="punctuation token">.</span>onConnect<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>connected<span class="punctuation token">)</span><span class="punctuation token">;</span> + +browser<span class="punctuation token">.</span>browserAction<span class="punctuation token">.</span>onClicked<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span><span class="keyword token">function</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> + portFromCS<span class="punctuation token">.</span><span class="function token">postMessage</span><span class="punctuation token">(</span><span class="punctuation token">{</span>greeting<span class="punctuation token">:</span> <span class="string token">"they clicked the button!"</span><span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/onconnectexternal/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/onconnectexternal/index.html new file mode 100644 index 0000000000..fe6cee3398 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/onconnectexternal/index.html @@ -0,0 +1,140 @@ +--- +title: runtime.onConnectExternal +slug: Mozilla/Add-ons/WebExtensions/API/runtime/onConnectExternal +tags: + - API + - Add-ons + - Evènement + - Extensions + - Non-standard + - Reference + - WebExtensions + - onConnectExternal + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/onConnectExternal +--- +<div>{{AddonSidebar()}}</div> + +<p>Lancé lorsqu'une extension reçoit une demande de connexion d'une extension différente.</p> + +<p>Pour envoyer un message qui sera reçu par le programme d'écoute <code>onConnectExternal</code>, utilisez {{WebExtAPIRef("runtime.connect()")}}, en transmettant l'ID du destinataire dans le paramètre <code>extensionId</code>.</p> + +<p>L'écouteur reçoit un objet {{WebExtAPIRef('runtime.Port')}} qu'il peut ensuite utiliser pour envoyer et recevoir des messages. L'objet <code>Port</code> contient également une propriété<code>sender</code>, qui est un objet {{WebExtAPIRef("runtime.MessageSender")}}, et que le destinataire peut utiliser pour vérifier l'ID de l'expéditeur.</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">browser.runtime.onConnectExternal.addListener(listener) +browser.runtime.onConnectExternal.removeListener(listener) +browser.runtime.onConnectExternal.hasListener(listener) +</pre> + +<p>Les événements ont trois fonctions :</p> + +<dl> + <dt><code>addListener(callback)</code></dt> + <dd>Ajoute un écouteur à cet événement.</dd> + <dt><code>removeListener(listener)</code></dt> + <dd>Arrêtez d'écouter cet événement. L'argument <code>listener</code> est l'écouteur à supprimer.</dd> + <dt><code>hasListener(listener)</code></dt> + <dd>Vérifie si un <code>listener</code> est enregistré pour cet événement. Retourne <code>true</code> s'il écoute, <code>false</code> sinon.</dd> +</dl> + +<h2 id="Syntaxe_addListener">Syntaxe addListener</h2> + +<h3 id="Paramètres">Paramètres</h3> + +<dl> + <dt><code>fonction</code></dt> + <dd> + <p>Une fonction de rappel qui sera appelée lorsque cet événement se produira. La fonction recevra les arguments suivants :</p> + + <dl class="reference-values"> + <dt><code>port</code></dt> + <dd>Un objet {{WebExtAPIRef('runtime.Port')}} connectant le script en cours à l'autre extension à laquelle il se connecte.</dd> + </dl> + </dd> +</dl> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.onConnectExternal")}}</p> + +<h2 id="Exemples">Exemples</h2> + +<p>Dans cet exemple, l'extension Hansel se connecte à l'extension Gretel :</p> + +<pre class="brush: js">console.log("connecting to Gretel"); +var myPort = browser.runtime.connect( + "gretel@mozilla.org" +); + +myPort.onMessage.addListener((message) => { + console.log(`From Gretel: ${message.content}`); +}); + +browser.browserAction.onClicked.addListener(() => { + myPort.postMessage({content: "Hello from Hansel"}); +});</pre> + +<p>Gretel écoute la connexion et vérifie que l'expéditeur est vraiment Hansel:</p> + +<pre class="brush: js">var portFromHansel; + +browser.runtime.onConnectExternal.addListener((port) => { + console.log(port); + if (port.sender.id === "hansel@mozilla.org") { + console.log("connection attempt from Hansel"); + portFromHansel = port; + portFromHansel.onMessage.addListener((message) => { + console.log(`From Hansel: ${message.content}`); + }); + } +}); + +browser.browserAction.onClicked.addListener(() => { + portFromHansel.postMessage({content: "Message from Gretel"}); +}); + +</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/oninstalled/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/oninstalled/index.html new file mode 100644 index 0000000000..d1ef171ab7 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/oninstalled/index.html @@ -0,0 +1,125 @@ +--- +title: runtime.onInstalled +slug: Mozilla/Add-ons/WebExtensions/API/runtime/onInstalled +tags: + - API + - Add-ons + - Event + - Extensions + - Non-standard + - Reference + - WebExtensions + - onInstalled + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/onInstalled +--- +<div>{{AddonSidebar()}}</div> + +<p>Lancé lorsque l'extension est installée pour la première fois, lorsque l'extension est mise à jour vers une nouvelle version et lorsque le navigateur est mis à jour vers une nouvelle version.</p> + +<p>Notez que <code>runtime.onInstalled</code> n'est pas la même chose {{WebExtAPIRef("management.onInstalled")}}. L'événement <code>runtime.onInstalled</code> est déclenché uniquement pour votre extension. L'événement <code>browser.management.onInstalled</code> est déclenché pour toutes les extensions.</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">browser.runtime.onInstalled.addListener(listener) +browser.runtime.onInstalled.removeListener(listener) +browser.runtime.onInstalled.hasListener(listener) +</pre> + +<p>Les événements ont trois fonctions :</p> + +<dl> + <dt><code>addListener(callback)</code></dt> + <dd>Ajouterun écouteur à cet événement.</dd> + <dt><code>removeListener(listener)</code></dt> + <dd>Arrêtez d'écoutercet événement. L'argument <code>listener</code> est l'écouteur à supprimer.</dd> + <dt><code>hasListener(listener)</code></dt> + <dd>Vérifie si un <code>écouteur</code> est enregistré pour cet événement. Renvoie <code>true</code> s'il écoute, <code>false</code> sinon.</dd> +</dl> + +<h2 id="Syntaxe_addListener">Syntaxe addListener</h2> + +<h3 id="Paramètres">Paramètres</h3> + +<dl> + <dt><code>function</code></dt> + <dd> + <p>La fonction de rappel appelée lorsque cet événement se produit. La fonction recevra les arguments suivants :</p> + + <dl class="reference-values"> + <dt><code>details</code></dt> + <dd>Un objet avec les propriétés suivantes :</dd> + <dd> + <dl class="reference-values"> + <dt><code>id</code>{{optional_inline}}</dt> + <dd><code>string</code>. L'ID de l'extension de module partagé importé mise à jour. Ceci n'est présent que si la valeur de <code>raison</code> est <code>shared_module_update</code>.</dd> + <dt><code>previousVersion</code>{{optional_inline}}</dt> + <dd><code>string</code>. La version précédente de l'extension vient d'être mise à jour. Ceci n'est pas présent si la valeur de <code>raison</code> est <code>mise à jour</code>.</dd> + <dt><code>reason</code></dt> + <dd>Une valeur {{WebExtAPIRef('runtime.OnInstalledReason')}}, indiquant la raison pour laquelle cet événement est distribué.</dd> + <dt><code>temporary</code></dt> + <dd><code>boolean</code>. Vrai si le module complémentaire a été installé temporairement. Par exemple, en utilisant la page "about:debugging" dans Firefox ou en utilisant <a href="/fr/Add-ons/WebExtensions/Getting_started_with_web-ext">web-ext run</a>. Sinon faux.</dd> + </dl> + </dd> + </dl> + </dd> +</dl> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.onInstalled", 10)}}</p> + +<h2 id="Exemples">Exemples</h2> + +<p>Lorsque l'extensin est installé, connectez-vous à la raison de l'installon et ouvrez <a class="external external-icon" href="https://www.reddit.com/r/CatGifs/">https://www.reddit.com/r/CatGifs/</a>:</p> + +<pre class="brush: js">function handleInstalled(details) { + console.log(details.reason); + browser.tabs.create({ + url: "http://chilloutandwatchsomecatgifs.com/" + }); +} + +browser.runtime.onInstalled.addListener(handleInstalled);</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/oninstalledreason/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/oninstalledreason/index.html new file mode 100644 index 0000000000..433f9e8292 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/oninstalledreason/index.html @@ -0,0 +1,79 @@ +--- +title: runtime.OnInstalledReason +slug: Mozilla/Add-ons/WebExtensions/API/runtime/OnInstalledReason +tags: + - API + - Add-ons + - Extensions + - Non-standard + - OnInstalledReason + - Reference + - Type + - WebExtensions + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/OnInstalledReason +--- +<div>{{AddonSidebar()}}</div> + +<p>Les valeurs pour laquelle l'événement {{WebExtAPIRef("runtime.onInstalled")}} est en cours d'envoi.</p> + +<h2 id="Type">Type</h2> + +<p>Les valeurs de ce type sont des chaînes. Les valeurs possibles sont :</p> + +<dl> + <dt><code>"install"</code></dt> + <dd>L'extension a été installée.</dd> + <dt><code>"update"</code></dt> + <dd>L'extension a été mise à jour vers une nouvelle version.</dd> + <dt><code>"browser_update"</code></dt> + <dd>Le navigateur a été mise à jour vers une nouvelle version.</dd> + <dt><code>"shared_module_update"</code></dt> + <dd>Une autre extension, qui contient un module utilisé par cette extension, a été mise à jour.</dd> +</dl> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.OnInstalledReason")}}</p> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/onmessage/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/onmessage/index.html new file mode 100644 index 0000000000..c1267fff27 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/onmessage/index.html @@ -0,0 +1,327 @@ +--- +title: runtime.onMessage +slug: Mozilla/Add-ons/WebExtensions/API/runtime/onMessage +tags: + - API + - Add-ons + - Event + - Extensions + - Non-standard + - Reference + - WebExtensions + - onmessage + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/onMessage +--- +<nav>{{AddonSidebar()}}</nav> + +<p>Utilisez cet événement pour écouter les messages d’une autre partie de votre extension. Par exemple, utilisez-le :</p> + +<p>Voici quelques exemples de cas d'utilisation :</p> + +<ul> + <li><strong>dans un <a href="/fr/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Content_scripts">script de contenu</a></strong>, pour écouter les messages d’un <a href="/fr/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Background_scripts">script d’arrière-plan</a> ;</li> + <li><strong>dans un script d’arrière-plan</strong>, pour écouter les messages d’un script de contenu ;</li> + <li><strong>dans une <a href="/fr/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Options_pages">page d’options</a> ou un script de <a href="/fr/Add-ons/WebExtensions/User_interface_components#Popups">popup</a></strong>, pour écouter les messages d’un script d’arrière-plan ;</li> + <li><strong>dans un script d’arrière plan</strong>, pour écouter les messages d’une page d’options ou d’un script de popup.</li> +</ul> + +<p>Pour envoyer un message reçu par l'écouteur <code>onMessage</code>, utilisez {{WebExtAPIRef("runtime.sendMessage()")}} ou (pour envoyer un message à un script de contenu) {{WebExtAPIRef("tabs.sendMessage()")}}.</p> + +<div class="blockIndicator note"> +<p>Évitez de créer plusieurs écouteurs <code>onMessage</code> pour le même type de message, car l'ordre dans lequel plusieurs auditeurs vont tirer n'est pas garanti.</p> + +<p>Lorsque vous voulez garantir la livraison d'un message à un point final spécifique, utilisez l'<a href="fr/docs/Mozilla/Add-ons/WebExtensions/Content_scripts##Les_messages_en_flux_continu">approche basée sur la connexion pour échanger des messages</a>.</p> +</div> + +<p>Avec le message lui-même, l’écouteur reçoit en paramètres :</p> + +<ul> + <li>Un objet <code>sender</code> donnant les détails sur l’expéditeur du message ;</li> + <li>Une fonction <code>sendResponse</code> qui peut être utilisé pour renvoyer une réponse à l'expéditeur.</li> +</ul> + +<p>Vous pouvez envoyer une réponse synchrone au message en appelant la fonction <code>sendResponse</code> dans votre écouteur. <a href="/fr/Add-ons/WebExtensions/API/runtime/onMessage#Sending_a_synchronous_response">Voir un exemple</a>.</p> + +<p>Pour envoyer un réponse asynchrone, il existe deux options :</p> + +<ul> + <li>Renvoyer <code>true</code> à partir de l’écouteur d’événement. Cela permet de conserver la fonction <code>sendResponse</code> après le retour de l’écouteur, ce qui vous permet de l’appeler plus tard. <a href="/fr/Add-ons/WebExtensions/API/runtime/onMessage#Sending_an_asynchronous_response_using_sendResponse">Voir un exemple</a>.</li> + <li>Renvoyer une <code>Promise</code> depuis l’écouteur d’événement, et la résoudre lorsque vous avez la réponse (ou la rejeter en cas d’erreur). <a href="/fr/Add-ons/WebExtensions/API/runtime/onMessage#Sending_an_asynchronous_response_using_a_Promise">Voir un exemple</a>.</li> +</ul> + +<div class="warning"> +<p>Retourner une <code>Promise</code> est maintenant le moyen préféré car <code>sendResponse</code> <a class="external" href="https://github.com/mozilla/webextension-polyfill/issues/16#issuecomment-296693219">sera retirée de la spécification W3C</a>.</p> + +<p>La bibliothèque populaire <a class="external" href="https://github.com/mozilla/webextension-polyfill">webextension-polyfill</a> a déjà supprimé cette fonction de son implémentation.</p> +</div> + +<div class="blockIndicator note"> +<p>Vous pouvez également utiliser une <a href="/fr/docs/Mozilla/Add-ons/WebExtensions/Content_scripts">approche basée sur la connexion pour échanger des messages</a>.</p> +</div> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox">browser.runtime.onMessage.addListener(listener) +browser.runtime.onMessage.removeListener(listener) +browser.runtime.onMessage.hasListener(listener)</pre> + +<p>Les événements ont trois fonctions :</p> + +<dl> + <dt><code>addListener(listener)</code></dt> + <dd>Ajoute un écouteur à cet événement.</dd> + <dt><code>removeListener(listener)</code></dt> + <dd>Cesse d’écouter cet événement. L’argument <code>listener</code> est l’écouteur à supprimer.</dd> + <dt><code>hasListener(listener)</code></dt> + <dd>Vérifie si un <code>listener</code> est enregistré pour cet événement. Retourne <code>true</code> s’il écoute, <code>false</code> sinon.</dd> +</dl> + +<h2 id="Syntaxe_de_addListener">Syntaxe de addListener</h2> + +<h3 id="Paramètres">Paramètres</h3> + +<dl> + <dt><em><code>listener</code></em></dt> + <dd> + <p>Une fonction d’écoute qui sera appelée lorsque cet événement se produira. La fonction recevra les arguments suivants :</p> + + <dl class="reference-values"> + <dt><em><code>message</code></em></dt> + <dd><code>object</code>. Le message lui-même. C’est un objet JSON-ifiable.</dd> + </dl> + + <dl class="reference-values"> + <dt><em><code>sender</code></em></dt> + <dd>Un objet {{WebExtAPIRef("runtime.MessageSender")}} représentant l’expéditeur du message.</dd> + </dl> + + <dl class="reference-values"> + <dt><code>s<em>endResponse</em></code></dt> + <dd> + <p>Une fonction à appeler, au plus une fois, pour envoyer une réponse au <code><var>message</var></code>. La fonction prend un seul argument, qui peut être n'importe quel objet JSON-ifiable. Cet argument est renvoyé à l'expéditeur du message.</p> + + <p>Si vous avez plus d'un écouteur <code>onMessage()</code> dans le même document, alors un seul peut envoyer une réponse.</p> + + <p>Pour envoyer une réponse de manière synchrone, appelez <code>sendResponse()</code> avant le retour de la fonction d'écoute.</p> + + <p>Pour envoyer une réponse de manière asynchrone</p> + + <ul> + <li>soit garder une référence à l'argument <code>sendResponse()</code> et retourner <code>true</code> depuis la fonction listenener. Vous pourrez alors appeler <code>sendResponse()</code> après le retour de la fonction d'écoute.</li> + <li>ou retournez une {{jsxref("Promise")}} à partir de la fonction d'écoute et résolvez la promise lorsque la réponse est prête. C'est un moyen privilégié</li> + </ul> + </dd> + </dl> + + <p>La fonction <code><var>listener</var></code> peut renvoyer un booléen ou une {{jsxref("Promise")}}.</p> + + <div class="blockIndicator note"> + <p><strong>Important:</strong> N'appelez pas <code>addListener()</code> en utilisant une fonction <code>async</code> :</p> + + <pre class="brush: js example-bad">// don't do this +browser.runtime.onMessage.addListener( + async (data, sender) => { + if (data.type === 'handle_me') { return 'done'; } + } +); +</pre> + + <p>L'auditeur consommera ainsi chaque message qu'il reçoit, ce qui empêchera effectivement tous les autres auditeurs de recevoir et de traiter des messages.</p> + + <p>Si vous souhaitez adopter une approche asynchrone, utilisez plutôt une Promise, comme ceci :</p> + + <pre class="brush: js example-good">browser.runtime.onMessage.addListener( + (data, sender) => { + if (data.type === 'handle_me') { + return Promise.resolve('done'); + } + } +); +</pre> + </div> + </dd> +</dl> + +<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2> + +<p class="hidden">La table de compatibilité sur cette page est générée à partir de données structurées. Si vous souhaitez contribuer aux données, veuillez consulter <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> et nous envoyer une <em>pull request.</em></p> + +<p>{{Compat("webextensions.api.runtime.onMessage()")}}</p> + +<h2 id="Exemples">Exemples</h2> + +<h3 id="Exemple_simple">Exemple simple</h3> + +<p>Ce script de contenu écoute les événements clic dans la page web. Si le clic a eu lieu sur un lien, il envoie un message à la page d’arrière-plan avec l’URL cible :</p> + +<pre class="brush: js">// content-script.js + +window.addEventListener("click", notifyExtension); + +function notifyExtension(e) { + if (e.target.tagName != "A") { + return; + } + browser.runtime.sendMessage({"url": e.target.href}); +}</pre> + +<p>Le script d’arrière-plan écoute ces messages et affiche une notification à l’aide de l’API <code><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/notifications">notifications</a></code>.</p> + +<pre class="brush: js">// background-script.js + +browser.runtime.onMessage.addListener(notify); + +function notify(message) { + browser.notifications.create({ + "type": "basic", + "iconUrl": browser.extension.getURL("link.png"), + "title": "Vous avez cliqué sur un lien !", + "message": message.url + }); +}</pre> + +<h3 id="Envoyer_une_réponse_synchrone">Envoyer une réponse synchrone</h3> + +<p>Le script de contenu suivant envoie un message au script d’arrière plan lorsque l’utilisateur ou l’utilisatrice clique sur la page. Il enregistre également toute réponse envoyé par le script d’arrière-plan :</p> + +<pre class="brush: js">// content-script.js + +function handleResponse(message) { + console.log(`le script d’arrière-plan a répondu : ${message.response}`); +} + +function handleError(error) { + console.log(`Erreur : ${error}`); +} + +function sendMessage(e) { + var sending = browser.runtime.sendMessage({content: "message du script de contenu"}); + sending.then(handleResponse, handleError); +} + +window.addEventListener("click", sendMessage);</pre> + +<p>Voici une version du script d’arrière-plan correspondant, qui envoie une réponse de manière synchrone depuis l’intérieur de l’écouteur :</p> + +<pre class="brush: js">// background-script.js + +function handleMessage(request, sender, sendResponse) { + console.log(`le script de contenu a envoyé un message : ${request.content}`); + sendResponse({response: "réponse du script d’arrière-plan"}); +} + +browser.runtime.onMessage.addListener(handleMessage);</pre> + +<p>Et voici une autre version, qui utilise {{jsxref("Promise.resolve()")}} :</p> + +<pre class="brush: js">// background-script.js + +function handleMessage(request, sender, sendResponse) { + console.log(`le script de contenu a envoyé un message : ${request.content}`); + return Promise.resolve({response: "réponse du script d’arrière-plan"}); +} + +browser.runtime.onMessage.addListener(handleMessage);</pre> + +<h3 id="Envoi_d’une_réponse_asynchrone_à_l’aide_de_sendResponse">Envoi d’une réponse asynchrone à l’aide de sendResponse</h3> + +<p>Voici un autre version du script d’arrière-plan de l’exemple précédent. Il envoie une réponse de manière asynchrone, après le retour de l’écouteur. Remarquez le <code>return true;</code> dans l’écouteur : cela indique au navigateur que vous avez l’intention d’utiliser l’argument <code>sendResponse</code> après le retour de l’écouteur.</p> + +<pre class="brush: js">// background-script.js + +function handleMessage(request, sender, sendResponse) { + console.log(`le script de contenu a envoyé un message : ${request.content}`); + setTimeout(() => { + sendResponse({response: "réponse asynchrone du script d’arrière-plan"}); + }, 1000); + return true; +} + +browser.runtime.onMessage.addListener(handleMessage);</pre> + +<h3 id="Envoi_d’une_réponse_asynchrone_à_l’aide_d’une_promesse">Envoi d’une réponse asynchrone à l’aide d’une promesse</h3> + +<p>Ce script de contenu reçoit le premier lien <code><a></code> dans la page, et envoie un message demandant si l’emplacement du lien fait partie des marque-pages. Il attend comme réponse un {{jsxref("Boolean", "booléen")}} : <code>true</code> si l’emplacement est dans les marque-pages, <code>false</code> sinon.</p> + +<pre class="brush: js">// content-script.js + +const firstLink = document.querySelector("a"); + +function handleResponse(isBookmarked) { + if (isBookmarked) { + firstLink.classList.add("bookmarked"); + } +} + +browser.runtime.sendMessage({ + url: firstLink.href +}).then(handleResponse);</pre> + +<p>Voici le script d’arrière plan. Il utilise <code>{{WebExtAPIRef("bookmarks.search()")}}</code> pour voir si le lien est dans les marque-pages, ce qui renvoie une {{jsxref("Promise", "promesse")}} :</p> + +<pre class="brush: js">// background-script.js + +function isBookmarked(message, sender, response) { + return browser.bookmarks.search({ + url: message.url + }).then(function(results) { + return results.length > 0; + }); +} + +browser.runtime.onMessage.addListener(isBookmarked);</pre> + +<p>Si le gestionnaire asynchrone ne renvoie pas de promise, vous pouvez explicitement construire une promise. Cet exemple plutôt artificiel envoie une réponse après un délai d’une seconde, en utilisant <code><a href="/fr/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout">Window.setTimeout()</a></code> :</p> + +<pre class="brush: js">// background-script.js + +function handleMessage(request, sender, sendResponse) { + return new Promise(resolve => { + setTimeout(() => { + resolve({response: "réponse asynchrone du script d’arrière-plan"}); + }, 1000); + }); +} + +browser.runtime.onMessage.addListener(handleMessage);</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements </strong> + +<p>Cette API est basée sur l’API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/onmessageexternal/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/onmessageexternal/index.html new file mode 100644 index 0000000000..f9f67a0264 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/onmessageexternal/index.html @@ -0,0 +1,157 @@ +--- +title: runtime.onMessageExternal +slug: Mozilla/Add-ons/WebExtensions/API/runtime/onMessageExternal +tags: + - API + - Add-ons + - Event + - Extensions + - Non-standard + - Reference + - WebExtensions + - onMessageExternal + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/onMessageExternal +--- +<div>{{AddonSidebar()}}</div> + +<div> +<div>Utilisez cet événement pour écouter les messages d'une autre extension.</div> + +<div></div> + +<p>Pour envoyer un message qui sera reçu par le module d'écoute <code>onMessageExternal</code>, utilisez {{WebExtAPIRef("runtime.sendMessage()")}}, en transmettant l'ID du destinataire dans le paramètre <code>extensionId</code>.</p> + +<p>Avec le message lui-même, l'écouteur est transmis :</p> + +<ul> + <li>un objet <code>sender</code> donnant des détails sur l'expéditeur du message</li> + <li>une fonction <code>sendResponse</code> qu'elle peut utiliser pour renvoyer une réponse à l'expéditeur.</li> +</ul> +</div> + +<p>Cette API ne peut pas être utilisée dans un script de contenu.</p> + +<h2 id="Syntax">Syntax</h2> + +<pre class="syntaxbox brush:js">browser.runtime.onMessageExternal.addListener() +browser.runtime.onMessageExternal.removeListener(listener) +browser.runtime.onMessageExternal.hasListener(listener) +</pre> + +<p>Les événements ont trois fonctions:</p> + +<dl> + <dt><code>addListener(callback)</code></dt> + <dd>Ajoute un écouteur à cet événement.</dd> + <dt><code>removeListener(listener)</code></dt> + <dd>Arrêtez d'écouter cet événement. L'argument <code>listener</code> est l'écouteur à supprimer.</dd> + <dt><code>hasListener(listener)</code></dt> + <dd>Vérifie si un <code>listener</code> est enregistré pour cet événement. Renvoie <code>true</code> s'il écoute, <code>false</code> sinon.</dd> +</dl> + +<h2 id="Syntaxe_addListener">Syntaxe addListener</h2> + +<h3 id="Paramètres">Paramètres</h3> + +<dl> + <dt><code>function</code></dt> + <dd> + <p>Une fonction de rappel qui sera appelée lorsque cet événement se produira. La fonction recevra les arguments suivants :</p> + + <dl class="reference-values"> + <dt><code>message</code></dt> + <dd><code>object</code>. Le message lui-même. C'est un objet JSON-ifiable.</dd> + </dl> + + <dl class="reference-values"> + <dt><code>sender</code></dt> + <dd>Un objet {{WebExtAPIRef('runtime.MessageSender')}} représentant l'expéditeur du message.</dd> + </dl> + + <dl class="reference-values"> + <dt><code>sendResponse</code></dt> + <dd> + <p>Une fonction à appeler, au plus une fois, pour envoyer une réponse au message. La fonction prend un seul argument, qui peut être n'importe quel objet JSON-ifiable. Cet argument est renvoyé à l'expéditeur du message.</p> + + <p>Si vous avez plus d'un écouteur <code>onMessageExternal</code> dans le même document, un seul peut envoyer une réponse.</p> + + <p>To send a response synchronously, call <code>sendResponse</code> before the listener function returns. To send a response asynchronously:</p> + + <ul> + <li>Soit garder une référence à l'argumen <code>sendResponse</code> et retourne <code>true</code> à partir de la fonction d'écouteur. Vous pourrez ensuite appeler <code>sendResponse</code> après le retour de la fonction d'écouteur..</li> + <li>ou retourne une <code><a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/Promise">Promise</a></code> de la fonction d'écouteur et résoudre la promesse lorsque la réponse est prête.</li> + </ul> + </dd> + </dl> + </dd> +</dl> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.onMessageExternal")}}</p> + +<h2 id="Exemples">Exemples</h2> + +<p>Dans cet exemple, l'extension "blue@mozilla.org" envoie un message à l'extension "red@mozilla.org":</p> + +<pre class="brush: js">// sender: browser.runtime.id == "blue@mozilla.org" + +// Send a message to the extension whose ID is "red@mozilla.org" +browser.runtime.sendMessage( + "red@mozilla.org", + "my message" + );</pre> + +<pre class="brush: js">// recipient: browser.runtime.id == "red@mozilla.org" + +function handleMessage(message, sender) { + // check that the message is from "blue@mozilla.org" + if (sender.id === "blue@mozilla.org") { + // process message + } +} + +browser.runtime.onMessageExternal.addListener(handleMessage);</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/onrestartrequired/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/onrestartrequired/index.html new file mode 100644 index 0000000000..0183947b85 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/onrestartrequired/index.html @@ -0,0 +1,100 @@ +--- +title: runtime.onRestartRequired +slug: Mozilla/Add-ons/WebExtensions/API/runtime/onRestartRequired +tags: + - API + - Add-ons + - Event + - Extensions + - Non-standard + - Reference + - WebExtensions + - onRestartRequired + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/onRestartRequired +--- +<div>{{AddonSidebar()}}</div> + +<p>Lancé lorsqu'une application ou le périphérique sur lequel elle s'exécute doit être redémarré. L'application devrait fermer toutes ses fenêtres dans les meilleurs délais pour permettre le redémarrage. Si l'application ne fait rien, un redémarrage sera appliqué après une période de grâce de 24 heures. Actuellement, cet événement est uniquement déclenché pour les applications de kiosque Chrome OS.</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">browser.runtime.onRestartRequired.addListener(listener) +browser.runtime.onRestartRequired.removeListener(listener) +browser.runtime.onRestartRequired.hasListener(listener) +</pre> + +<p>Les événements ont trois fonctions :</p> + +<dl> + <dt><code>addListener(callback)</code></dt> + <dd>Ajouter un écouteur à cet événement.</dd> + <dt><code>removeListener(listener)</code></dt> + <dd>Arrêtez d'écouter cet événement. L'argument <code>listener</code> est l'écouteur à supprimer.</dd> + <dt><code>hasListener(listener)</code></dt> + <dd>Vérifie si un <code>listener</code> est enregistré pour cet événement. Renvoie <code>true</code> s'il écoute, <code>false</code> sinon.</dd> +</dl> + +<h2 id="Syntaxe_addListener">Syntaxe addListener</h2> + +<h3 id="Paramètres">Paramètres</h3> + +<dl> + <dt><code>fonction </code></dt> + <dd> + <p>Une fonction de rappel qui sera appelée lorsque cet événement se produira. La fonction recevra les arguments suivants :</p> + + <dl class="reference-values"> + <dt><code>raison</code></dt> + <dd>Une valeur {{WebExtAPIRef('runtime.OnRestartRequiredReason')}} — La raison pour laquelle l'événemtn est envoyé.</dd> + </dl> + </dd> +</dl> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.onRestartRequired")}}</p> + +<h2 id="Exemples">Exemples</h2> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/onrestartrequiredreason/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/onrestartrequiredreason/index.html new file mode 100644 index 0000000000..4ab9253023 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/onrestartrequiredreason/index.html @@ -0,0 +1,74 @@ +--- +title: runtime.OnRestartRequiredReason +slug: Mozilla/Add-ons/WebExtensions/API/runtime/OnRestartRequiredReason +tags: + - API + - Add-ons + - Extensions + - Non-standard + - OnRestartsRequiredReason + - Reference + - Type + - WebExtensions + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/OnRestartRequiredReason +--- +<div>{{AddonSidebar()}}</div> + +<p>La raison pour laquelle l'événement {{WebExtAPIRef("runtime.onRestartRequired", "onRestartRequired")}} est en cours d'exécution.</p> + +<h2 id="Type">Type</h2> + +<p>Les valeurs de ce type sont des chaînes. Les valeurs possibles sont :</p> + +<ul> + <li><code>"app_update"</code>: L'application en cours de mise à jour vers une version plus récente.</li> + <li><code>"os_update"</code>: Le navigateur / Système d'exploitation est mise à jour vers une nouvelle verion plus récente.</li> + <li><code>"periodic"</code>: Le système a fonctionné pendant plus logntemps que la durée de disponibilité autorisée dans la stratégie d'entreprise.</li> +</ul> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.OnRestartRequiredReason")}}</p> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/onstartup/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/onstartup/index.html new file mode 100644 index 0000000000..49d50da632 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/onstartup/index.html @@ -0,0 +1,105 @@ +--- +title: runtime.onStartup +slug: Mozilla/Add-ons/WebExtensions/API/runtime/onStartup +tags: + - API + - Add-ons + - Event + - Extensions + - Non-standard + - Reference + - WebExtensions + - onStartup + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/onStartup +--- +<div>{{AddonSidebar()}}</div> + +<p>Lancé lorsqu'un premier profil a cette extension installée. Cet événement n'est pas déclenché lorsqu'une navigation privée / profil privé est démarré, même si cette extension fonctionne en mode de navigation privée 'split'.</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">browser.runtime.onStartup.addListener(listener) +browser.runtime.onStartup.removeListener(listener) +browser.runtime.onStartup.hasListener(listener) +</pre> + +<p>Les événements ont trois fonctions :</p> + +<dl> + <dt><code>addListener(callback)</code></dt> + <dd>Ajoute un écouteur à écouteur.</dd> + <dt><code>removeListener(listener)</code></dt> + <dd>Arrêtez d'écouter cet événement. L'argument <code>listener</code> est l'écouteur à supprimer.</dd> + <dt><code>hasListener(listener)</code></dt> + <dd>Vérifie si un <code>écouteur</code> est enregistré pour cet événement. Renvoie <code>true</code> s'il écoute, sinon <code>false</code>.</dd> +</dl> + +<h2 id="Syntaxe_addListener">Syntaxe addListener</h2> + +<h3 id="Parameters">Parameters</h3> + +<dl> + <dt><code>callback</code></dt> + <dd> + <p>Une fonction qui sera appelée lorsque cet événemetn se produit.</p> + </dd> +</dl> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.onStartup")}}</p> + +<h2 id="Exemples">Exemples</h2> + +<p>Ouvre <a href="http://chilloutandwatchsomecatgifs.com/">http://chilloutandwatchsomecatgifs.com/</a> quand le navigateur démarre :</p> + +<pre class="brush: js">function handleStartup() { + browser.tabs.create({ + url: "http://chilloutandwatchsomecatgifs.com/" + }); +} + +browser.runtime.onStartup.addListener(handleStartup);</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/onsuspend/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/onsuspend/index.html new file mode 100644 index 0000000000..ef4f5a5353 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/onsuspend/index.html @@ -0,0 +1,108 @@ +--- +title: runtime.onSuspend +slug: Mozilla/Add-ons/WebExtensions/API/runtime/onSuspend +tags: + - API + - Add-ons + - Event + - Extensions + - Non-standard + - Reference + - WebExtensions + - onSuspend + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/onSuspend +--- +<div>{{AddonSidebar()}}</div> + +<p>Envoyé sur la page de l'événement juste avant son déchargement. Cela donne à l'extension l'opportunité de faire un peu de nettoyage. Notez que, comme la page est en cours de déchargement, les opérations asynchrones démarrées lors de la gestion de cet événement ne sont pas garanties.</p> + +<div class="note"> +<p><strong>Note</strong>: Si quelque chose empêche le déchargement de la page d'événement, l'événement {{WebExtAPIRef("runtime.onSuspendCanceled")}} sera envoyé et la page ne sera pas déchargée.</p> +</div> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">browser.runtime.onSuspend.addListener(listener) +browser.runtime.onSuspend.removeListener(listener) +browser.runtime.onSuspend.hasListener(listener) +</pre> + +<p>Les événements ont trois fonctions :</p> + +<dl> + <dt><code>addListener(callback)</code></dt> + <dd>Ajoute un écouteur à cet événement.</dd> + <dt><code>removeListener(listener)</code></dt> + <dd>Arrêtez d'écouter cet événement. L'argument <code>listener</code> est l'écouteur à supprimer.</dd> + <dt><code>hasListener(listener)</code></dt> + <dd>Vérifie si un <code>écouteur</code> est enregistré pour cet événement. Retourne <code>true</code> s'il est écouté, sinon <code>false</code>.</dd> +</dl> + +<h2 id="Syntaxe_addListener">Syntaxe addListener</h2> + +<h3 id="Paramètres">Paramètres</h3> + +<dl> + <dt><code>callback</code></dt> + <dd> + <p>Fonction dui sera appelée lorsque cet événement se produit</p> + </dd> +</dl> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.onSuspend")}}</p> + +<h2 id="Exemples">Exemples</h2> + +<p>Ecoutez les événements suspendus :</p> + +<pre class="brush: js">function handleSuspend() { + console.log("Suspending event page"); + // handle cleanup +} + +browser.runtime.onSuspend.addListener(handleSuspend);</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/onsuspendcanceled/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/onsuspendcanceled/index.html new file mode 100644 index 0000000000..cf01913334 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/onsuspendcanceled/index.html @@ -0,0 +1,103 @@ +--- +title: runtime.onSuspendCanceled +slug: Mozilla/Add-ons/WebExtensions/API/runtime/onSuspendCanceled +tags: + - API + - Add-ons + - Event + - Extensions + - Non-standard + - Reference + - WebExtensions + - onSuspendCanceled + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/onSuspendCanceled +--- +<div>{{AddonSidebar()}}</div> + +<p>Envoyé après {{WebExtAPIRef("runtime.onSuspend")}} pour indiquer que l'application ne sera pas déchargée après tout.</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">browser.runtime.onSuspendCanceled.addListener(listener) +browser.runtime.onSuspendCanceled.removeListener(listener) +browser.runtime.onSuspendCanceled.hasListener(listener) +</pre> + +<p>Les événements ont trois fonctions :</p> + +<dl> + <dt><code>addListener(callback)</code></dt> + <dd>Ajouter un écouteur à cet événement.</dd> + <dt><code>removeListener(listener)</code></dt> + <dd>Arrêtez d'écouter cet événement. L'argument <code>listener</code> est un écouteur à suppriimer.</dd> + <dt><code>hasListener(listener)</code></dt> + <dd>Vérifie si un <code>écouteur</code> est enregistré pour cet événement. Retourne <code>true</code> s'il écoute, sinon <code>false</code>.</dd> +</dl> + +<h2 id="Syntaxe_addListener">Syntaxe addListener</h2> + +<h3 id="Paramètres">Paramètres</h3> + +<dl> + <dt><code>callback</code></dt> + <dd> + <p>Fonction qui sera appelée lorsque cet événement se produit.</p> + </dd> +</dl> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p><span class="diff_add">{{Compat("webextensions.api.runtime.onSuspendCanceled")}}</span></p> + +<h2 id="Exemples">Exemples</h2> + +<p>Ecoutez les événements <code>SuspendCanceled</code> :</p> + +<pre class="brush: js">function handleSuspendCanceled() { + console.log("Suspend canceled"); +} + +browser.runtime.onSuspendCanceled.addListener(handleSuspendCanceled);</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/onupdateavailable/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/onupdateavailable/index.html new file mode 100644 index 0000000000..d1795b9b05 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/onupdateavailable/index.html @@ -0,0 +1,116 @@ +--- +title: runtime.onUpdateAvailable +slug: Mozilla/Add-ons/WebExtensions/API/runtime/onUpdateAvailable +tags: + - API + - Add-ons + - Event + - Extensions + - Non-standard + - Reference + - WebExtensions + - onUpdateAvailable + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/onUpdateAvailable +--- +<div>{{AddonSidebar()}}</div> + +<p>Déclenché quand une mise à jour de l'extension est disponible. Cet événement permet à une extension de retarder une mise à jour : par exemple, car elle est au milieu d'une opération qui ne doit pas être interrompue.</p> + +<p>Si l'extension n'écoute pas cet événement lorsqu'une mise à jour est disponible, l'extension est rechargée immédiatement et la mise à jour est appliquée. Si l'extension est à l'écoute, la mise à jour sera appliquée la prochaine fois que l'extension sera rechargée. Cela arrive si :</p> + +<ul> + <li>Le navigateur est redémarré</li> + <li>L'extension est désactivée et réactivée</li> + <li>L'extension se recharge explicitement en appelant {{WebExtAPIRef('runtime.reload()')}}.</li> +</ul> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">browser.runtime.onUpdateAvailable.addListener() +browser.runtime.onUpdateAvailable.removeListener(listener) +browser.runtime.onUpdateAvailable.hasListener(listener) +</pre> + +<p>Les événements ont trois fonctions :</p> + +<dl> + <dt><code>addListener(callback)</code></dt> + <dd>Ajouter un écouteur à cet événement.</dd> + <dt><code>removeListener(listener)</code></dt> + <dd>Arrêtez d'écouter cet événement. L'argument<code>listener</code> est un écouteur à supprimer.</dd> + <dt><code>hasListener(listener)</code></dt> + <dd>Vérifie que l'<code>écouteur</code> est enregistré pour cet événement. Retourne <code>true</code> s'il écoute, sinon <code>false</code>.</dd> +</dl> + +<h2 id="Syntaxe_addListener">Syntaxe addListener</h2> + +<h3 id="Paramètres">Paramètres</h3> + +<dl> + <dt><code>callback</code></dt> + <dd> + <p>Fonction qui sera appelée quand cet événement se produit. La fonction recevra les arguments suivants :</p> + + <dl class="reference-values"> + <dt><code>details</code></dt> + <dd><code>object</code>. Contient une seule propriété, une chaîne nommée <code>version</code>, qui représente le numéro de version de la mise à jour.</dd> + </dl> + </dd> +</dl> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.onUpdateAvailable")}}</p> + +<h2 id="Exemples">Exemples</h2> + +<p>Ecoutez les événements <code>UpdateAvailable</code>:</p> + +<pre class="brush: js">function handleUpdateAvailable(details) { + console.log(details.version); +} + +browser.runtime.onUpdateAvailable.addListener(handleUpdateAvailable);</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/openoptionspage/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/openoptionspage/index.html new file mode 100644 index 0000000000..ab58180798 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/openoptionspage/index.html @@ -0,0 +1,86 @@ +--- +title: runtime.openOptionsPage() +slug: Mozilla/Add-ons/WebExtensions/API/runtime/openOptionsPage +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/openOptionsPage +--- +<div>{{AddonSidebar()}}</div> + +<div>Si votre extension a défini une <a href="/fr/Add-ons/WebExtensions/user_interface/Options_pages">page d'options</a>, cette méthode l'ouvre.</div> + +<div></div> + +<p>C'est une fonction asynchrone qui renvoie une <code><a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/Promise">Promise</a></code>.</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">var openingPage = browser.runtime.openOptionsPage() +</pre> + +<h3 id="Paramètres">Paramètres</h3> + +<p>None.</p> + +<h3 id="valeur_retournée">valeur retournée</h3> + +<p>Une <code><a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/Promise">Promise</a></code> qui sera remplie sans argument lorsque la page d'options a été créée avec succés, ou rejetée avec un message d'erreur si l'opération a échoué.</p> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.openOptionsPage")}}</p> + +<h2 id="Exemples">Exemples</h2> + +<p>Ouvrez une page d'options lorsque l'utilisateur clique sur l'icône d'une action du navigateur :</p> + +<pre class="brush: js">function onOpened() { + console.log(`Options page opened`); +} + +function onError(error) { + console.log(`Error: ${error}`); +} + +var opening = browser.runtime.openOptionsPage(); +opening.then(onOpened, onError);</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/platformarch/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/platformarch/index.html new file mode 100644 index 0000000000..84d8172bb4 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/platformarch/index.html @@ -0,0 +1,77 @@ +--- +title: runtime.PlatformArch +slug: Mozilla/Add-ons/WebExtensions/API/runtime/PlatformArch +tags: + - API + - Add-ons + - Extensions + - Non-standard + - PlatformArch + - Reference + - Type + - WebExtensions + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/PlatformArch +--- +<div>{{AddonSidebar()}}</div> + +<p>L'architecture du processeur de la machine.</p> + +<h2 id="Type">Type</h2> + +<p>Les valeurs de ce type sont des chaînes. Les valeurs possible sont :</p> + +<dl> + <dt><code>"arm"</code></dt> + <dd>La plateforme est basée sur l'architecture des bras.</dd> + <dt><code>"x86-32"</code></dt> + <dd>La plateforme est basé sur l'architecture x86 32-bits.</dd> + <dt><code>"x86-64"</code></dt> + <dd>La plateforme est basé sur l'architecture x86 64-bits.</dd> +</dl> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.PlatformArch")}}</p> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/platforminfo/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/platforminfo/index.html new file mode 100644 index 0000000000..30ff35a1ce --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/platforminfo/index.html @@ -0,0 +1,77 @@ +--- +title: runtime.PlatformInfo +slug: Mozilla/Add-ons/WebExtensions/API/runtime/PlatformInfo +tags: + - API + - Add-ons + - Extensions + - Non-standard + - PlatformInfo + - Reference + - Type + - WebExtensions + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/PlatformInfo +--- +<div>{{AddonSidebar()}}</div> + +<p>Un objet contenant des informations sur la plate-forme actuelle.</p> + +<h2 id="Type">Type</h2> + +<p>Les valeurs de ce type sont des objets qui contiennent les propriétés suivantes:</p> + +<dl class="reference-values"> + <dt><code>os</code></dt> + <dd>{{WebExtAPIRef('runtime.PlatformOs')}}. Le système d'exploitation de la plateforme.</dd> + <dt><code>arch</code></dt> + <dd>{{WebExtAPIRef('runtime.PlatformArch')}}. L'architecture du processeur de la plateforme.</dd> + <dt><code>nacl_arch</code></dt> + <dd>{{WebExtAPIRef('runtime.PlatformNaclArch')}}. L'architecture du client natif Cela peut être différent de <code>arch</code> sur certaines plates-formes.</dd> +</dl> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p><span class="diff_add">{{Compat("webextensions.api.runtime.PlatformInfo")}}</span></p> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/platformnaclarch/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/platformnaclarch/index.html new file mode 100644 index 0000000000..9880430b69 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/platformnaclarch/index.html @@ -0,0 +1,68 @@ +--- +title: runtime.PlatformNaclArch +slug: Mozilla/Add-ons/WebExtensions/API/runtime/PlatformNaclArch +tags: + - API + - Add-ons + - Extensions + - Non-standard + - PlatformNaclArch + - Reference + - Type + - WebExtensions + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/PlatformNaclArch +--- +<p>{{AddonSidebar()}}</p> + +<p>L'architecture du client natif. Cela peut-etre différent de arch sur certaines plate-formes.</p> + +<h2 id="Type">Type</h2> + +<p>Les valeurs de type sont des chaînes. Les valeurs possible sont : <code>"arm"</code>, <code>"x86-32"</code>, <code>"x86-64"</code>.</p> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p><span class="diff_add">{{Compat("webextensions.api.runtime.PlatformNaclArch")}}</span></p> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/platformos/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/platformos/index.html new file mode 100644 index 0000000000..64911f28b3 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/platformos/index.html @@ -0,0 +1,83 @@ +--- +title: runtime.PlatformOs +slug: Mozilla/Add-ons/WebExtensions/API/runtime/PlatformOs +tags: + - API + - Add-ons + - Extensions + - Non-standard + - PlatformOs + - Reference + - Type + - WebExtensions + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/PlatformOs +--- +<div>{{AddonSidebar()}}</div> + +<p>Le système d'exploitation sur lequel le navigateur fonctionne.</p> + +<h2 id="Type">Type</h2> + +<p>Les valeurs de ce type sont des chaînes. Les valeurs possibles sont:</p> + +<dl> + <dt><code>"mac"</code></dt> + <dd>Le système d'exploitation est sous Mac OS X.</dd> + <dt><code>"win"</code></dt> + <dd>Le système d'exploitation est sous Windows.</dd> + <dt><code>"android"</code></dt> + <dd>Le système d'exploitation est sous Android.</dd> + <dt><code>"cros"</code></dt> + <dd>Le système d'exploitation est sous Chrome OS.</dd> + <dt><code>"linux"</code></dt> + <dd>Le système d'exploitation est sous Linux.</dd> + <dt><code>"openbsd"</code></dt> + <dd>Le système d'exploitation est sous Open/FreeBSD.</dd> +</dl> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.PlatformOs")}}</p> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/port/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/port/index.html new file mode 100644 index 0000000000..eb8e904ad7 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/port/index.html @@ -0,0 +1,248 @@ +--- +title: runtime.Port +slug: Mozilla/Add-ons/WebExtensions/API/runtime/Port +tags: + - API + - Add-ons + - Extensionns + - Non-standard + - Reference + - Type + - WebExtensions + - port + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/Port +--- +<div>{{AddonSidebar()}}</div> + +<p>Un objet <code>Port</code> represente une extrémité d'une connexion entre deux contextes spécifiques, qui peut-être utilisée pour échanger des messages.</p> + +<p>Un côté initie la connexion à l'aide d'une API <code>connect()</code>. Cela retourne un objet <code>Port</code>. L'autre camp écoute les tentatives de connexion à l'aide d'un écouteur <code>onConnect</code>. Ceci est passé un objet <code>Port</code> correspondant.</p> + +<p>Une fois que les deux côtés ont des objets <code>Port,</code> ils peuvent échanger des messages JSON en utilisant <code>Port.postMessage()</code> et <code>Port.onMessage</code>. Quand ils sont terminés, chaque extrémité peut se déconnecter en utilisant <code>Port.disconnect()</code>, ce qui générera un événement <code>Port.onDisconnect</code> à l'autre extrémité, permettant à l'autre extrémité de faire le nettoyage requis.</p> + +<p>Vous pouvez utiliser ce modèle pour communiquer entre:</p> + +<ul> + <li>différentes parties de votre extension (par exemple, entre les <a href="/fr/Add-ons/WebExtensions/Content_scripts">scripts de contenus</a> et les <a href="/fr/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Background_scripts">scripts d'arrière-plan</a>)</li> + <li>entre votre extension et une <a href="/fr/Add-ons/WebExtensions/Native_messaging">application native s'exéutant sur l'ordinateur de l'utilisateur</a>.</li> + <li>entre votre extension et une extension différente</li> +</ul> + +<p>Vous devez utiliser différentes API de connexion pour différents types de connexions, comme indiqué dans le tableau ci-dessous.</p> + +<table class="fullwidth-table standard-table"> + <thead> + <tr> + <th scope="col">type de connection</th> + <th scope="col">Lancer une tentative de connexion</th> + <th scope="col">Gérer la tentative de connexion</th> + </tr> + </thead> + <tbody> + <tr> + <td>Script d'arrière-plan au script de contenu</td> + <td>{{WebExtAPIRef("tabs.connect()")}}</td> + <td>{{WebExtAPIRef("runtime.onConnect")}}</td> + </tr> + <tr> + <td>Script de contenu au script d'arrière-plan</td> + <td>{{WebExtAPIRef("runtime.connect()")}}</td> + <td>{{WebExtAPIRef("runtime.onConnect")}}</td> + </tr> + <tr> + <td>Extension à l'application native</td> + <td>{{WebExtAPIRef("runtime.connectNative()")}}</td> + <td>N'est pas applicable (voir <a href="/fr/Add-ons/WebExtensions/Native_messaging">Native messaging</a>).</td> + </tr> + <tr> + <td>Extension à l'extension</td> + <td>{{WebExtAPIRef("runtime.connect()")}}</td> + <td>{{WebExtAPIRef("runtime.onConnectExternal")}}</td> + </tr> + </tbody> +</table> + +<h2 id="Type">Type</h2> + +<p>Les valeurs de ce type sont des objets. Ils contiennent les propriétés suivantes :</p> + +<dl class="reference-values"> + <dt><code>name</code></dt> + <dd><code>string</code>. Le nom du port, défini dans {{WebExtAPIRef("runtime.connect()")}} ou {{WebExtAPIRef("tabs.connect()")}} appel qui l'a créé. Si ce port est connecté à une application native, son nom est le nom de l'application native.</dd> + <dt><code>disconnect</code></dt> + <dd><code>function</code>. Déconnecte un port. Chaque extrémité peut appeler cela quand ils ont fini avec le port. Cela provoquera le déclenchement de <code>onDisconnect</code> à l'autre extrémité. Ceci est utile si l'autre extrémité maintient un état relatif à ce port, qui peut être nettoyé lors de la déconnexion. Si ce port est connecté à une application native, cette fonction ferme l'application native.</dd> + <dt><code>error</code></dt> + <dd><code>object</code>. Si le port a été déconnecté en raison d'une erreur, il sera défini sur un objet avec un <code>message</code>, de propriété de chaîne, vous donnant plus d'informations sur l'erreur. Voir <code>onDisconnect</code>.</dd> + <dt><code>onDisconnect</code></dt> + <dd> + <p><code>object</code>. Cela contient les fonctions <code>addListener()</code> et <code>removeListener()</code> communes à tous les événements pour les extensions créées à l'aide des API. WebExtension. Les fonctions de l'écouteur seront appelées lorsque l'autre extrémité aura appelé <code>Port.disconnect()</code>. Cet événement ne sera déclenché qu'une fois pour chaque port. La fonction d'écouteur recevra l'objet <code>Port</code>. Si le port a été déconnecté en raison d'une erreur, l'argument <code>Port</code> contiendra une propriété <code>error</code> donnant plus d'informations sur l'erreur :</p> + + <pre class="brush: js">port.onDisconnect.addListener((p) => { + if (p.error) { + console.log(`Disconnected due to an error: ${p.error.message}`); + } +});</pre> + + <p>Notez que dans Google Chrome <code>port.error</code> n'est pas supporté: utilisez plutôt {{WebExtAPIRef("runtime.lastError")}} pour obtenir le message d'erreur.</p> + </dd> + <dt><code>onMessage</code></dt> + <dd><code>object</code>. Cela contient les fonctions <code>addListener()</code> et <code>removeListener()</code> communes à tous les événements pour les extensions créées à l'aide des API WebExtension. Les fonctions de l'écouteur seront appelées lorsque l'autre extrémité aura envoyé un message à ce port. L'écouteur recevra l'objet JSON envoyé par l'autre extrémité.</dd> + <dt><code>postMessage</code></dt> + <dd><code>function</code>. Envoyer un message à l'autre extrémité. Cela prend un argument, qui est un objet JSON représentant le message à envoyer. Il sera fourni à tout script écoutant l'événement <code>onMessage</code> du port, ou à l'application native si ce port est connecté à une application native.</dd> + <dt><code>sender</code>{{optional_inline}}</dt> + <dd>{{WebExtAPIRef('runtime.MessageSender')}}. Contient des informations sur l'expéditeur du message. ette propriété ne sera présente que sur les ports transmis aux écouteurs <code>onConnect</code>/<code>onConnectExternal</code>.</dd> +</dl> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.Port")}}</p> + +<h2 id="Exemples">Exemples</h2> + +<h3 id="Connecting_from_content_scripts">Connecting from content scripts</h3> + +<p>This content script:</p> + +<ul> + <li>connects to the background script and stores the <code>Port</code> in a variable called <code>myPort</code>.</li> + <li>listens for messages on <code>myPort</code> and logs them.</li> + <li>sends messages to the background script, using <code>myPort</code>, when the user clicks the document.</li> +</ul> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="comment token">// content-script.js</span> + +<span class="keyword token">var</span> myPort <span class="operator token">=</span> browser<span class="punctuation token">.</span>runtime<span class="punctuation token">.</span><span class="function token">connect</span><span class="punctuation token">(</span><span class="punctuation token">{</span>name<span class="punctuation token">:</span><span class="string token">"port-from-cs"</span><span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> +myPort<span class="punctuation token">.</span><span class="function token">postMessage</span><span class="punctuation token">(</span><span class="punctuation token">{</span>greeting<span class="punctuation token">:</span> <span class="string token">"hello from content script"</span><span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + +myPort<span class="punctuation token">.</span>onMessage<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span><span class="keyword token">function</span><span class="punctuation token">(</span>m<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"In content script, received message from background script: "</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>m<span class="punctuation token">.</span>greeting<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + +document<span class="punctuation token">.</span>body<span class="punctuation token">.</span><span class="function token">addEventListener</span><span class="punctuation token">(</span><span class="string token">"click"</span><span class="punctuation token">,</span> <span class="keyword token">function</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> + myPort<span class="punctuation token">.</span><span class="function token">postMessage</span><span class="punctuation token">(</span><span class="punctuation token">{</span>greeting<span class="punctuation token">:</span> <span class="string token">"they clicked the page!"</span><span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<p>The corresponding background script:</p> + +<ul> + <li>listens for connection attempts from the content script.</li> + <li>when it receives a connection attempt: + <ul> + <li>stores the port in a variable named <code>portFromCS</code>.</li> + <li>sends the content script a message using the port.</li> + <li>starts listening to messages received on the port, and logs them.</li> + </ul> + </li> + <li>sends messages to the content script, using <code>portFromCS</code>, when the user clicks the extension's browser action.</li> +</ul> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="comment token">// background-script.js</span> + +<span class="keyword token">var</span> portFromCS<span class="punctuation token">;</span> + +<span class="keyword token">function</span> <span class="function token">connected</span><span class="punctuation token">(</span>p<span class="punctuation token">)</span> <span class="punctuation token">{</span> + portFromCS <span class="operator token">=</span> p<span class="punctuation token">;</span> + portFromCS<span class="punctuation token">.</span><span class="function token">postMessage</span><span class="punctuation token">(</span><span class="punctuation token">{</span>greeting<span class="punctuation token">:</span> <span class="string token">"hi there content script!"</span><span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + portFromCS<span class="punctuation token">.</span>onMessage<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span><span class="keyword token">function</span><span class="punctuation token">(</span>m<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"In background script, received message from content script"</span><span class="punctuation token">)</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>m<span class="punctuation token">.</span>greeting<span class="punctuation token">)</span><span class="punctuation token">;</span> + <span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +browser<span class="punctuation token">.</span>runtime<span class="punctuation token">.</span>onConnect<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span>connected<span class="punctuation token">)</span><span class="punctuation token">;</span> + +browser<span class="punctuation token">.</span>browserAction<span class="punctuation token">.</span>onClicked<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span><span class="keyword token">function</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> + portFromCS<span class="punctuation token">.</span><span class="function token">postMessage</span><span class="punctuation token">(</span><span class="punctuation token">{</span>greeting<span class="punctuation token">:</span> <span class="string token">"they clicked the button!"</span><span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<h4 id="Script_à_contenu_multiple">Script à contenu multiple</h4> + +<p>Si plusieurs scripts de contenu communiquent en même temps, vous voudrez peut-être stocker chaque connexion dans un tableau.</p> + +<ul> +</ul> + +<pre class="brush: js">// background-script.js + +var ports = [] + +function connected(p) { + ports[p.sender.tab.id] = p + //... +} + +browser.runtime.onConnect.addListener(connected) + +browser.browserAction.onClicked.addListener(function() { + ports.forEach(p => { + p.postMessage({greeting: "they clicked the button!"}) + }) +});</pre> + +<h3 id="Connecting_to_native_applications">Connecting to native applications</h3> + +<p>This example connects to the native application "ping_pong" and starts listening for messages from it. It also sends the native application a message when the user clicks a browser action icon:</p> + +<pre class="brush: js">/* +On startup, connect to the "ping_pong" app. +*/ +var port = browser.runtime.connectNative("ping_pong"); + +/* +Listen for messages from the app. +*/ +port.onMessage.addListener((response) => { + console.log("Received: " + response); +}); + +/* +On a click on the browser action, send the app a message. +*/ +browser.browserAction.onClicked.addListener(() => { + console.log("Sending: ping"); + port.postMessage("ping"); +});</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/reload/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/reload/index.html new file mode 100644 index 0000000000..05b9a48524 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/reload/index.html @@ -0,0 +1,83 @@ +--- +title: runtime.reload() +slug: Mozilla/Add-ons/WebExtensions/API/runtime/reload +tags: + - API + - Add-ons + - Extensions + - Method + - Non-standard + - Reference + - WebExtensions + - reload + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/reload +--- +<div>{{AddonSidebar()}}</div> + +<p>Recharge une extension.</p> + +<p>S'il y a des mises à jour en attente pour l'extension, qu'elles ont été différées en écoutant {{WebExtAPIRef("runtime.onUpdateAvailable")}}, elles seront appliquées en reload.</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">browser.runtime.reload() +</pre> + +<h3 id="Paramètres">Paramètres</h3> + +<p>Aucun.</p> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.reload")}}</p> + +<h2 id="Exemples">Exemples</h2> + +<p>Rechargez l'extension lorsque l'utilisateur clique sur l'icône d'une action du navigateur :</p> + +<pre class="brush: js">browser.browserAction.onClicked.addListener((tab) => { + browser.runtime.reload(); +});</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/requestupdatecheck/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/requestupdatecheck/index.html new file mode 100644 index 0000000000..1adb3de2bc --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/requestupdatecheck/index.html @@ -0,0 +1,110 @@ +--- +title: runtime.requestUpdateCheck() +slug: Mozilla/Add-ons/WebExtensions/API/runtime/requestUpdateCheck +tags: + - API + - Add-ons + - Extensions + - Méthode + - Non-standard + - Reference + - WebExtensions + - requestUpdateCheck + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/requestUpdateCheck +--- +<div>{{AddonSidebar()}}</div> + +<p>Vérifie de voir si un mise à jour de l'extension est disponible.</p> + +<p>C'est une fonction asynchrone qui renvoie une <code><a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/Promise">Promise</a></code>.</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">var requestingCheck = browser.runtime.requestUpdateCheck() +</pre> + +<h3 id="Paramètres">Paramètres</h3> + +<p>None.</p> + +<h3 id="Valeur_retournée">Valeur retournée</h3> + +<p>Une <code><a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/Promise">Promise</a></code> qui sera remplie avec deux arguments :</p> + +<dl class="reference-values"> + <dt><code>status</code></dt> + <dd>Une valeur {{WebExtAPIRef('runtime.RequestUpdateCheckStatus')}} — Le résultat de la vérification de mise à jour.</dd> + <dt><code>details</code>{{optional_inline}}</dt> + <dd><code>object</code>. Si le <code>status</code> est <code>update_available</code>, cela contient plus d'informations sur la mise à jour. C'est un objet contenant une simple propriété :</dd> + <dd> + <dl> + <dt><code>version</code></dt> + <dd><code>string</code>. La version de la mise à jour.</dd> + </dl> + </dd> +</dl> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p><span class="diff_add">{{Compat("webextensions.api.runtime.requestUpdateCheck")}}</span></p> + +<h2 id="Exemples">Exemples</h2> + +<p>Demander une mise à jour, etenregistrer la nouvelle version si elle est disponible :</p> + +<pre class="brush: js">function onRequested(status, details) { + console.log(status); + if (status === "update_available") { + console.log(details.version); + } +} + +function onError(error) { + console.log(`Error: ${error}`); +} + +var requestingCheck = browser.runtime.requestUpdateCheck(onRequested); +requestingCheck.then(onRequested, onError);</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/requestupdatecheckstatus/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/requestupdatecheckstatus/index.html new file mode 100644 index 0000000000..15268f7523 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/requestupdatecheckstatus/index.html @@ -0,0 +1,77 @@ +--- +title: runtime.RequestUpdateCheckStatus +slug: Mozilla/Add-ons/WebExtensions/API/runtime/RequestUpdateCheckStatus +tags: + - API + - Add-ons + - Extensions + - Non-standard + - Reference + - RequestUpdateCheckStatus + - Type + - WebExtensions + - runtime +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/RequestUpdateCheckStatus +--- +<div>{{AddonSidebar()}}</div> + +<p>Résultat d'un appel à {{WebExtAPIRef("runtime.requestUpdateCheck()")}}.</p> + +<h2 id="Type">Type</h2> + +<p>Les valeurs de ce type sont des chaînes. Les valeurs possibles sont :</p> + +<dl> + <dt><code>"throttled"</code></dt> + <dd>La mise à jour est limitée.</dd> + <dt><code>"no_update"</code></dt> + <dd>Aucune mise à jour n'est disponible.</dd> + <dt><code>"update_available"</code></dt> + <dd>Une mise à jour de l'extension est disponible.</dd> +</dl> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.RequestUpdateCheckStatus")}}</p> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/sendmessage/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/sendmessage/index.html new file mode 100644 index 0000000000..1768aaed86 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/sendmessage/index.html @@ -0,0 +1,167 @@ +--- +title: runtime.sendMessage() +slug: Mozilla/Add-ons/WebExtensions/API/runtime/sendMessage +tags: + - API + - Add-ons + - Extensions + - Method + - Non-standard + - Reference + - WebExtensions + - runtime + - sendMessage +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/sendMessage +--- +<div>{{AddonSidebar()}}</div> + +<p>Envoie un simple message aux écouteurs d'événement dans votre extension ou une extension différente.</p> + +<p>Si vous envoyez à votre extension, omettez l'argument <code>extensionId</code>. L'événement {{WebExtAPIRef('runtime.onMessage')}} sera déclenché dans chaque page de votre extension, à l'exception du cadre appelé <code>runtime.sendMessage</code>.</p> + +<p>Si vous envoyez une extension différente, ajouter l'argument <code>extensionId</code> à l'ID de l'autre extension. {{WebExtAPIRef('runtime.onMessageExternal')}} sera déclenché dans l'autre extension.</p> + +<p>Les extensions ne peuvent pas envoyer de messages aux scripts de contenu en utilisant cette méthode. Pour envoyer des messages aux scripts de contenu, utilisez {{WebExtAPIRef('tabs.sendMessage')}}.</p> + +<ul> +</ul> + +<p>C'est une fonction asynchrone qui renvoie une <code><a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/Promise">Promise</a></code>.</p> + +<div class="blockIndicator note"> +<p>Vous pouvez également utiliser une <a href="/fr/docs/Mozilla/Add-ons/WebExtensions/Content_scripts#Communication_avec_les_scripts_darrière-plan">approche basée sur la connexion pour échanger des messages</a>.</p> +</div> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">var sending = browser.runtime.sendMessage( + extensionId, // optional string + message, // any + options // optional object +) +</pre> + +<h3 id="Paramètres">Paramètres</h3> + +<dl> + <dt><code>extensionId</code>{{optional_inline}}</dt> + <dd><code>string</code>. L'ID de l'extension à envoyer le message. Incluez ceci pour envoyer le message à une extension différente..Si le destinataire prévu a défini un ID explicitement en utilisant la clé d' <a href="/fr/Add-ons/WebExtensions/manifest.json/applications">applications</a> dans manifest.json, <code>extensionId</code> doit avoir une valeur. Sinon, il devrait avoir l'ID qui a été généré pour le destinataire prévu.</dd> + <dd>Si <code>extensionId</code> est omis, le message sera envoyé à votre propre extension.</dd> + <dt><code>message</code></dt> + <dd><code>any</code>. Un objet qui peut être structuré clone sérialisé.</dd> + <dt><code>options</code>{{optional_inline}}</dt> + <dd><code>object</code>. + <dl class="reference-values"> + <dt><code>includeTlsChannelId</code>{{optional_inline}}</dt> + <dd><code>boolean</code>. Indique si l'ID de canal TLS sera transmis à {{WebExtAPIRef('runtime.onMessageExternal')}} pour les processus qui écoutent l'événement de connexion.</dd> + <dt><code>toProxyScript{{optional_inline}}</code></dt> + <dd><code>boolean</code>. Doit être True si le message est destiné à un fichier PAC chargé à l'aide de l'API {{WebExtAPIRef("proxy")}}.</dd> + </dl> + </dd> +</dl> + +<p>En fonction des arguments qui lui sont donnés, cette API est parfois ambiguë. Les règles suivantes sont utilisées :</p> + +<ul> + <li><strong>Si un argument est donné</strong>, c'est le message à envoyer, et le message sera envoyé en interne.</li> + <li><strong>Si deux arguments sont donnés :</strong> + <ul> + <li>Les arguments sont interprétés comme (message, options) et le message est envoyé en interne si le second argument est l'un des suivants : + <ol> + <li>Un objet d'options valide (c'est-à-dire un objet qui ne contient que les propriétés des options supportés par le navigateur)</li> + <li>null</li> + <li>indéfini</li> + </ol> + </li> + <li>Sinon, les arguments sont interprétés comme <code>(extensionId, message)</code>. Le message sera envoyé à l'extension identifiée par <code>extensionId</code>.</li> + </ul> + </li> + <li><strong>Si trois arguments sont donnés</strong>, les arguments sont interprétés comme <code>(extensionId, message, options)</code>. Le message sera envoyé à l'extension identifiée par <code>extensionId</code>.</li> +</ul> + +<p>Notez qu'avant Firefox 55, le règles étaient différentes dans le cas des 2 arguments. Sous les anciennes règles, si le premier argument était une chaîne, il était traité comme <code>extensionId</code>, avec le message comme deuxième argument. Cel signifiait que si vous appelez <code>sendMessage()</code> avec des arguments comme <code>("my-message", {})</code>, il enverrait un message vide à l'extension identifiée par "my-message". Sous les nouvelles règles, avec ces arguments, vous enverriez le message "my-message" en interne, avec un objet options vide.</p> + +<h3 id="Valeur_retournée">Valeur retournée</h3> + +<p>Une <code><a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/Promise">Promise</a></code>. Si le destinataire a envoyé une réponse, celle-ci sera remplie avec la réponse en tant qu'objet JSON. Sinon, il sera rempli sans arguments. si une erreur survient lors de la connexion à l'extension, la promessage sera rejetée avec un message d'erreur.</p> + +<h2 id="Compatibilité_du_navitageur">Compatibilité du navitageur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p><span class="diff_add">{{Compat("webextensions.api.runtime.sendMessage")}}</span></p> + +<h2 id="Exemples">Exemples</h2> + +<p>Voici un script de contenu qui envoie un message au script d'arrière-plan lorsque l'utilisateur clique sur la fenêtre de contenu. La charge utile du message est <code>{greeting: "Greeting from the content script"}</code>, et l'expéditeur s'attend également à recevoir une réponse, qui est gérée dans la fonction <code>handleResponse</code> :</p> + +<pre class="brush: js">// content-script.js + +function handleResponse(message) { + console.log(`Message from the background script: ${message.response}`); +} + +function handleError(error) { + console.log(`Error: ${error}`); +} + +function notifyBackgroundPage(e) { + var sending = browser.runtime.sendMessage({ + greeting: "Greeting from the content script" + }); + sending.then(handleResponse, handleError); +} + +window.addEventListener("click", notifyBackgroundPage);</pre> + +<p>Le script d'arrière-plan correspondant ressemble à ceci :</p> + +<pre class="brush: js">// background-script.js + +function handleMessage(request, sender, sendResponse) { + console.log("Message from the content script: " + + request.greeting); + sendResponse({response: "Response from background script"}); +} + +browser.runtime.onMessage.addListener(handleMessage);</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/sendnativemessage/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/sendnativemessage/index.html new file mode 100644 index 0000000000..af714bdb80 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/sendnativemessage/index.html @@ -0,0 +1,114 @@ +--- +title: runtime.sendNativeMessage() +slug: Mozilla/Add-ons/WebExtensions/API/runtime/sendNativeMessage +tags: + - API + - Add-ons + - Extensions + - Method + - Non-standard + - Reference + - WebExtensions + - runtime + - sendNativeMessage +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/sendNativeMessage +--- +<div>{{AddonSidebar()}}</div> + +<p>Envoie un seul message d'une extension à une application native.</p> + +<p>Cela prend deux paramètres obligatoires : le nom de l'application native et un objet JSON qui est le message à envoyer. Le navigateur lancera l'application native et délivrera le message.</p> + +<p>C'est une fonction asynchrone qui renvoie une <code><a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/Promise">Promise</a></code>. The first message sent by the native application is treated as a response to the <code>sendNativeMessage()</code> call, and the promise will be fulfilled with this message as a parameter. Note that you can't use {{WebExtAPIRef("runtime.onMessage")}} to get responses from the application: you must use the callback function instead.</p> + +<p>Une nouvelle instance de l'application est lancée pour appel à <code>runtime.sendNativeMessage()</code>. Le navigateur terminera l'application native après avoir reçu une réponse. Pour mettre fin à une application native, le navigateur ferme le canal, donne au processus quelques secondes pour quitter normalement, puis le tue s'il ne s'est pas arrêté.</p> + +<p>Pour plus d'informations, voir <a href="/fr/Add-ons/WebExtensions/Native_messaging">Native messaging</a>.</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">var sending = browser.runtime.sendNativeMessage( + application, // string + message // object +) +</pre> + +<h3 id="Paramètres">Paramètres</h3> + +<dl> + <dt><code>application</code></dt> + <dd><code>string</code>. Le nom de l'application native. Cela doit correspondre à la propriété "name" dans le <a href="/fr/Add-ons/WebExtensions/Native_messaging#App_manifest">fichier manifest de l'application native</a>.</dd> + <dt><code>message</code></dt> + <dd><code>object</code>. Un objet JSON qui sera envoyé à l'application native.</dd> +</dl> + +<h3 id="Valeur_retournée">Valeur retournée</h3> + +<p>Une <code><a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/Promise">Promise</a></code>. Si l'expéditeur a envoyé une réponse, celle-ci sera remplie avec la réponse en tant qu'objet JSON. Sinon, il sera rempli sans arguments. Si une erreur survient lors de la connexion à l'application native, la promesse sera rejetée avec un message d'erreur.</p> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p><span class="diff_add">{{Compat("webextensions.api.runtime.sendNativeMessage")}}</span></p> + +<h2 id="Exemples">Exemples</h2> + +<p>Voici un script d'arrière-plan qui envoie un message "ping" à l'application "ping_pong" et enregistre la réponse, chaque fois que l'utilisateur clique sur l'action du navigateur :</p> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">onResponse</span><span class="punctuation token">(</span>response<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">`Received ${</span>response}<span class="punctuation token">`)</span><span class="punctuation token">;</span> +<span class="punctuation token">} + +</span></code>function onError(error) { + console.log(`Error: ${error}`); +}<code class="language-js"> + +<span class="comment token">/* +On a click on the browser action, send the app a message. +*/</span> +browser<span class="punctuation token">.</span>browserAction<span class="punctuation token">.</span>onClicked<span class="punctuation token">.</span><span class="function token">addListener</span><span class="punctuation token">(</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="operator token">=</span><span class="operator token">></span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"Sending: ping"</span><span class="punctuation token">)</span><span class="punctuation token">;</span> + var sending = browser<span class="punctuation token">.</span>runtime<span class="punctuation token">.</span><span class="function token">sendNativeMessage</span><span class="punctuation token">(</span><span class="string token">"ping_pong"</span><span class="punctuation token">,</span> <span class="string token">"ping"</span><span class="punctuation token">)</span><span class="punctuation token">; + sending.then(onResponse, onError);</span> +<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/fr/mozilla/add-ons/webextensions/api/runtime/setuninstallurl/index.html b/files/fr/mozilla/add-ons/webextensions/api/runtime/setuninstallurl/index.html new file mode 100644 index 0000000000..9d74339487 --- /dev/null +++ b/files/fr/mozilla/add-ons/webextensions/api/runtime/setuninstallurl/index.html @@ -0,0 +1,97 @@ +--- +title: runtime.setUninstallURL() +slug: Mozilla/Add-ons/WebExtensions/API/runtime/setUninstallURL +tags: + - API + - Add-ons + - Extensions + - Method + - Non-standard + - Reference + - WebExtensions + - runtime + - setUninstallURL +translation_of: Mozilla/Add-ons/WebExtensions/API/runtime/setUninstallURL +--- +<div>{{AddonSidebar()}}</div> + +<p>Définit l'URL à visiter lorsque l'extension est déinstallée. Cela peut être utilisé pour nettoyer les données côté serveur, effectuer des analyses ou implémenter des enquêtes. L'URL peut contenir au maximum 255 caractères.</p> + +<p>C'est une fonction asynchrone qui renvoie une <code><a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/Promise">Promise</a></code>.</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox brush:js">var settingUrl = browser.runtime.setUninstallURL( + url // string +) +</pre> + +<h3 id="Paramètres">Paramètres</h3> + +<dl> + <dt><code>url</code></dt> + <dd><code>string</code>. L'URL à ouvrir après la désinstallation de l'extension. Cette URL doit avoir un schéma <code>http</code> ou <code>https</code>. Définissez-le sur une chaîne vide pour ne pas ouvrir un nouvel onglet lors de la désinstallation.</dd> +</dl> + +<h3 id="Valeur_retournée">Valeur retournée</h3> + +<p>Une <code><a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/Promise">Promise</a></code> qui sera remplie sans argument lorsque l'URL a été définie ou rejetée avec un message d'erreur si l'opération a échoué.</p> + +<h2 id="Compatibilité_du_navigateur">Compatibilité du navigateur</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.runtime.setUninstallURL")}}</p> + +<h2 id="Exemples">Exemples</h2> + +<pre class="brush: js">function onSetURL() { + console.log("set uninstall URL"); +} + +function onError(error) { + console.log(`Error: ${error}`); +} + +var settingUrl = browser.runtime.setUninstallURL("https://example.org"); +settingUrl.then(onSetURL, onError);</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Remerciements :</strong> + +<p>Cette API est basée sur l'API Chromium <a href="https://developer.chrome.com/extensions/runtime#event-onConnect"><code>chrome.runtime</code></a>. Cette documentation est dérivée de <a href="https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json"><code>runtime.json</code></a> dans le code de Chromium code.</p> + +<p>Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> |
