Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Use the <code>chrome.downloads</code> API to programmatically initiate, | 5 // Use the <code>chrome.downloads</code> API to programmatically initiate, |
| 6 // monitor, manipulate, and search for downloads. | 6 // monitor, manipulate, and search for downloads. |
| 7 [permissions=downloads] | 7 [permissions=downloads] |
| 8 namespace downloads { | 8 namespace downloads { |
| 9 [inline_doc] dictionary HeaderNameValuePair { | 9 [inline_doc] dictionary HeaderNameValuePair { |
| 10 // Name of the HTTP header. | 10 // Name of the HTTP header. |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 // <dt>complete</dt> | 127 // <dt>complete</dt> |
| 128 // <dd>The download completed successfully.</dd> | 128 // <dd>The download completed successfully.</dd> |
| 129 // </dl> | 129 // </dl> |
| 130 enum State {in_progress, interrupted, complete}; | 130 enum State {in_progress, interrupted, complete}; |
| 131 | 131 |
| 132 // The state of the process of downloading a file. | 132 // The state of the process of downloading a file. |
| 133 dictionary DownloadItem { | 133 dictionary DownloadItem { |
| 134 // An identifier that is persistent across browser sessions. | 134 // An identifier that is persistent across browser sessions. |
| 135 long id; | 135 long id; |
| 136 | 136 |
| 137 // Absolute URL. | 137 // The absolute URL that this download initiated from, before any |
| 138 // redirects. | |
| 138 DOMString url; | 139 DOMString url; |
| 139 | 140 |
| 141 // The absolute URL that this download is being made from, after all | |
| 142 // redirects. | |
| 143 DOMString finalUrl; | |
| 144 | |
| 140 // Absolute URL. | 145 // Absolute URL. |
| 141 DOMString referrer; | 146 DOMString referrer; |
| 142 | 147 |
| 143 // Absolute local path. | 148 // Absolute local path. |
| 144 DOMString filename; | 149 DOMString filename; |
| 145 | 150 |
| 146 // False if this download is recorded in the history, true if it is not | 151 // False if this download is recorded in the history, true if it is not |
| 147 // recorded. | 152 // recorded. |
| 148 boolean incognito; | 153 boolean incognito; |
| 149 | 154 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 DOMString? byExtensionId; | 224 DOMString? byExtensionId; |
| 220 | 225 |
| 221 // The localized name of the extension that initiated this download if this | 226 // The localized name of the extension that initiated this download if this |
| 222 // download was initiated by an extension. May change if the extension | 227 // download was initiated by an extension. May change if the extension |
| 223 // changes its name or if the user changes their locale. | 228 // changes its name or if the user changes their locale. |
| 224 DOMString? byExtensionName; | 229 DOMString? byExtensionName; |
| 225 }; | 230 }; |
| 226 | 231 |
| 227 [inline_doc] dictionary DownloadQuery { | 232 [inline_doc] dictionary DownloadQuery { |
| 228 // This array of search terms limits results to $(ref:DownloadItem) whose | 233 // This array of search terms limits results to $(ref:DownloadItem) whose |
| 229 // <code>filename</code> or <code>url</code> contain all of the search terms | 234 // <code>filename</code> or <code>url</code> or <code>finalUrl</code> |
| 230 // that do not begin with a dash '-' and none of the search terms that do | 235 // contain all of the search terms that do not begin with a dash '-' and |
| 231 // begin with a dash. | 236 // none of the search terms that do begin with a dash. |
| 232 DOMString[]? query; | 237 DOMString[]? query; |
| 233 | 238 |
| 234 // Limits results to $(ref:DownloadItem) that | 239 // Limits results to $(ref:DownloadItem) that |
| 235 // started before the given ms since the epoch. | 240 // started before the given ms since the epoch. |
| 236 DOMString? startedBefore; | 241 DOMString? startedBefore; |
| 237 | 242 |
| 238 // Limits results to $(ref:DownloadItem) that | 243 // Limits results to $(ref:DownloadItem) that |
| 239 // started after the given ms since the epoch. | 244 // started after the given ms since the epoch. |
| 240 DOMString? startedAfter; | 245 DOMString? startedAfter; |
| 241 | 246 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 256 double? totalBytesLess; | 261 double? totalBytesLess; |
| 257 | 262 |
| 258 // Limits results to $(ref:DownloadItem) whose | 263 // Limits results to $(ref:DownloadItem) whose |
| 259 // <code>filename</code> matches the given regular expression. | 264 // <code>filename</code> matches the given regular expression. |
| 260 DOMString? filenameRegex; | 265 DOMString? filenameRegex; |
| 261 | 266 |
| 262 // Limits results to $(ref:DownloadItem) whose | 267 // Limits results to $(ref:DownloadItem) whose |
| 263 // <code>url</code> matches the given regular expression. | 268 // <code>url</code> matches the given regular expression. |
| 264 DOMString? urlRegex; | 269 DOMString? urlRegex; |
| 265 | 270 |
| 271 // Limits results to $(ref:DownloadItem) whose | |
| 272 // <code>finalUrl</code> matches the given regular expression. | |
| 273 DOMString? finalUrlRegex; | |
| 274 | |
| 266 // The maximum number of matching $(ref:DownloadItem) returned. Defaults to | 275 // The maximum number of matching $(ref:DownloadItem) returned. Defaults to |
| 267 // 1000. Set to 0 in order to return all matching $(ref:DownloadItem). See | 276 // 1000. Set to 0 in order to return all matching $(ref:DownloadItem). See |
| 268 // $(ref:search) for how to page through results. | 277 // $(ref:search) for how to page through results. |
| 269 long? limit; | 278 long? limit; |
| 270 | 279 |
| 271 // Set elements of this array to $(ref:DownloadItem) properties in order to | 280 // Set elements of this array to $(ref:DownloadItem) properties in order to |
| 272 // sort search results. For example, setting | 281 // sort search results. For example, setting |
| 273 // <code>orderBy=['startTime']</code> sorts the $(ref:DownloadItem) by their | 282 // <code>orderBy=['startTime']</code> sorts the $(ref:DownloadItem) by their |
| 274 // start time in ascending order. To specify descending order, prefix with a | 283 // start time in ascending order. To specify descending order, prefix with a |
| 275 // hyphen: '-startTime'. | 284 // hyphen: '-startTime'. |
| 276 DOMString[]? orderBy; | 285 DOMString[]? orderBy; |
| 277 | 286 |
| 278 // The <code>id</code> of the $(ref:DownloadItem) to query. | 287 // The <code>id</code> of the $(ref:DownloadItem) to query. |
| 279 long? id; | 288 long? id; |
| 280 | 289 |
| 281 // Absolute URL. | 290 // The absolute URL that this download initiated from, before any |
| 291 // redirects. | |
| 282 DOMString? url; | 292 DOMString? url; |
| 283 | 293 |
| 294 // The absolute URL that this download is being made from, after all | |
| 295 // redirects. | |
| 296 DOMString? finalUrl; | |
| 297 | |
| 284 // Absolute local path. | 298 // Absolute local path. |
| 285 DOMString? filename; | 299 DOMString? filename; |
| 286 | 300 |
| 287 // Indication of whether this download is thought to be safe or known to be | 301 // Indication of whether this download is thought to be safe or known to be |
| 288 // suspicious. | 302 // suspicious. |
| 289 DangerType? danger; | 303 DangerType? danger; |
| 290 | 304 |
| 291 // The file's MIME type. | 305 // The file's MIME type. |
| 292 DOMString? mime; | 306 DOMString? mime; |
| 293 | 307 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 boolean? previous; | 350 boolean? previous; |
| 337 boolean? current; | 351 boolean? current; |
| 338 }; | 352 }; |
| 339 | 353 |
| 340 // Encapsulates a change in a DownloadItem. | 354 // Encapsulates a change in a DownloadItem. |
| 341 [inline_doc] dictionary DownloadDelta { | 355 [inline_doc] dictionary DownloadDelta { |
| 342 // The <code>id</code> of the $(ref:DownloadItem) | 356 // The <code>id</code> of the $(ref:DownloadItem) |
| 343 // that changed. | 357 // that changed. |
| 344 long id; | 358 long id; |
| 345 | 359 |
| 346 // The change in <code>url</code>, if any. | 360 // The <code>url</code> of download, only if previously unknown. |
| 347 StringDelta? url; | 361 StringDelta? url; |
| 348 | 362 |
| 363 // The <code>finalUrl</code> of download, only if previously unknown. | |
| 364 StringDelta? finalUrl; | |
| 365 | |
| 349 // The change in <code>filename</code>, if any. | 366 // The change in <code>filename</code>, if any. |
| 350 StringDelta? filename; | 367 StringDelta? filename; |
| 351 | 368 |
| 352 // The change in <code>danger</code>, if any. | 369 // The change in <code>danger</code>, if any. |
| 353 StringDelta? danger; | 370 StringDelta? danger; |
| 354 | 371 |
| 355 // The change in <code>mime</code>, if any. | 372 // The <code>mime</code> of download, only if previously unknown. |
| 356 StringDelta? mime; | 373 StringDelta? mime; |
| 357 | 374 |
| 358 // The change in <code>startTime</code>, if any. | 375 // The <code>startTime</code> of download, only if previously unknown. |
| 359 StringDelta? startTime; | 376 StringDelta? startTime; |
| 360 | 377 |
| 361 // The change in <code>endTime</code>, if any. | 378 // The change in <code>endTime</code>, if any. |
| 362 StringDelta? endTime; | 379 StringDelta? endTime; |
| 363 | 380 |
| 364 // The change in <code>state</code>, if any. | 381 // The change in <code>state</code>, if any. |
| 365 StringDelta? state; | 382 StringDelta? state; |
| 366 | 383 |
| 367 // The change in <code>canResume</code>, if any. | 384 // The change in <code>canResume</code>, if any. |
| 368 BooleanDelta? canResume; | 385 BooleanDelta? canResume; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 516 | 533 |
| 517 // Fires with the <code>downloadId</code> when a download is erased from | 534 // Fires with the <code>downloadId</code> when a download is erased from |
| 518 // history. | 535 // history. |
| 519 // |downloadId|: The <code>id</code> of the $(ref:DownloadItem) that was | 536 // |downloadId|: The <code>id</code> of the $(ref:DownloadItem) that was |
| 520 // erased. | 537 // erased. |
| 521 static void onErased(long downloadId); | 538 static void onErased(long downloadId); |
| 522 | 539 |
| 523 // When any of a $(ref:DownloadItem)'s properties except | 540 // When any of a $(ref:DownloadItem)'s properties except |
| 524 // <code>bytesReceived</code> and <code>estimatedEndTime</code> changes, | 541 // <code>bytesReceived</code> and <code>estimatedEndTime</code> changes, |
| 525 // this event fires with the <code>downloadId</code> and an object | 542 // this event fires with the <code>downloadId</code> and an object |
| 526 // containing the properties that changed. | 543 // containing the properties that changed. This event can contain all |
| 544 // previously unreported download item data, it will be fired in two cases: | |
| 545 // for downloads that already existed before event listener was added or | |
| 546 // for dangerous download that was accepted and is not temporary anymore. | |
| 547 // Those are the only cases where fields <code>url</code>, | |
| 548 // <code>finalUrl</code>, <code>mime</code> and <code>startTime</code> can | |
| 549 // appear in download delta, those properties cannot change after download | |
| 550 // item creation. Download delta fields in such cases will contain only | |
| 551 // current value. | |
|
asanka
2016/07/07 19:28:31
Let's not document this behavior; it's a bug and s
mharanczyk
2016/07/08 10:10:54
Reverted download delta documentation back to orig
| |
| 527 static void onChanged(DownloadDelta downloadDelta); | 552 static void onChanged(DownloadDelta downloadDelta); |
| 528 | 553 |
| 529 // During the filename determination process, extensions will be given the | 554 // During the filename determination process, extensions will be given the |
| 530 // opportunity to override the target $(ref:DownloadItem.filename). Each | 555 // opportunity to override the target $(ref:DownloadItem.filename). Each |
| 531 // extension may not register more than one listener for this event. Each | 556 // extension may not register more than one listener for this event. Each |
| 532 // listener must call <code>suggest</code> exactly once, either | 557 // listener must call <code>suggest</code> exactly once, either |
| 533 // synchronously or asynchronously. If the listener calls | 558 // synchronously or asynchronously. If the listener calls |
| 534 // <code>suggest</code> asynchronously, then it must return | 559 // <code>suggest</code> asynchronously, then it must return |
| 535 // <code>true</code>. If the listener neither calls <code>suggest</code> | 560 // <code>true</code>. If the listener neither calls <code>suggest</code> |
| 536 // synchronously nor returns <code>true</code>, then <code>suggest</code> | 561 // synchronously nor returns <code>true</code>, then <code>suggest</code> |
| 537 // will be called automatically. The $(ref:DownloadItem) will not complete | 562 // will be called automatically. The $(ref:DownloadItem) will not complete |
| 538 // until all listeners have called <code>suggest</code>. Listeners may call | 563 // until all listeners have called <code>suggest</code>. Listeners may call |
| 539 // <code>suggest</code> without any arguments in order to allow the download | 564 // <code>suggest</code> without any arguments in order to allow the download |
| 540 // to use <code>downloadItem.filename</code> for its filename, or pass a | 565 // to use <code>downloadItem.filename</code> for its filename, or pass a |
| 541 // <code>suggestion</code> object to <code>suggest</code> in order to | 566 // <code>suggestion</code> object to <code>suggest</code> in order to |
| 542 // override the target filename. If more than one extension overrides the | 567 // override the target filename. If more than one extension overrides the |
| 543 // filename, then the last extension installed whose listener passes a | 568 // filename, then the last extension installed whose listener passes a |
| 544 // <code>suggestion</code> object to <code>suggest</code> wins. In order to | 569 // <code>suggestion</code> object to <code>suggest</code> wins. In order to |
| 545 // avoid confusion regarding which extension will win, users should not | 570 // avoid confusion regarding which extension will win, users should not |
| 546 // install extensions that may conflict. If the download is initiated by | 571 // install extensions that may conflict. If the download is initiated by |
| 547 // $(ref:download) and the target filename is known before the MIME type and | 572 // $(ref:download) and the target filename is known before the MIME type and |
| 548 // tentative filename have been determined, pass <code>filename</code> to | 573 // tentative filename have been determined, pass <code>filename</code> to |
| 549 // $(ref:download) instead. | 574 // $(ref:download) instead. |
| 550 [maxListeners=1] static void onDeterminingFilename( | 575 [maxListeners=1] static void onDeterminingFilename( |
| 551 DownloadItem downloadItem, SuggestFilenameCallback suggest); | 576 DownloadItem downloadItem, SuggestFilenameCallback suggest); |
| 552 }; | 577 }; |
| 553 }; | 578 }; |
| OLD | NEW |