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

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)
565 return;
566
567 this.allowdownload = this.createChild_('div', 'allowdownload',
568 this.rowbutton);
569
570 this.createChild_('span', 'allowdownloadtext', this.allowdownload,
571 localStrings.getString('allowdownload'));
572
573 var self = this;
574 this.createChild_('span', 'confirm', this.allowdownload,
575 localStrings.getString('confirmyes'),
576 function() {
577 self.allowDownload_();
578 });
579 this.createChild_('span', 'confirm', this.allowdownload,
580 localStrings.getString('confirmcancel'),
581 function() {
582 self.cancelDownload_();
583 });
584
585 this.resetRow_();
586 this.menubutton.onclick = '';
587 },
588
589 removeAllowDownload_: function() {
590 if (this.allowdownload) {
591 this.rowbutton.removeChild(this.allowdownload);
592 this.allowdownload = null;
593 var self = this;
594 this.menubutton.onclick = function() {
595 menu.clicked(self);
596 };
597 }
598 },
599
600 createProgress_: function() {
601 if (this.progress)
602 return;
603
604 this.progress = this.createChild_('div', 'progress', this.rowbutton);
605
606 // Menu has Pause/Cancel. Open hidden.
607 this.open.style.display = 'none';
608 this.pause.style.display = '';
609 this.cancel.style.display = '';
610 },
611
612 removeProgress_: function() {
613 if (this.progress) {
614 this.rowbutton.removeChild(this.progress);
615 this.progress = null;
616 }
601 }, 617 },
602 618
603 updatePause_: function(result) { 619 updatePause_: function(result) {
604 var pause = this.pause; 620 var pause = this.pause;
605 var pauseStr = localStrings.getString('pause'); 621 var pauseStr = localStrings.getString('pause');
606 var resumeStr = localStrings.getString('resume'); 622 var resumeStr = localStrings.getString('resume');
607 623
608 if (pause && 624 if (pause &&
609 result.state == 'PAUSED' && 625 result.state == 'PAUSED' &&
610 pause.textContent != resumeStr) { 626 pause.textContent != resumeStr) {
611 pause.textContent = resumeStr; 627 pause.textContent = resumeStr;
612 } else if (pause && 628 } else if (pause &&
613 result.state == 'IN_PROGRESS' && 629 result.state == 'IN_PROGRESS' &&
614 pause.textContent != pauseStr) { 630 pause.textContent != pauseStr) {
615 pause.textContent = pauseStr; 631 pause.textContent = pauseStr;
616 } 632 }
617 }, 633 },
618 634
635 updateProgress_: function(result) {
636 this.removeAllowDownload_();
637 this.createProgress_();
638 this.progress.textContent = result.progress_status_text;
639 this.updatePause_(result);
640 },
641
642 /**
643 * Called when the item has finished downloading. Switch the menu
644 * and remove the progress bar.
645 * @private
646 */
647 finishedDownloading_: function() {
648 this.filename.className = 'downloaded title';
649
650 // Menu has Open. Pause/Cancel hidden.
651 this.open.style.display = '';
652 this.pause.style.display = 'none';
653 this.cancel.style.display = 'none';
654
655 // Make rowbutton clickable.
656 this.rowbutton.onclick = this.getFunctionForItem_();
657 this.rowbutton.style.cursor = 'pointer';
658
659 // Make rowbutton draggable.
660 this.rowbutton.setAttribute('draggable', 'true');
661 var self = this;
662 this.rowbutton.addEventListener('dragstart', function(e) {
663 e.dataTransfer.effectAllowed = 'copy';
664 e.dataTransfer.setData('Text', self.path);
665 e.dataTransfer.setData('URL', 'file:///' + self.path);
666 }, false);
667
668 this.removeAllowDownload_();
669 this.removeProgress_();
670 },
671
619 /** 672 /**
620 * One of the DownloadItem we are observing has updated. 673 * One of the DownloadItem we are observing has updated.
621 * @param {Object} result JSON representation of DownloadItem. 674 * @param {Object} result JSON representation of DownloadItem.
622 */ 675 */
623 downloadUpdated: function(result) { 676 downloadUpdated: function(result) {
624 if (result.percent < 100 || result.state == 'DANGEROUS') { 677 this.filename.textContent = result.file_name;
625 this.startedDownloading_(result); 678 this.filename.className = 'downloading title';
679
680 if (result.state == 'CANCELLED' ||
681 result.state == 'INTERRUPTED') {
682 this.list.remove(this);
683 } else if (result.state == 'DANGEROUS') {
684 this.createAllowDownload_();
685 } else if (result.percent < 100) {
626 this.updateProgress_(result); 686 this.updateProgress_(result);
627 this.updatePause_(result);
628 } else { 687 } else {
629 this.finishedDownloading_(); 688 this.finishedDownloading_();
630 } 689 }
631 }, 690 },
632 }; 691 };
633 692
634 /** 693 /**
635 * DownloadRowList is a container for DownloadRows. 694 * DownloadRowList is a container for DownloadRows.
636 */ 695 */
637 function DownloadRowList() { 696 function DownloadRowList() {
(...skipping 30 matching lines...) Expand all
668 return this.numRows > this.MIN_ROWS && this.numRows < this.MAX_ROWS; 727 return this.numRows > this.MIN_ROWS && this.numRows < this.MAX_ROWS;
669 }, 728 },
670 729
671 /** 730 /**
672 * Remove a row from the list, as when a download is canceled, or 731 * Remove a row from the list, as when a download is canceled, or
673 * the the number of rows has exceeded the max allowed. 732 * the the number of rows has exceeded the max allowed.
674 * 733 *
675 * @param {DownloadRow} row Row to be removed. 734 * @param {DownloadRow} row Row to be removed.
676 * @private 735 * @private
677 */ 736 */
678 remove_: function(row) { 737 remove: function(row) {
679 this.downloadList.splice(this.downloadList.indexOf(row), 1); 738 this.downloadList.splice(this.downloadList.indexOf(row), 1);
680 this.element.removeChild(row.element); 739 this.element.removeChild(row.element);
681 row.element.downloadRow = null; 740 row.element.downloadRow = null;
682 741
683 this.numRows--; 742 this.numRows--;
684 if (this.numRowsOutsideRange_()) 743 if (this.numRowsOutsideRange_())
685 window.resizeBy(0, -this.ROW_HEIGHT); 744 window.resizeBy(0, -this.ROW_HEIGHT);
686 }, 745 },
687 746
688 /** 747 /**
689 * Append a new row to the list, removing the last row if we exceed the 748 * Append a new row to the list, removing the last row if we exceed the
690 * maximum allowed. 749 * maximum allowed.
691 * @param {DownloadRow} row Row to be removed. 750 * @param {DownloadRow} row Row to be removed.
692 */ 751 */
693 append: function(row) { 752 append: function(row) {
694 if (this.numRowsOutsideRange_()) 753 if (this.numRowsOutsideRange_())
695 window.resizeBy(0, this.ROW_HEIGHT); 754 window.resizeBy(0, this.ROW_HEIGHT);
696 755
697 this.numRows++; 756 this.numRows++;
698 757
699 var list = this.element; 758 var list = this.element;
700 if (this.numRows > this.MAX_ROWS) 759 if (this.numRows > this.MAX_ROWS)
701 this.remove_(list.lastChild.downloadRow); 760 this.remove(list.lastChild.downloadRow);
702 761
703 if (list.firstChild) { 762 if (list.firstChild) {
704 list.insertBefore(row, list.firstChild); 763 list.insertBefore(row, list.firstChild);
705 } else { 764 } else {
706 list.appendChild(row); 765 list.appendChild(row);
707 } 766 }
708 }, 767 },
709 768
710 /** 769 /**
711 * Handle list callback with list of DownloadItems. 770 * Handle list callback with list of DownloadItems.
(...skipping 17 matching lines...) Expand all
729 } 788 }
730 if (!found) 789 if (!found)
731 removeList.pushUnique(this.downloadList[y]); 790 removeList.pushUnique(this.downloadList[y]);
732 } 791 }
733 792
734 for (var i = 0; i < results.length; i++) { 793 for (var i = 0; i < results.length; i++) {
735 this.update(results[i]); 794 this.update(results[i]);
736 } 795 }
737 796
738 for (i = 0; i < removeList.length; i++) { 797 for (i = 0; i < removeList.length; i++) {
739 this.remove_(removeList[i]); 798 this.remove(removeList[i]);
740 } 799 }
741 }, 800 },
742 801
743 /** 802 /**
744 * Handle update of a DownloadItem we're observing. 803 * Handle update of a DownloadItem we're observing.
745 * @param {Object} result JSON representation of DownloadItem. 804 * @param {Object} result JSON representation of DownloadItem.
746 */ 805 */
747 update: function(result) { 806 update: function(result) {
748 var element = $(result.file_path); 807 var element = $(result.file_path);
749 var row = element && element.downloadRow; 808 var row = element && element.downloadRow;
750 if (element &&
751 result.state == 'CANCELLED' ||
752 result.state == 'INTERRUPTED') {
753 this.remove_(row);
754 return;
755 }
756 809
757 if (!element && 810 if (!row &&
758 result.state != 'CANCELLED' && 811 result.state != 'CANCELLED' &&
759 result.state != 'INTERRUPTED') { 812 result.state != 'INTERRUPTED') {
760 row = new DownloadRow(this, result); 813 row = new DownloadRow(this, result);
761 } 814 }
762 815
763 row && row.downloadUpdated(result); 816 row && row.downloadUpdated(result);
764 }, 817 },
765 }; 818 };
766 819
767 </script> 820 </script>
768 <body onload="init();" onclick="menu.clear()" onselectstart="return false" 821 <body onload="init();" onclick="menu.clear()" onselectstart="return false"
769 i18n-values=".style.fontFamily:fontfamily"> 822 i18n-values=".style.fontFamily:fontfamily">
770 <div id="header"> 823 <div id="header">
771 <div id="currenttitle"></div> 824 <div id="currenttitle"></div>
772 </div><br> 825 </div><br>
773 <div id="main" class="columnlist"></div> 826 <div id="main" class="columnlist"></div>
774 <div id="showalldownloads" class="showalldownloads"> 827 <div id="showalldownloads" class="showalldownloads">
775 <span id="showalldownloadstext" class="showalldownloadstext" 828 <span id="showalldownloadstext" class="showalldownloadstext"
776 onclick="showAllDownloads()"></span> 829 onclick="showAllDownloads()"></span>
777 </div> 830 </div>
778 </body> 831 </body>
779 </html> 832 </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