diff options
Diffstat (limited to 'files/ja/mozilla/add-ons/add-on_manager')
4 files changed, 208 insertions, 0 deletions
diff --git a/files/ja/mozilla/add-ons/add-on_manager/addonauthor/index.html b/files/ja/mozilla/add-ons/add-on_manager/addonauthor/index.html new file mode 100644 index 0000000000..03d58b8a15 --- /dev/null +++ b/files/ja/mozilla/add-ons/add-on_manager/addonauthor/index.html @@ -0,0 +1,31 @@ +--- +title: AddonAuthor +slug: Mozilla/Add-ons/Add-on_Manager/AddonAuthor +tags: + - Add-on Manager + - Add-ons +translation_of: Mozilla/JavaScript_code_modules/Add-on_Manager/AddonAuthor +--- +<p>作成者、開発者、貢献者、アドオンの翻訳者を表します。</p> + + +<h2 id="Attributes" name="Attributes">属性</h2> +<table class="standard-table"> + <tbody> + <tr> + <td class="header">属性</td> + <td class="header">型</td> + <td class="header">説明</td> + </tr> + <tr> + <td><code>name</code></td> + <td><code>string</code></td> + <td>人名</td> + </tr> + <tr> + <td><code>url</code> {{optional_inline}}</td> + <td><code>string</code></td> + <td><code>name</code> 属性で指定した人物の詳細が記載された URL</td> + </tr> + </tbody> +</table> diff --git a/files/ja/mozilla/add-ons/add-on_manager/addonscreenshot/index.html b/files/ja/mozilla/add-ons/add-on_manager/addonscreenshot/index.html new file mode 100644 index 0000000000..b3a81b55e5 --- /dev/null +++ b/files/ja/mozilla/add-ons/add-on_manager/addonscreenshot/index.html @@ -0,0 +1,34 @@ +--- +title: AddonScreenshot +slug: Mozilla/Add-ons/Add-on_Manager/AddonScreenshot +tags: + - Add-on Manager + - Add-ons +translation_of: Mozilla/JavaScript_code_modules/Add-on_Manager/AddonScreenshot +--- +<p>アドオンのスクリーンショット</p> +<h2 id="Attributes" name="Attributes">属性</h2> +<table class="standard-table"> + <tbody> + <tr> + <td class="header">属性</td> + <td class="header">型</td> + <td class="header">説明</td> + </tr> + <tr> + <td><code>url</code></td> + <td><code>string</code></td> + <td>スクリーンショットの URL</td> + </tr> + <tr> + <td><code>thumbnailURL</code> {{optional_inline}}</td> + <td><code>string</code></td> + <td>スクリーンショットのサムネイルの URL</td> + </tr> + <tr> + <td><code>caption</code> {{optional_inline}}</td> + <td><code>string</code></td> + <td>スクリーンショットのキャプション</td> + </tr> + </tbody> +</table> diff --git a/files/ja/mozilla/add-ons/add-on_manager/code_samples/index.html b/files/ja/mozilla/add-ons/add-on_manager/code_samples/index.html new file mode 100644 index 0000000000..0cc6c7b6ee --- /dev/null +++ b/files/ja/mozilla/add-ons/add-on_manager/code_samples/index.html @@ -0,0 +1,75 @@ +--- +title: コードの実例 +slug: Mozilla/Add-ons/Add-on_Manager/Code_Samples +tags: + - Add-on Manager + - Add-ons +translation_of: Mozilla/JavaScript_code_modules/Add-on_Manager/Code_Samples +--- +<h2 id="Getting_the_directory_where_your_addon_is_located" name="Getting_the_directory_where_your_addon_is_located">アドオンが格納されているディレクトリの取得</h2> + +<p>あなたのアドオンがインストールされているディレクトリを確認する必要がある場合、次の様なトリックを用います。コード中の <var>YOUREXTENSIONID</var> はあなたのアドオンの ID で置き換えてください。</p> + +<pre class="brush: js">Components.utils.import("resource://gre/modules/<code><a href="/ja/Add-ons/Add-on_Manager" title="Add-on Manager">AddonManager.jsm</a></code>"); + +<code><a href="/ja/Add-ons/Add-on_Manager/AddonManager" title="AddonManager">AddonManager</a></code>.<code><a href="/ja/Add-ons/Add-on_Manager/AddonManager#getAddonByID()" title="AddonManager.getAddonByID()">getAddonByID</a></code>("YOUREXTENSIONID", function(addon) { + var addonLocation = addon.<code><a href="/ja/Add-ons/Add-on_Manager/Addon#getResourceURI()" title="Addon.getResourceURI()">getResourceURI</a></code>("").QueryInterface(Components.interfaces.{{ Interface( "nsIFileURL" ) }}).file.path; +}); +</pre> + +<h2 id="Accessing_file_and_version_information" name="Accessing_file_and_version_information">ファイルとバージョン情報へのアクセス</h2> + +<pre class="brush: js">Components.utils.import("resource://gre/modules/<code><a href="/ja/Add-ons/Add-on_Manager" title="Add-on Manager">AddonManager.jsm</a></code>"); + +<code><a href="/ja/Add-ons/Add-on_Manager/AddonManager" title="AddonManager">AddonManager</a></code>.<code><a href="/ja/Add-ons/Add-on_Manager/AddonManager#getAddonByID()" title="AddonManager.getAddonByID()">getAddonByID</a></code>("my-addon@foo.com", function(addon) { + alert("My extension's version is " + addon.version); + alert("Did I remember to include that file.txt file in my XPI? " + + addon.<code><a href="/ja/Add-ons/Add-on_Manager/Addon#hasResource()" title="Addon.hasResource()">hasResource</a></code>("file.txt") ? "YES!" : "No"); + alert("Let's pretend I did, it's available from the URL " + addon.<code><a href="/ja/Add-ons/Add-on_Manager/Addon#getResourceURI()" title="Addon.getResourceURI()">getResourceURI</a></code>("file.txt").spec); +}); +</pre> + +<h2 id="Uninstall_an_addon" name="Uninstall_an_addon">アドオンの削除</h2> + +<pre class="brush: js">Components.utils.import("resource://gre/modules/<code><a href="/ja/Add-ons/Add-on_Manager" title="Add-on Manager">AddonManager.jsm</a></code>"); + +<code><a href="/ja/Add-ons/Add-on_Manager/AddonManager" title="AddonManager">AddonManager</a></code>.<code><a href="/ja/Add-ons/Add-on_Manager/AddonManager#getAddonByID()" title="AddonManager.getAddonByID()">getAddonByID</a></code>("youraddon@youraddon.com", function(addon) { + addon.<code><a href="/ja/Add-ons/Add-on_Manager/Addon#uninstall()" title="Addon.uninstall()">uninstall</a></code>(); +}); +</pre> + +<h2 id="Disable_an_addon" name="Disable_an_addon">アドオンの無効化</h2> + +<pre class="brush: js">Components.utils.import("resource://gre/modules/<code><a href="/ja/Add-ons/Add-on_Manager" title="Add-on Manager">AddonManager.jsm</a></code>"); +<code><a href="/ja/Add-ons/Add-on_Manager/AddonManager" title="AddonManager">AddonManager</a></code>.<code><a href="/ja/Add-ons/Add-on_Manager/AddonManager#getAddonByID()" title="AddonManager.getAddonByID()">getAddonByID</a></code>("youraddon@youraddon.com", function(addon) { + if (addon.isActive) addon.userDisabled = addon.isActive; +}); +</pre> + +<h2 id="Listening_for_addon_uninstall" name="Listening_for_addon_uninstall">アドオンのアンインストールのリスニング</h2> + + +<p>以下の例では、アドオンのアンインストール時にクリーンアップを実行する profile-before-change メッセージを取得する際に確認することができる変数 "beingUninstalled" を設定しています。</p> + + +<pre class="brush: js">var beingUninstalled; + +let listener = { + onUninstalling: function(addon) { + if (addon.id == "youraddon@youraddon.com") { + beingUninstalled = true; + } + }, + onOperationCancelled: function(addon) { + if (addon.id == "youraddon@youraddon.com") { + beingUninstalled = (addon.<code><a href="/ja/Add-ons/Add-on_Manager/AddonManager#Pending_operations" title="AddonManager.pendingOperations">pendingOperations</a></code> & AddonManager.PENDING_UNINSTALL) != 0; + } + } +} + +try { + Components.utils.import("resource://gre/modules/<code><a href="/ja/Add-ons/Add-on_Manager" title="Add-on Manager">AddonManager.jsm</a></code>"); + + <code><a href="/ja/Add-ons/Add-on_Manager/AddonManager" title="AddonManager">AddonManager</a></code>.<code><a href="/ja/Add-ons/Add-on_Manager/AddonManager#addAddonListener()" title="AddonManager.addAddonListener()">addAddonListener</a></code>(listener); +} catch (ex) {} +</pre> diff --git a/files/ja/mozilla/add-ons/add-on_manager/index.html b/files/ja/mozilla/add-ons/add-on_manager/index.html new file mode 100644 index 0000000000..292d5b739b --- /dev/null +++ b/files/ja/mozilla/add-ons/add-on_manager/index.html @@ -0,0 +1,68 @@ +--- +title: Add-on Manager +slug: Mozilla/Add-ons/Add-on_Manager +tags: + - Add-on Manager + - Add-ons + - NeedsEditorialReview + - NeedsTechnicalReview + - NeedsTranslation + - TopicStub +translation_of: Mozilla/JavaScript_code_modules/Add-on_Manager +--- +<p>{{ gecko_minversion_header("2.0") }}</p> + +<p>The Add-on Manager is responsible for managing all of the add-ons installed in the application. Through its APIs information about all installed add-ons can be retrieved and new add-ons can be installed. The APIs are designed to be generic and support many different types of add-ons.</p> + +<p>Many functions in the Add-on Manager interface operate asynchronously returning results through callbacks passed to the functions. The callbacks may be called immediately while the initial function is still executing or shortly after depending on when the requested data becomes available.</p> + +<h2 id="Accessing_installed_add-ons">Accessing installed add-ons</h2> + +<p>Information about installed add-ons can be retrieved through the main <code><a href="/ja/Add-ons/Add-on_Manager/AddonManager" title="AddonManager">AddonManager</a></code> API. All of its functions are asynchronous meaning that a callback function must be passed to receive the <code><a href="/ja/Add-ons/Add-on_Manager/Addon" title="Addon">Addon</a></code> instances. The callback may well only be called after the API function returns. For example:</p> + +<pre class="brush: js">Components.utils.import("resource://gre/modules/AddonManager.jsm"); + +AddonManager.getAllAddons(function(aAddons) { + // Here aAddons is an array of <code><a href="/ja/Add-ons/Add-on_Manager/Addon" title="Addon">Addon</a></code> objects +}); +// This code will execute before the code inside the callback +</pre> + +<p>Notifications about changes to installed add-ons are dispatched to any registered <code><a href="/ja/Add-ons/Add-on_Manager/AddonListener" title="AddonListener">AddonListener</a></code>s. They must be registered through the <code><a href="/ja/Add-ons/Add-on_Manager/AddonManager#addAddonListener()" title="AddonManager.addAddonListener()">addAddonListener()</a></code> method.</p> + +<h2 id="Installing_new_add-ons">Installing new add-ons</h2> + +<p>New add-ons can be installed by using the <code><a href="/ja/Add-ons/Add-on_Manager/AddonManager#getInstallForFile()" title="AddonManager.getInstallForFile()">getInstallForFile()</a></code> or <code><a href="/ja/Add-ons/Add-on_Manager/AddonManager#getInstallForURL()" title="AddonManager.getInstallForURL()">getInstallForURL()</a></code> methods on the <code><a href="/ja/Add-ons/Add-on_Manager/AddonManager" title="AddonManager">AddonManager</a></code> object. These will pass an <code><a href="/ja/Add-ons/Add-on_Manager/AddonInstall" title="AddonInstall">AddonInstall</a></code> instance to the callback which can then be used to install the add-on:</p> + +<pre class="brush: js">Components.utils.import("resource://gre/modules/AddonManager.jsm"); + +AddonManager.getInstallForURL("http://www.foo.com/test.xpi", function(aInstall) { + // aInstall is an instance of <code><a href="/ja/Add-ons/Add-on_Manager/AddonInstall" title="AddonInstall">AddonInstall</a></code> + aInstall.install(); +}, "application/x-xpinstall"); +</pre> + +<p>The progress of <code><a href="/ja/Add-ons/Add-on_Manager/AddonInstall" title="AddonInstall">AddonInstall</a></code>s can be monitored using an <code><a href="/ja/Add-ons/Add-on_Manager/InstallListener" title="InstallListener">InstallListener</a></code>. A listener can be registered either for a specific install using the <code><a href="/ja/Add-ons/Add-on_Manager/AddonInstall#addListener()" title="AddonInstall.addListener()">addListener()</a></code> method or for all installs using the <code><a href="/ja/Add-ons/Add-on_Manager/AddonManager#addInstallListener()" title="AddonManager.addInstallListener()">addInstallListener()</a></code> method.</p> + +<h2 id="Finding_updates">Finding updates</h2> + +<p>Add-ons can be checked for updates using the <code><a href="/ja/Add-ons/Add-on_Manager/Addon#findUpdates()" title="Addon.findUpdates()">findUpdates()</a></code> method. It must be passed an <code><a href="/ja/Add-ons/Add-on_Manager/UpdateListener" title="UpdateListener">UpdateListener</a></code> to receive information about compatibility information and new update information. Any available update is returned as an <code><a href="/ja/Add-ons/Add-on_Manager/AddonInstall" title="AddonInstall">AddonInstall</a></code> which is ready to be downloaded and installed.</p> + +<p>{{ h1_gecko_minversion("Detecting add-on changes", "7.0") }}</p> + +<p>You can also get lists of add-ons that, at startup, were changed in various ways. The <code><a href="/ja/Add-ons/Add-on_Manager/AddonManager#getStartupChanges()" title="AddonManager.getStartupChanges()">getStartupChanges()</a></code> method lets you find out which add-ons were installed, removed, updated, enabled, or disabled at application startup.</p> + +<p>For example, to take a look at the add-ons that were disabled at startup:</p> + +<pre class="brush: js">Components.utils.import("resource://gre/modules/AddonManager.jsm"); + +let addonIDs = AddonManager.getStartupChanges(AddonManager.STARTUP_CHANGE_DISABLED); +if (addonIDs.length > 0) { + // addonIDs is now an array of the add-on IDs that have been disabled +alert("Note: " + addonIDs.length + " add-ons have been disabled."); +} +</pre> + +<h2 id="See_also">See also</h2> + +<p>{{ ListSubpages() }}</p> |