diff options
Diffstat (limited to 'files/fr/mozilla/add-ons/webextensions/api/runtime/oninstalled/index.html')
| -rw-r--r-- | files/fr/mozilla/add-ons/webextensions/api/runtime/oninstalled/index.html | 125 |
1 files changed, 125 insertions, 0 deletions
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> |
