downloads: break downloads.js into more classes/files.
commit85c004102bdcf0e5d741559b2235fdcb9d4aaa19
authordbeam <dbeam@chromium.org>
Thu, 12 Mar 2015 01:33:21 +0000 (11 18:33 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 12 Mar 2015 01:34:02 +0000 (12 01:34 +0000)
treeeb7db880852ddba023503c032cd6b9fd3a4e50b9
parenta7c5b29eb875d894d9ea9757ced5a0ce0335ca54
downloads: break downloads.js into more classes/files.

chrome://downloads' code has gotten less flexible than we'd like over
the years and needs a little TLC.

This CL heavily refactors chrome://downloads code by ripping apart
downloads.js into:

  downloads.{
    Item: a light data wrapper that has-an ItemView
    ItemView: responsible for beautiful downloads
    Manager: owns and manages all the items
  }

as well as moving large portions of programmatic DOM creation (i.e. tons
of document.createElement() calls) into an HTML template that's cloned.

The JS refactor loosens the coupling between various layers, more
clearly show responsibilities, and makes the code easier to understand,
test, and maintain (in theory).

The new way C++ => JS communication works is:

- if an item will be hidden or shown (e.g. remove, undo, new)
 - C++ sends a whole new list to the JS
 - the JS is now much smarter about re-using DOM nodes
  - this preserves focus and has better performance

- if an item is simply updated (e.g. downloading in progress)
 - C++ sends an update to that specific item

R=asanka@chromium.org
BUG=446412

Review URL: https://codereview.chromium.org/977473002

Cr-Commit-Position: refs/heads/master@{#320204}
20 files changed:
chrome/app/generated_resources.grd
chrome/browser/browser_resources.grd
chrome/browser/download/download_item_model.cc
chrome/browser/download/download_item_model.h
chrome/browser/resources/downloads/OWNERS
chrome/browser/resources/downloads/compiled_resources.gyp
chrome/browser/resources/downloads/downloads.css
chrome/browser/resources/downloads/downloads.html
chrome/browser/resources/downloads/downloads.js [deleted file]
chrome/browser/resources/downloads/externs.js [new file with mode: 0644]
chrome/browser/resources/downloads/focus_row.js [new file with mode: 0644]
chrome/browser/resources/downloads/item.js [new file with mode: 0644]
chrome/browser/resources/downloads/item_view.js [new file with mode: 0644]
chrome/browser/resources/downloads/manager.js [new file with mode: 0644]
chrome/browser/ui/webui/downloads_dom_handler.cc
chrome/browser/ui/webui/downloads_dom_handler.h
chrome/browser/ui/webui/downloads_dom_handler_browsertest.cc
chrome/browser/ui/webui/downloads_ui.cc
chrome/browser/ui/webui/downloads_ui_browsertest.js
chrome/browser/ui/webui/downloads_ui_browsertest_base.js