Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1519)

Side by Side Diff: chrome/browser/resources/active_downloads.html

Issue 6948013: Fix dangerous downloads. Ellipsis for long filenames. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/webui/active_downloads_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE HTML> 1 <!DOCTYPE HTML>
2 <html i18n-values="dir:textdirection;"> 2 <html i18n-values="dir:textdirection;">
3 <head> 3 <head>
4 <meta charset="utf-8"> 4 <meta charset="utf-8">
5 <title i18n-content="title"></title> 5 <title i18n-content="title"></title>
6 <link rel="icon" href="../../app/theme/downloads_favicon.png"> 6 <link rel="icon" href="../../app/theme/downloads_favicon.png">
7 <style type="text/css"> 7 <style type="text/css">
8 div.header { 8 div.header {
9 border-bottom: 1px solid #7289E2; 9 border-bottom: 1px solid #7289E2;
10 padding: 8px; 10 padding: 8px;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 .rowbg:active { 77 .rowbg:active {
78 background: -webkit-gradient(linear, left top, left bottom, 78 background: -webkit-gradient(linear, left top, left bottom,
79 from(#d2e0f0), to(#dee6f0), color-stop(0.1, #e3e9f0)); 79 from(#d2e0f0), to(#dee6f0), color-stop(0.1, #e3e9f0));
80 } 80 }
81 81
82 .downloadrow { 82 .downloadrow {
83 height: 36px; 83 height: 36px;
84 } 84 }
85 85
86 .rowbutton { 86 .rowbutton {
87 padding: 8px 5px 5px 34px; 87 padding: 5px 5px 0 34px;
88 position: relative; 88 position: relative;
89 right: 24px; 89 right: 24px;
90 border-right: 1px solid #CCC; 90 border-right: 1px solid #CCC;
91 height: 22px; 91 height: 30px;
92 cursor: pointer;
93 } 92 }
94 93
95 .rowbutton div.icon { 94 .rowbutton div.icon {
96 float: left; 95 float: left;
97 margin-left: 0;
98 margin-top: 1px; 96 margin-top: 1px;
99 display: inline 97 display: inline
100 position: relative; 98 position: relative;
101 width: 21px; 99 width: 21px;
102 height: 17px; 100 height: 17px;
103 background-repeat: no-repeat; 101 background-repeat: no-repeat;
104 } 102 }
105 103
106 .rowbutton span.title { 104 .rowbutton span.title {
107 position: relative; 105 position: relative;
106 text-overflow: ellipsis;
107 white-space: nowrap;
108 display: inline-block;
109 overflow: hidden;
110 width: 189px;
108 color: #325282; 111 color: #325282;
109 } 112 }
110 113
111 .rowbutton span.downloading { 114 .rowbutton span.downloading {
112 top: -6px; 115 top: -6px;
113 font-size: .8em; 116 font-size: .8em;
114 position: relative;
115 color: #325282;
116 } 117 }
117 118
118 .rowbutton span.downloaded { 119 .rowbutton span.downloaded {
119 white-space: nowrap;
120 font-size: .8em; 120 font-size: .8em;
121 text-overflow: ellipsis;
122 } 121 }
123 122
124 .rowbutton span.error { 123 .rowbutton span.error {
125 font-size: .6em; 124 font-size: .6em;
126 top: -6px; 125 }
126
127 .allowdownload {
128 margin: -10px 5px 5px 30px;
129 display: block;
130 }
131
132 .allowdownloadtext {
133 font-size: .6em;
134 color: #325282;
135 }
136
137 .confirm {
138 font-size: .6em;
139 text-decoration: underline;
140 margin-left: 5px;
141 color: #254f9b;
142 cursor: pointer;
127 } 143 }
128 144
129 .progress { 145 .progress {
130 font-size: .6em; 146 font-size: .6em;
131 text-align: right; 147 text-align: right;
132 margin-left: auto; 148 margin-left: auto;
133 margin-top: -5px; 149 margin-top: -5px;
134 } 150 }
135 151
136 div.title {
137 text-align: right;
138 position: relative;
139 font-size: .8em;
140 font-weight: bold;
141 padding-top: 2px;
142 }
143
144 div.columnlist { 152 div.columnlist {
145 width: 100%; 153 width: 100%;
146 top: 0; 154 top: 0;
147 left: 0; 155 left: 0;
148 bottom: 29px; /* space for Show All Downloads */ 156 bottom: 29px; /* space for Show All Downloads */
149 position: absolute; 157 position: absolute;
150 background: #e8e8e8 158 background: #e8e8e8
151 } 159 }
152 160
153 span.showalldownloadstext { 161 span.showalldownloadstext {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 * Testing. Allow this page to be loaded in a browser. 257 * Testing. Allow this page to be loaded in a browser.
250 * Create stubs for localStrings and chrome.send. 258 * Create stubs for localStrings and chrome.send.
251 */ 259 */
252 var testHarnessEnabled = false; 260 var testHarnessEnabled = false;
253 function initTestHarness() { 261 function initTestHarness() {
254 if (testHarnessEnabled) { 262 if (testHarnessEnabled) {
255 localStrings = { 263 localStrings = {
256 getString: function(name) { 264 getString: function(name) {
257 if (name == 'showalldownloads') 265 if (name == 'showalldownloads')
258 return 'Show All Downloads'; 266 return 'Show All Downloads';
267 if (name == 'allowdownload')
268 return 'Allow Download?';
269 if (name == 'confirmyes')
270 return 'Yes';
271 if (name == 'confirmcancel')
272 return 'Cancel';
259 return name; 273 return name;
260 }, 274 },
261 getStringF: function(name, path) { 275 getStringF: function(name, path) {
262 return path + ' - Unknown file type.'; 276 return path + ' - Unknown file type.';
263 }, 277 },
264 }; 278 };
265 chrome.send = function(name, ary) { 279 chrome.send = function(name, ary) {
266 console.log('chrome.send ' + name + ' ' + ary); 280 console.log('chrome.send ' + name + ' ' + ary);
267 if (name == 'getDownloads' || 281 if (name == 'getDownloads' ||
268 (name == 'openNewFullWindow' && 282 (name == 'openNewFullWindow' &&
269 ary[0] == 'chrome://downloads')) 283 ary[0] == 'chrome://downloads'))
270 sendTestResults(); 284 sendTestResults();
271 } 285 }
272 } 286 }
273 } 287 }
274 288
275 /** 289 /**
276 * Create a results array with test data and call downloadsList. 290 * Create a results array with test data and call downloadsList.
277 */ 291 */
278 var id = 1; 292 var id = 1;
279 var results = []; 293 var results = [];
280 function sendTestResults() { 294 function sendTestResults() {
281 results.push({ 295 results.push({
282 state: (id % 2 ? 'IN_PROGRESS' : 'COMPLETE'), 296 state: (id % 2 ? 'DANGEROUS' : 'COMPLETE'),
283 percent: (id % 2 ? 90 : 100), 297 percent: (id % 2 ? 90 : 100),
284 id: id, 298 id: id,
285 file_name: 'Test' + id + '.pdf', 299 file_name: ' Test' + id + '.pdf',
286 file_path: '/home/achuith/Downloads/Test' + id + '.pdf', 300 file_path: '/home/achuith/Downloads/Test' + id + '.pdf',
287 progress_status_text : (id % 2 ? 301 progress_status_text : (id % 2 ?
288 'download progressing nicely' : 'download complete'), 302 'download progressing nicely' : 'download complete'),
289 }); 303 });
290 id++; 304 id++;
291 downloadsList(results); 305 downloadsList(results);
292 } 306 }
293 307
294 /** 308 /**
295 * Current Menu. 309 * Current Menu.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 * DownloadRow contains all the elements that go into a row of the downloads 368 * DownloadRow contains all the elements that go into a row of the downloads
355 * list. It represents a single DownloadItem. 369 * list. It represents a single DownloadItem.
356 * 370 *
357 * @param {DownloadRowList} list Global DownloadRowList. 371 * @param {DownloadRowList} list Global DownloadRowList.
358 * @param {Object} result JSON representation of DownloadItem. 372 * @param {Object} result JSON representation of DownloadItem.
359 * @constructor 373 * @constructor
360 */ 374 */
361 function DownloadRow(list, result) { 375 function DownloadRow(list, result) {
362 this.path = result.file_path; 376 this.path = result.file_path;
363 this.name = result.file_name; 377 this.name = result.file_name;
378 this.list = list;
364 this.id = result.id; 379 this.id = result.id;
365 this.list = list;
366 380
367 this.createRow_(list); 381 this.createRow_(list);
368 this.createRowButton_(); 382 this.createRowButton_();
369 this.createMenu_(); 383 this.createMenu_();
370 this.downloading_ = false;
371 } 384 }
372 385
373 DownloadRow.prototype = { 386 DownloadRow.prototype = {
374 /** 387 /**
375 * Create the row html element and book-keeping for the row. 388 * Create the row html element and book-keeping for the row.
376 * @param {DownloadRowList} list global DownloadRowList instance. 389 * @param {DownloadRowList} list global DownloadRowList instance.
377 * @private 390 * @private
378 */ 391 */
379 createRow_: function(list) { 392 createRow_: function(list) {
380 var row = document.createElement('li'); 393 var row = document.createElement('li');
(...skipping 11 matching lines...) Expand all
392 return 'icon iconphoto'; 405 return 'icon iconphoto';
393 } else if (pathIsVideoFile(this.path)) { 406 } else if (pathIsVideoFile(this.path)) {
394 return 'icon iconmedia'; 407 return 'icon iconmedia';
395 } else if (pathIsAudioFile(this.path)) { 408 } else if (pathIsAudioFile(this.path)) {
396 return 'icon iconmusic'; 409 return 'icon iconmusic';
397 } 410 }
398 return 'icon iconfile'; 411 return 'icon iconfile';
399 }, 412 },
400 413
401 setErrorText_: function(text) { 414 setErrorText_: function(text) {
402 this.filename.textContent = ''; 415 this.filename.textContent = text;
403 this.error.textContent = text; 416 this.filename.className = 'error title';
404 }, 417 },
405 418
406 supportsPdf_: function() { 419 supportsPdf_: function() {
407 return 'application/pdf' in navigator.mimeTypes; 420 return 'application/pdf' in navigator.mimeTypes;
408 }, 421 },
409 422
410 openFilePath_: function() { 423 openFilePath_: function() {
411 chrome.send('openNewFullWindow', ['file://' + this.path]); 424 chrome.send('openNewFullWindow', ['file://' + this.path]);
412 }, 425 },
413 426
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 var elem = document.createElement(type); 478 var elem = document.createElement(type);
466 elem.className = className; 479 elem.className = className;
467 if (textContent !== undefined) 480 if (textContent !== undefined)
468 elem.textContent = textContent; 481 elem.textContent = textContent;
469 elem.onclick = onclick; 482 elem.onclick = onclick;
470 parent.appendChild(elem); 483 parent.appendChild(elem);
471 return elem; 484 return elem;
472 }, 485 },
473 486
474 /** 487 /**
475 * Create the draggable row button for the left of the row. 488 * Create the row button for the left of the row.
476 * This contains the icon, filename and error elements. 489 * This contains the icon, filename and error elements.
477 * @private 490 * @private
478 */ 491 */
479 createRowButton_: function () { 492 createRowButton_: function () {
480 this.rowbutton = this.createChild_('div', 'rowbutton rowbg', this.element); 493 this.rowbutton = this.createChild_('div', 'rowbutton rowbg', this.element);
481 494
482 // Make element draggable.
483 this.rowbutton.setAttribute('draggable', 'true');
484 var self = this;
485 this.rowbutton.addEventListener('dragstart', function(e) {
486 e.dataTransfer.effectAllowed = 'copy';
487 e.dataTransfer.setData('Text', self.path);
488 e.dataTransfer.setData('URL', 'file:///' + self.path);
489 }, false);
490
491 // Icon. 495 // Icon.
492 var icon = this.createChild_('div', this.getIconClass_(), this.rowbutton); 496 var icon = this.createChild_('div', this.getIconClass_(), this.rowbutton);
493 497
494 // Filename. 498 // Filename.
495 this.filename = this.createChild_('span', 'downloaded title', 499 this.filename = this.createChild_('span', 'downloaded title',
496 this.rowbutton, this.name); 500 this.rowbutton, this.name);
497
498 // Error message.
499 this.error = this.createChild_('span', 'error title', this.rowbutton);
500 }, 501 },
501 502
502 /** 503 /**
503 * Create the menu button on the right of the row. 504 * Create the menu button on the right of the row.
504 * This contains the menuicon. The menuicon contains the menu, which 505 * This contains the menuicon. The menuicon contains the menu, which
505 * contains items for Open, Pause/Resume and Cancel. 506 * contains items for Open, Pause/Resume and Cancel.
506 * @private 507 * @private
507 */ 508 */
508 createMenu_: function() { 509 createMenu_: function() {
509 var self = this; 510 var self = this;
510 var menubutton = this.createChild_('div', 'menubutton rowbg', 511 this.menubutton = this.createChild_('div', 'menubutton rowbg',
511 this.element, '', 512 this.element, '',
512 function() { 513 function() {
513 menu.clicked(self); 514 menu.clicked(self);
514 }); 515 });
515 516
516 var menuicon = this.createChild_('div', 'menuicon', menubutton); 517 this.menuicon = this.createChild_('div', 'menuicon', this.menubutton);
517 menuicon.align = 'right'; 518 this.menuicon.align = 'right';
518 this.menuicon = menuicon;
519 519
520 var menudiv = this.createChild_('div', 'menu', menuicon); 520 var menudiv = this.createChild_('div', 'menu', this.menuicon);
521 521
522 this.open = this.createChild_('div', 'menuitem', menudiv, 522 this.open = this.createChild_('div', 'menuitem', menudiv,
523 localStrings.getString('open'), this.getFunctionForItem_()); 523 localStrings.getString('open'), this.getFunctionForItem_());
524 524
525 this.pause = this.createChild_('div', 'menuitem', menudiv, 525 this.pause = this.createChild_('div', 'menuitem', menudiv,
526 localStrings.getString('pause'), function() { 526 localStrings.getString('pause'), function() {
527 self.pauseToggleDownload_(); 527 self.pauseToggleDownload_();
528 }); 528 });
529 529
530 this.cancel = this.createChild_('div', 'menuitem', menudiv, 530 this.cancel = this.createChild_('div', 'menuitem', menudiv,
531 localStrings.getString('cancel'), function() { 531 localStrings.getString('cancel'), function() {
532 self.cancelDownload_(); 532 self.cancelDownload_();
533 }); 533 });
534 534
535 this.pause.style.display = 'none'; 535 this.pause.style.display = 'none';
536 this.cancel.style.display = 'none'; 536 this.cancel.style.display = 'none';
537 }, 537 },
538 538
539 /** 539 allowDownload_: function() {
540 * Called when the item has finished downloading. Switch the menu 540 chrome.send('allowDownload', ['' + this.id]);
541 * and remove the progress bar.
542 * @private
543 */
544 finishedDownloading_: function() {
545 this.downloading_ = false;
546 this.filename.className = 'downloaded title';
547
548 // Menu has Pause/Cancel. Open hidden.
549 this.open.style.display = '';
550 this.pause.style.display = 'none';
551 this.cancel.style.display = 'none';
552
553 this.rowbutton.onclick = this.getFunctionForItem_();
554
555 if (this.progress) {
556 this.rowbutton.removeChild(this.progress);
557 this.progress = null;
558 }
559 },
560
561 /**
562 * Called when a new item has started downloading. Switch the menu
563 * and create the progress bar.
564 *
565 * @param {Object} result JSON representation of DownloadItem.
566 * @private
567 */
568 startedDownloading_: function(result) {
569 if (this.downloading_)
570 return;
571 this.downloading_ = true;
572 this.filename.className = 'downloading title';
573 this.filename.textContent = result.file_name;
574
575 this.progress = this.createChild_('div', 'progress', this.rowbutton);
576
577 // Menu has Open. Pause/Cancel hidden.
578 this.open.style.display = 'none';
579 this.pause.style.display = '';
580 this.cancel.style.display = '';
581 }, 541 },
582 542
583 cancelDownload_: function() { 543 cancelDownload_: function() {
584 this.element.removeAttribute('dangerous');
585 chrome.send('cancelDownload', ['' + this.id]); 544 chrome.send('cancelDownload', ['' + this.id]);
586 }, 545 },
587 546
588 pauseToggleDownload_: function() { 547 pauseToggleDownload_: function() {
589 this.pause.textContent = 548 this.pause.textContent =
590 (this.pause.textContent == localStrings.getString('pause')) ? 549 (this.pause.textContent == localStrings.getString('pause')) ?
591 localStrings.getString('resume') : 550 localStrings.getString('resume') :
592 localStrings.getString('pause'); 551 localStrings.getString('pause');
593 552
594 // Convert id to string before send. 553 // Convert id to string before send.
595 chrome.send('pauseToggleDownload', ['' + this.id]); 554 chrome.send('pauseToggleDownload', ['' + this.id]);
596 }, 555 },
597 556
598 updateProgress_: function(result) { 557 resetRow_: function() {
599 if (result.percent < 100 && result.state != 'DANGEROUS') 558 this.rowbutton.onclick = '';
600 this.progress.textContent = result.progress_status_text; 559 this.rowbutton.style.cursor = '';
560 this.rowbutton.setAttribute('draggable', 'false');
561 },
562
563 createAllowDownload_: function() {
564 if (this.allowdownload) {
zel 2011/05/07 04:49:21 nit: not need for {}
achuithb 2011/05/07 05:09:57 Done.
565 return;
566 }
567
568 this.allowdownload = this.createChild_('div', 'allowdownload',
569 this.rowbutton);
570
571 this.createChild_('span', 'allowdownloadtext', this.allowdownload,
572 localStrings.getString('allowdownload'));
573
574 var self = this;
575 this.createChild_('span', 'confirm', this.allowdownload,
576 localStrings.getString('confirmyes'),
577 function() {
578 self.allowDownload_();
579 });
580 this.createChild_('span', 'confirm', this.allowdownload,
581 localStrings.getString('confirmcancel'),
582 function() {
583 self.cancelDownload_();
584 });
585
586 this.resetRow_();
587 this.menubutton.onclick = '';
588 },
589
590 removeAllowDownload_: function() {
591 if (this.allowdownload) {
592 this.rowbutton.removeChild(this.allowdownload);
593 this.allowdownload = null;
594 var self = this;
595 this.menubutton.onclick = function() {
596 menu.clicked(self);
597 };
598 }
599 },
600
601 createProgress_: function() {
602 if (this.progress)
603 return;
604
605 this.progress = this.createChild_('div', 'progress', this.rowbutton);
606
607 // Menu has Pause/Cancel. Open hidden.
608 this.open.style.display = 'none';
609 this.pause.style.display = '';
610 this.cancel.style.display = '';
611 },
612
613 removeProgress_: function() {
614 if (this.progress) {
615 this.rowbutton.removeChild(this.progress);
616 this.progress = null;
617 }
601 }, 618 },
602 619
603 updatePause_: function(result) { 620 updatePause_: function(result) {
604 var pause = this.pause; 621 var pause = this.pause;
605 var pauseStr = localStrings.getString('pause'); 622 var pauseStr = localStrings.getString('pause');
606 var resumeStr = localStrings.getString('resume'); 623 var resumeStr = localStrings.getString('resume');
607 624
608 if (pause && 625 if (pause &&
609 result.state == 'PAUSED' && 626 result.state == 'PAUSED' &&
610 pause.textContent != resumeStr) { 627 pause.textContent != resumeStr) {
611 pause.textContent = resumeStr; 628 pause.textContent = resumeStr;
612 } else if (pause && 629 } else if (pause &&
613 result.state == 'IN_PROGRESS' && 630 result.state == 'IN_PROGRESS' &&
614 pause.textContent != pauseStr) { 631 pause.textContent != pauseStr) {
615 pause.textContent = pauseStr; 632 pause.textContent = pauseStr;
616 } 633 }
617 }, 634 },
618 635
636 updateProgress_: function(result) {
637 this.removeAllowDownload_();
638 this.createProgress_();
639 this.progress.textContent = result.progress_status_text;
640 this.updatePause_(result);
641 },
642
643 /**
644 * Called when the item has finished downloading. Switch the menu
645 * and remove the progress bar.
646 * @private
647 */
648 finishedDownloading_: function() {
649 this.filename.className = 'downloaded title';
650
651 // Menu has Open. Pause/Cancel hidden.
652 this.open.style.display = '';
653 this.pause.style.display = 'none';
654 this.cancel.style.display = 'none';
655
656 // Make rowbutton clickable.
657 this.rowbutton.onclick = this.getFunctionForItem_();
658 this.rowbutton.style.cursor = 'pointer';
659
660 // Make rowbutton draggable.
661 this.rowbutton.setAttribute('draggable', 'true');
662 var self = this;
663 this.rowbutton.addEventListener('dragstart', function(e) {
664 e.dataTransfer.effectAllowed = 'copy';
665 e.dataTransfer.setData('Text', self.path);
666 e.dataTransfer.setData('URL', 'file:///' + self.path);
667 }, false);
668
669 this.removeAllowDownload_();
670 this.removeProgress_();
671 },
672
619 /** 673 /**
620 * One of the DownloadItem we are observing has updated. 674 * One of the DownloadItem we are observing has updated.
621 * @param {Object} result JSON representation of DownloadItem. 675 * @param {Object} result JSON representation of DownloadItem.
622 */ 676 */
623 downloadUpdated: function(result) { 677 downloadUpdated: function(result) {
624 if (result.percent < 100 || result.state == 'DANGEROUS') { 678 this.filename.textContent = result.file_name;
625 this.startedDownloading_(result); 679 this.filename.className = 'downloading title';
680
681 if (result.state == 'CANCELLED' ||
682 result.state == 'INTERRUPTED') {
683 this.list.remove(this);
684 } else if (result.state == 'DANGEROUS') {
685 this.createAllowDownload_();
686 } else if (result.percent < 100) {
626 this.updateProgress_(result); 687 this.updateProgress_(result);
627 this.updatePause_(result);
628 } else { 688 } else {
629 this.finishedDownloading_(); 689 this.finishedDownloading_();
630 } 690 }
631 }, 691 },
632 }; 692 };
633 693
634 /** 694 /**
635 * DownloadRowList is a container for DownloadRows. 695 * DownloadRowList is a container for DownloadRows.
636 */ 696 */
637 function DownloadRowList() { 697 function DownloadRowList() {
(...skipping 30 matching lines...) Expand all
668 return this.numRows > this.MIN_ROWS && this.numRows < this.MAX_ROWS; 728 return this.numRows > this.MIN_ROWS && this.numRows < this.MAX_ROWS;
669 }, 729 },
670 730
671 /** 731 /**
672 * Remove a row from the list, as when a download is canceled, or 732 * Remove a row from the list, as when a download is canceled, or
673 * the the number of rows has exceeded the max allowed. 733 * the the number of rows has exceeded the max allowed.
674 * 734 *
675 * @param {DownloadRow} row Row to be removed. 735 * @param {DownloadRow} row Row to be removed.
676 * @private 736 * @private
677 */ 737 */
678 remove_: function(row) { 738 remove: function(row) {
679 this.downloadList.splice(this.downloadList.indexOf(row), 1); 739 this.downloadList.splice(this.downloadList.indexOf(row), 1);
680 this.element.removeChild(row.element); 740 this.element.removeChild(row.element);
681 row.element.downloadRow = null; 741 row.element.downloadRow = null;
682 742
683 this.numRows--; 743 this.numRows--;
684 if (this.numRowsOutsideRange_()) 744 if (this.numRowsOutsideRange_())
685 window.resizeBy(0, -this.ROW_HEIGHT); 745 window.resizeBy(0, -this.ROW_HEIGHT);
686 }, 746 },
687 747
688 /** 748 /**
689 * Append a new row to the list, removing the last row if we exceed the 749 * Append a new row to the list, removing the last row if we exceed the
690 * maximum allowed. 750 * maximum allowed.
691 * @param {DownloadRow} row Row to be removed. 751 * @param {DownloadRow} row Row to be removed.
692 */ 752 */
693 append: function(row) { 753 append: function(row) {
694 if (this.numRowsOutsideRange_()) 754 if (this.numRowsOutsideRange_())
695 window.resizeBy(0, this.ROW_HEIGHT); 755 window.resizeBy(0, this.ROW_HEIGHT);
696 756
697 this.numRows++; 757 this.numRows++;
698 758
699 var list = this.element; 759 var list = this.element;
700 if (this.numRows > this.MAX_ROWS) 760 if (this.numRows > this.MAX_ROWS)
701 this.remove_(list.lastChild.downloadRow); 761 this.remove(list.lastChild.downloadRow);
702 762
703 if (list.firstChild) { 763 if (list.firstChild) {
704 list.insertBefore(row, list.firstChild); 764 list.insertBefore(row, list.firstChild);
705 } else { 765 } else {
706 list.appendChild(row); 766 list.appendChild(row);
707 } 767 }
708 }, 768 },
709 769
710 /** 770 /**
711 * Handle list callback with list of DownloadItems. 771 * Handle list callback with list of DownloadItems.
(...skipping 17 matching lines...) Expand all
729 } 789 }
730 if (!found) 790 if (!found)
731 removeList.pushUnique(this.downloadList[y]); 791 removeList.pushUnique(this.downloadList[y]);
732 } 792 }
733 793
734 for (var i = 0; i < results.length; i++) { 794 for (var i = 0; i < results.length; i++) {
735 this.update(results[i]); 795 this.update(results[i]);
736 } 796 }
737 797
738 for (i = 0; i < removeList.length; i++) { 798 for (i = 0; i < removeList.length; i++) {
739 this.remove_(removeList[i]); 799 this.remove(removeList[i]);
740 } 800 }
741 }, 801 },
742 802
743 /** 803 /**
744 * Handle update of a DownloadItem we're observing. 804 * Handle update of a DownloadItem we're observing.
745 * @param {Object} result JSON representation of DownloadItem. 805 * @param {Object} result JSON representation of DownloadItem.
746 */ 806 */
747 update: function(result) { 807 update: function(result) {
748 var element = $(result.file_path); 808 var element = $(result.file_path);
749 var row = element && element.downloadRow; 809 var row = element && element.downloadRow;
750 if (element &&
751 result.state == 'CANCELLED' ||
752 result.state == 'INTERRUPTED') {
753 this.remove_(row);
754 return;
755 }
756 810
757 if (!element && 811 if (!row &&
758 result.state != 'CANCELLED' && 812 result.state != 'CANCELLED' &&
759 result.state != 'INTERRUPTED') { 813 result.state != 'INTERRUPTED') {
760 row = new DownloadRow(this, result); 814 row = new DownloadRow(this, result);
761 } 815 }
762 816
763 row && row.downloadUpdated(result); 817 row && row.downloadUpdated(result);
764 }, 818 },
765 }; 819 };
766 820
767 </script> 821 </script>
768 <body onload="init();" onclick="menu.clear()" onselectstart="return false" 822 <body onload="init();" onclick="menu.clear()" onselectstart="return false"
769 i18n-values=".style.fontFamily:fontfamily"> 823 i18n-values=".style.fontFamily:fontfamily">
770 <div id="header"> 824 <div id="header">
771 <div id="currenttitle"></div> 825 <div id="currenttitle"></div>
772 </div><br> 826 </div><br>
773 <div id="main" class="columnlist"></div> 827 <div id="main" class="columnlist"></div>
774 <div id="showalldownloads" class="showalldownloads"> 828 <div id="showalldownloads" class="showalldownloads">
775 <span id="showalldownloadstext" class="showalldownloadstext" 829 <span id="showalldownloadstext" class="showalldownloadstext"
776 onclick="showAllDownloads()"></span> 830 onclick="showAllDownloads()"></span>
777 </div> 831 </div>
778 </body> 832 </body>
779 </html> 833 </html>
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/active_downloads_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698