diff options
| author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
|---|---|---|
| committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
| commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
| tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/mozilla/add-ons/webextensions/api/downloads | |
| parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
| download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip | |
initial commit
Diffstat (limited to 'files/zh-cn/mozilla/add-ons/webextensions/api/downloads')
3 files changed, 379 insertions, 0 deletions
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/downloads/download/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/downloads/download/index.html new file mode 100644 index 0000000000..c7b6216ee8 --- /dev/null +++ b/files/zh-cn/mozilla/add-ons/webextensions/api/downloads/download/index.html @@ -0,0 +1,144 @@ +--- +title: downloads.download() +slug: Mozilla/Add-ons/WebExtensions/API/downloads/download +tags: + - API + - Add-ons + - Extensions + - Method + - WebExtensions + - download + - downloads +translation_of: Mozilla/Add-ons/WebExtensions/API/downloads/download +--- +<div>{{AddonSidebar()}}</div> + +<p>{{WebExtAPIRef("downloads")}} API 的 <strong><code>download()</code></strong> 函数根据给出的URL和其他首选项下载一个文件。</p> + +<ul> + <li>如果指定的 <code>url</code> 使用HTTP或者HTTPS协议, 那么下载请求将会包含当前为该域名所设置的所有cookie。</li> + <li>如果<code>filename</code> 和 <code>saveAs</code> 都已经指定,那么将会弹出“保存为” 对话框,并且默认名称显示为<code>filename</code>.</li> +</ul> + +<p>这是一个异步函数,其返回值为 <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>.</p> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox brush:js">var downloading = browser.downloads.download( + options // object +) +</pre> + +<h3 id="参数">参数</h3> + +<dl> + <dt><code>options</code></dt> + <dd>一个 <code>object</code> ,用来指定你想要下载的文件和其他想要在下载时设置的首选项。可以包含以下属性:</dd> + <dd> + <dl class="reference-values"> + <dt><code>allowHttpErrors</code>{{optional_inline}}</dt> + <dd>一个 <code>boolean</code>,启用后即使遇到HTTP错误仍然继续下载。 例如,可以使用该标志下载服务错误页面。默认值为<code>false</code>. 当设置为以下值时: + <ul> + <li><code>false</code>,遇到HTTP错误时下载会被取消。</li> + <li><code>true</code>, 即使遇到HTTP错误也会继续下载,并且不会弹出HTTP服务错误报告。但是,如果下载失败的原因是文件相关,网络相关,用户相关,或者说其他错误,仍然会报错。<span style="display: none;"> </span></li> + </ul> + </dd> + <dt><code>body</code>{{optional_inline}}</dt> + <dd>一个 <code>string</code>,代表请求的内容。</dd> + <dt><code>conflictAction</code>{{optional_inline}}</dt> + <dd>一个字符串,表示如果存在命名冲突时你希望进行的操作,字符串内容所代表的类型由 {{WebExtAPIRef('downloads.FilenameConflictAction')}} 定义(未指定时默认为 "uniquify" )。</dd> + <dt><code>filename</code>{{optional_inline}}</dt> + <dd>一个 <code>string</code> ,表示相对默认保存位置的文件路径——这里提供你希望文件保存的位置,和你想要使用的文件名。绝对路径,空路径,以及包含反向引用的路径 (<code>../</code>) 会导致错误产生。 如果省略,该值将默认为已经提供给下载文件的文件名,并且直接保存到下载文件夹中。</dd> + <dt><code>headers</code>{{optional_inline}}</dt> + <dd>如果URL使用HTTP或者HTTPS协议, 保存在 <code>array</code> 中的一系列 <code>objects</code> 表示与请求一起发送的额外HTTP请求头。每一个请求头表示为字典对象,包含有关键字 <code>name</code> 还有 <code>value</code>或<code>binaryValue</code>中的一个。 无法指定 <code>XMLHttpRequest</code>和 <code>fetch</code>禁止的请求头,但是 Firefox 70 之后允许使用<code>Referer</code>请求头。尝试使用被禁止的请求头会产生一个错误。</dd> + <dt><code>incognito</code>{{optional_inline}}</dt> + <dd>一个 <code>boolean</code>:如果被设置为 true,那么这次下载会建立一个隐私浏览会话。 这意味着它只会出现在当前打开的任意隐私窗口的下载管理器。</dd> + <dt><code>method</code>{{optional_inline}}</dt> + <dd>一个 <code>string</code>,表示<code>url</code>使用HTTP[S] 协议时使用的HTTP方法。其值可能是 "GET" 或 "POST"。</dd> + <dt><code>saveAs</code>{{optional_inline}}</dt> + <dd> + <p>一个<code>boolean</code> 指定是(<code>true</code>)否(<code>false</code>)提供一个文件选择对话框允许用户选择文件名。.</p> + + <p>如果该选项省略, 浏览器会根据用户对于该行为的偏好设置决定是否提供一个文件选择对话框 (在火狐这项设置标签在about:preferences里为"每次都问您要存到哪" ,或者about:config里 <code>browser.download.useDownloadDir</code> )。</p> + + <div class="note"> + <p><strong>Note</strong>: 如果 <code>saveAs</code> 被设置为 <code>true</code>,Firefox for Android 将会引发一个错误。 当 <code>saveAs</code> 为 <code>false</code> 或空时这个参数会被忽略.</p> + </div> + </dd> + <dt><code>url</code></dt> + <dd>一个 <code>string</code>,表示需要下载的链接地址。</dd> + </dl> + </dd> +</dl> + +<h3 id="返回值">返回值</h3> + +<p>一个 <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>. 如果成功开始下载,promise会被新创建的{{WebExtAPIRef("downloads.DownloadItem")}} 的 <code>id</code> 填充。否则 promise 会被拒绝并产生一条{{WebExtAPIRef("downloads.InterruptReason")}}错误信息.</p> + +<p>如果你使用 <a href="/en-US/docs/Web/API/URL/createObjectURL">URL.createObjectURL()</a> 下载由 JavaScript 创建的数据并且之后想要(使用 <a href="/en-US/docs/Web/API/URL/revokeObjectURL">revokeObjectURL</a>)撤销对象链接(并且强烈推荐这么做),你必须在下载完成后再这么做。监听 <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/downloads/onChanged">downloads.onChanged</a> 事件来判断是否下载完成。</p> + +<h2 id="浏览器兼容性">浏览器兼容性</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.downloads.download")}}</p> + +<h2 id="例子">例子</h2> + +<p>下面这段代码尝试下载一个example文件,同时指定文件名和保存位置,还有 <code>uniquify</code> <code>conflictAction</code> 选项。</p> + +<pre class="brush: js">function onStartedDownload(id) { + console.log(`Started downloading: ${id}`); +} + +function onFailed(error) { + console.log(`Download failed: ${error}`); +} + +var downloadUrl = "https://example.org/image.png"; + +var downloading = browser.downloads.download({ + url : downloadUrl, + filename : 'my-image-again.png', + conflictAction : 'uniquify' +}); + +downloading.then(onStartedDownload, onFailed);</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Acknowledgements</strong> + +<p>这个 API 基于 Chromium的 <a href="https://developer.chrome.com/extensions/downloads#method-download"><code>chrome.downloads</code></a> API.</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/zh-cn/mozilla/add-ons/webextensions/api/downloads/downloaditem/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/downloads/downloaditem/index.html new file mode 100644 index 0000000000..ce523d15af --- /dev/null +++ b/files/zh-cn/mozilla/add-ons/webextensions/api/downloads/downloaditem/index.html @@ -0,0 +1,101 @@ +--- +title: downloads.DownloadItem +slug: Mozilla/Add-ons/WebExtensions/API/downloads/DownloadItem +translation_of: Mozilla/Add-ons/WebExtensions/API/downloads/DownloadItem +--- +<div>{{AddonSidebar()}}</div> + +<p>{{WebExtAPIRef("downloads")}} API 的 <code>DownloadItem</code> 类代表了一个被下载的文件。</p> + +<h2 id="Type">Type</h2> + +<p>这个类型的值是对象,包含了以下属性:</p> + +<dl class="reference-values"> + <dt><code>byExtensionId</code>{{optional_inline}}</dt> + <dd>一个代表了触发此下载的扩展的 ID 的 <code>string</code> (如果是被扩展触发的话)。一旦设置,不会改变。如果下载不是由扩展触发的,则为 undefined。</dd> + <dt><code>byExtensionName</code>{{optional_inline}}</dt> + <dd>一个代表了触发此下载的扩展的名字的 <code>string</code> (如果是被扩展触发的话)。如果用户改变了扩展的语言环境,则这个属性的值也可能变化。如果下载不是由扩展触发的,则为 undefined。</dd> + <dt><code>bytesReceived</code></dt> + <dd>一个代表了在下载过程中从主机接收到的字节数的 <code>number</code> ;不考虑文件压缩。</dd> + <dt><code>canResume</code></dt> + <dd>一个标识当前中断(例如暂停)的下载是否可以从当前位置恢复的 <code>boolean</code>。</dd> + <dt><code>danger</code></dt> + <dd>一个标识这个下载是否通过一个不安全的或已知的可疑的站点。可能被设置为 {{WebExtAPIRef('downloads.DangerType')}} 类型。</dd> + <dt><code>endTime</code>{{optional_inline}}</dt> + <dd>A <code>string</code> (in <a href="https://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> format) representing the number of milliseconds between the UNIX epoch and when this download ended. This is undefined if the download has not yet finished.</dd> + <dt><code>error</code>{{optional_inline}}</dt> + <dd>A string indicating why a download was interrupted. Possible values are defined in the {{WebExtAPIRef('downloads.InterruptReason')}} type. This is undefined if an error has not occurred.</dd> + <dt><code>estimatedEndTime</code>{{optional_inline}}</dt> + <dd>A <code>string</code> (in <a href="https://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> format) representing the estimated number of milliseconds between the UNIX epoch and when this download is estimated to be completed. This is undefined if it is not known (in particular, it is undefined in the <code>DownloadItem</code> that's passed into {{WebExtAPIRef("downloads.onCreated")}}).</dd> + <dt><code>exists</code></dt> + <dd>A <code>boolean</code> indicating whether a downloaded file still exists (<code>true</code>) or not (<code>false</code>). This information might be out-of-date, as browsers do not automatically watch for file removal — to check whether a file exists, call the {{WebExtAPIRef('downloads.search()')}} method, filtering for the file in question.</dd> + <dt><code>filename</code></dt> + <dd>A <code>string</code> representing the file's absolute local path.</dd> + <dt><code>fileSize</code></dt> + <dd>A <code>number</code> indicating the total number of bytes in the whole file, after decompression. A value of -1 here means that the total file size is unknown.</dd> + <dt><code>id</code></dt> + <dd>An <code>integer</code> representing a unique identifier for the downloaded file that is persistent across browser sessions.</dd> + <dt><code>incognito</code></dt> + <dd>A <code>boolean</code> that indicates whether the download is recorded in the browser's history (<code>false</code>), or not (<code>true</code>).</dd> + <dt><code>mime</code></dt> + <dd>A <code>string</code> representing the downloaded file's MIME type.</dd> + <dt><code>paused</code></dt> + <dd>A <code>boolean</code> indicating whether the download is paused, i.e. if the download has stopped reading data from the host but has kept the connection open. If so, the value is <code>true</code>, <code>false</code> if not.</dd> + <dt><code>referrer</code></dt> + <dd>A <code>string</code> representing the downloaded file's referrer.</dd> + <dt><code>startTime</code></dt> + <dd>A <code>string</code> (in <a href="https://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> format) representing the number of milliseconds between the UNIX epoch and when this download began.</dd> + <dt><code>state</code></dt> + <dd>A <code>string</code> Indicating whether the download is progressing, interrupted, or complete. Possible values are defined in the {{WebExtAPIRef('downloads.State')}} type.</dd> + <dt><code>totalBytes</code></dt> + <dd>A <code>number</code> indicating the total number of bytes in the file being downloaded. This does not take file compression into consideration. A value of -1 here means that the total number of bytes is unknown.</dd> + <dt><code>url</code></dt> + <dd>A <code>string</code> representing the absolute URL from which the file was downloaded.</dd> +</dl> + +<h2 id="Browser_compatibility">Browser compatibility</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.downloads.DownloadItem")}}</p> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>Acknowledgements</strong> + +<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/downloads#type-DownloadItem"><code>chrome.downloads</code></a> API.</p> + +<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</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/zh-cn/mozilla/add-ons/webextensions/api/downloads/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/downloads/index.html new file mode 100644 index 0000000000..a2074471b7 --- /dev/null +++ b/files/zh-cn/mozilla/add-ons/webextensions/api/downloads/index.html @@ -0,0 +1,134 @@ +--- +title: downloads +slug: Mozilla/Add-ons/WebExtensions/API/downloads +tags: + - API + - Add-ons + - Extensions + - Interface + - NeedsTranslation + - Non-standard + - Reference + - TopicStub + - WebExtensions + - downloads +translation_of: Mozilla/Add-ons/WebExtensions/API/downloads +--- +<div>{{AddonSidebar}}</div> + +<div>启用与浏览器的下载管理器交互的扩展。你可以使用这个 API 模块来下载文件、取消、暂停、恢复下载和在文件管理器中显示下载的文件。</div> + +<p>为使用此 API,你需要在你的 <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json">manifest.json</a> 文件中声明 "downloads" <a href="/en-US/Add-ons/WebExtensions/manifest.json/permissions#API_permissions">API 权限</a>。</p> + +<h2 id="Types">Types</h2> + +<dl> + <dt>{{WebExtAPIRef("downloads.FilenameConflictAction")}}</dt> + <dd>定义当一个下载的文件与现存的文件命名冲突时要做什么。</dd> + <dt>{{WebExtAPIRef("downloads.InterruptReason")}}</dt> + <dd>定义一系列中断下载的可能理由。</dd> + <dt>{{WebExtAPIRef("downloads.DangerType")}}</dt> + <dd><span class="tlid-translation translation" lang="zh-CN"><span title="">定义一组与可下载文件相关的潜在危险的常见警告。</span></span></dd> + <dt>{{WebExtAPIRef("downloads.State")}}</dt> + <dd><span class="tlid-translation translation" lang="zh-CN"><span title="">定义当前下载可能处于的不同状态。</span></span></dd> + <dt>{{WebExtAPIRef("downloads.DownloadItem")}}</dt> + <dd>代表下载的文件。</dd> + <dt>{{WebExtAPIRef("downloads.StringDelta")}}</dt> + <dd><span class="tlid-translation translation" lang="zh-CN"><span title="">表示两个字符串之间的差异。</span></span></dd> + <dt>{{WebExtAPIRef("downloads.DoubleDelta")}}</dt> + <dd>代表两个双精度浮点数之间的差异。</dd> + <dt>{{WebExtAPIRef("downloads.BooleanDelta")}}</dt> + <dd>代表两个布尔数之间的差异。</dd> + <dt>{{WebExtAPIRef("downloads.DownloadTime")}}</dt> + <dd>代表一个下载将会花费的时间。</dd> + <dt>{{WebExtAPIRef("downloads.DownloadQuery")}}</dt> + <dd><span class="tlid-translation translation" lang="zh-CN"><span title="">定义一组参数,可用于在下载管理器中搜索一组特定的下载。</span></span></dd> +</dl> + +<h2 id="Functions">Functions</h2> + +<dl> + <dt>{{WebExtAPIRef("downloads.download()")}}</dt> + <dd>下载一个文件,给出它的 URL 和其他可选的参数。</dd> + <dt>{{WebExtAPIRef("downloads.search()")}}</dt> + <dd>查询 {{WebExtAPIRef("downloads.DownloadItem", "DownloadItems")}} 是否在浏览器的下载管理器中可用,返回匹配指定的搜索标准的条目。</dd> + <dt>{{WebExtAPIRef("downloads.pause()")}}</dt> + <dd>暂停一个下载。</dd> + <dt>{{WebExtAPIRef("downloads.resume()")}}</dt> + <dd>恢复一个暂停的下载。</dd> + <dt>{{WebExtAPIRef("downloads.cancel()")}}</dt> + <dd>取消一个下载。</dd> + <dt>{{WebExtAPIRef("downloads.getFileIcon()")}}</dt> + <dd><span class="tlid-translation translation" lang="zh-CN"><span title="">检索指定下载的图标。</span></span></dd> + <dt>{{WebExtAPIRef("downloads.open()")}}</dt> + <dd>用下载的文件相关联的程序打开它。</dd> + <dt>{{WebExtAPIRef("downloads.show()")}}</dt> + <dd>打开当前平台的文件管理应用来在它包含的文件夹中显示下载的文件。</dd> + <dt>{{WebExtAPIRef("downloads.showDefaultFolder()")}}</dt> + <dd>用当前平台的文件管理应用显示默认下载文件夹。</dd> + <dt>{{WebExtAPIRef("downloads.erase()")}}</dt> + <dd>擦除浏览器的下载历史中匹配 {{WebExtAPIRef("downloads.DownloadItem", "DownloadItems")}} 的下载记录,不会在磁盘中删除文件。</dd> + <dt>{{WebExtAPIRef("downloads.removeFile()")}}</dt> + <dd>从磁盘中移除下载的文件,但不从浏览器的下载历史中去除。</dd> + <dt>{{WebExtAPIRef("downloads.acceptDanger()")}}</dt> + <dd><span class="tlid-translation translation" lang="zh-CN"><span title="">提示用户接受或取消危险的下载。</span></span></dd> + <dt>{{WebExtAPIRef("downloads.drag()")}}</dt> + <dd> <span class="tlid-translation translation" lang="zh-CN"><span title="">将下载的文件拖动到另一个应用程序。</span></span></dd> + <dt>{{WebExtAPIRef("downloads.setShelfEnabled()")}}</dt> + <dd><span class="tlid-translation translation" lang="zh-CN"><span title="">启用或禁用与当前浏览器配置文件关联的每个窗口底部的灰色架子。</span> <span title="">只要至少一个扩展名已禁用该架子,它就会被禁用。</span></span></dd> +</dl> + +<h2 id="Events">Events</h2> + +<dl> + <dt>{{WebExtAPIRef("downloads.onCreated")}}</dt> + <dd>当一个下载开始时被 {{WebExtAPIRef("downloads.DownloadItem", "DownloadItem")}} 对象触发。</dd> + <dt>{{WebExtAPIRef("downloads.onErased")}}</dt> + <dd>当一个下载从历史中擦除时被 Fires with the <code>downloadId</code> 触发。</dd> + <dt>{{WebExtAPIRef("downloads.onChanged")}}</dt> + <dd>当任意一个 {{WebExtAPIRef("downloads.DownloadItem", "DownloadItem")}} 的属性期望 <code>bytesReceived</code> 改变时,此事件被这个 `downloadId` 和包含了变化属性的对象触发。</dd> +</dl> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + +<p>{{Compat("webextensions.api.downloads")}}</p> + +<p>{{WebExtExamples("h2")}}</p> + +<div class="note"><strong>Acknowledgements</strong> + +<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/downloads"><code>chrome.downloads</code></a> API.</p> + +<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</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> |
