summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-12 20:16:16 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-12 20:16:16 +0000
commit7ecf33cc7376a3c9beb5ccd1f3864f37a9f0684e (patch)
treea75e1846f183595d4d0d6e8b9038fad8b6645a11
parentc025738684582542a2a5cd5ffa2fbdd5ab28f6ce (diff)
downloadchromium_src-7ecf33cc7376a3c9beb5ccd1f3864f37a9f0684e.zip
chromium_src-7ecf33cc7376a3c9beb5ccd1f3864f37a9f0684e.tar.gz
chromium_src-7ecf33cc7376a3c9beb5ccd1f3864f37a9f0684e.tar.bz2
Downloads: First pass at a cleanup to match webdev style.
BUG=none TEST=none R=csilv,dbeam Review URL: https://chromiumcodereview.appspot.com/9689007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126201 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_resources.grd5
-rw-r--r--chrome/browser/resources/downloads/downloads.css (renamed from chrome/browser/resources/downloads.html)64
-rw-r--r--chrome/browser/resources/downloads/downloads.html43
-rw-r--r--chrome/browser/resources/downloads/downloads.js (renamed from chrome/browser/resources/downloads.js)149
-rw-r--r--chrome/browser/ui/webui/downloads_ui.cc1
5 files changed, 139 insertions, 123 deletions
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd
index 8e01b60..849c2da 100644
--- a/chrome/browser/browser_resources.grd
+++ b/chrome/browser/browser_resources.grd
@@ -43,8 +43,9 @@
<include name="IDR_CRASHES_JS" file="resources\crashes.js" type="BINDATA" />
<include name="IDR_CREDITS_HTML" file="resources\about_credits.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_CREDITS_JS" file="resources\about_credits.js" type="BINDATA" />
- <include name="IDR_DOWNLOADS_HTML" file="resources\downloads.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
- <include name="IDR_DOWNLOADS_JS" file="resources\downloads.js" type="BINDATA" />
+ <include name="IDR_DOWNLOADS_CSS" file="resources\downloads\downloads.css" flattenhtml="true" type="BINDATA" />
+ <include name="IDR_DOWNLOADS_HTML" file="resources\downloads\downloads.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
+ <include name="IDR_DOWNLOADS_JS" file="resources\downloads\downloads.js" type="BINDATA" />
<if expr="is_macosx">
<include name="IDR_EXTENSIONS_INFOBAR_CSS" file="resources\extensions_infobar_mac.css" flattenhtml="true" type="BINDATA" />
</if>
diff --git a/chrome/browser/resources/downloads.html b/chrome/browser/resources/downloads/downloads.css
index fcfd7ca..e85b734 100644
--- a/chrome/browser/resources/downloads.html
+++ b/chrome/browser/resources/downloads/downloads.css
@@ -1,13 +1,7 @@
-<!DOCTYPE HTML>
-<html i18n-values="dir:textdirection;">
-<head>
-<meta charset="utf-8">
-<title i18n-content="title"></title>
-<link rel="icon" href="../../app/theme/downloads_favicon.png">
-<link rel="stylesheet" href="old_webui.css">
-<link rel="stylesheet" href="shared/css/chrome_shared.css">
-<link rel="stylesheet" href="shared/css/widgets.css">
-<style>
+/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
#downloads-summary {
background-color: rgb(235, 239, 249);
@@ -30,11 +24,11 @@ html[dir=rtl] #downloads-actions {
}
#downloads-actions > a {
- margin-left: 10px;
+ -webkit-margin-start: 10px;
}
#downloads-actions > a:first-child {
- margin-left: 0;
+ -webkit-margin-start: 0;
}
#downloads-display {
@@ -84,7 +78,8 @@ html[dir=rtl] .icon {
.download.otr > .safe,
.download.otr > .show-dangerous {
-webkit-transition: opacity 150ms;
- background: url('shared/images/otr_icon_standalone.png') no-repeat 100% 100%;
+ background: url('../shared/images/otr_icon_standalone.png')
+ no-repeat 100% 100%;
opacity: .66;
}
@@ -112,11 +107,11 @@ html[dir=rtl] .progress {
}
.progress.background {
- background: url('../../app/theme/download_progress_background32.png');
+ background: url('chrome://theme/IDR_DOWNLOAD_PROGRESS_BACKGROUND_32');
}
.progress.foreground {
- background: url('../../app/theme/download_progress_foreground32.png');
+ background: url('chrome://theme/IDR_DOWNLOAD_PROGRESS_FOREGROUND_32');
}
.name {
@@ -127,7 +122,6 @@ html[dir=rtl] .progress {
}
.download .status {
- display: inline;
color: #999;
white-space: nowrap;
}
@@ -145,43 +139,11 @@ html[dir=rtl] .progress {
}
.controls a {
+ -webkit-margin-end: 16px;
color: #777;
- margin-right: 16px;
}
#downloads-pagination {
+ -webkit-margin-start: 18px;
padding-top: 24px;
- margin-left: 18px;
-}
-
-</style>
-<script src="chrome://resources/js/local_strings.js"></script>
-</head>
-<body i18n-values=".style.fontFamily:fontfamily;.style.fontSize:fontsize">
-<div class="header">
- <a id="search-link" href="">
- <img src="shared/images/downloads_section.png"
- width="67" height="67" class="logo" border="0" /></a>
- <form id="search-form" method="post" action="" class="form">
- <input type="text" name="term" id="term" />
- <input id="search-submit"
- type="submit" name="submit" i18n-values="value:searchbutton" />
- </form>
-</div>
-<div class="main">
- <div id="downloads-summary">
- <span id="downloads-summary-text" i18n-content="downloads">Downloads</span>
- <span id="downloads-actions">
- <a id="open-downloads-folder" href=""
- i18n-content="open_downloads_folder">Open downloads folder</a>
- <a id="clear-all" href="" i18n-content="clear_all">Clear All</a>
- </span>
- </div>
- <div id="downloads-display"></div>
-</div>
-<script src="chrome://downloads/downloads.js"></script>
-<script src="chrome://downloads/strings.js"></script>
-<script src="chrome://resources/js/i18n_template.js"></script>
-<script src="chrome://resources/js/i18n_process.js"></script>
-</body>
-</html>
+}
diff --git a/chrome/browser/resources/downloads/downloads.html b/chrome/browser/resources/downloads/downloads.html
new file mode 100644
index 0000000..438fb87
--- /dev/null
+++ b/chrome/browser/resources/downloads/downloads.html
@@ -0,0 +1,43 @@
+<!DOCTYPE HTML>
+<html i18n-values="dir:textdirection;">
+<head>
+ <meta charset="utf-8">
+ <title i18n-content="title"></title>
+ <link rel="icon" href="chrome://theme/IDR_DOWNLOADS_FAVICON">
+ <link rel="stylesheet" href="../old_webui.css">
+ <link rel="stylesheet" href="../shared/css/chrome_shared.css">
+ <link rel="stylesheet" href="../shared/css/widgets.css">
+ <link rel="stylesheet" href="downloads.css">
+ <script src="chrome://resources/js/local_strings.js"></script>
+ <script src="chrome://resources/js/util.js"></script>
+ <script src="chrome://downloads/downloads.js"></script>
+</head>
+<body i18n-values=".style.fontFamily:fontfamily;.style.fontSize:fontsize">
+ <div class="header">
+ <a id="search-link" href="">
+ <img src="../shared/images/downloads_section.png"
+ width="67" height="67" class="logo" border="0">
+ </a>
+ <form id="search-form" method="post" action="" class="form">
+ <input type="text" name="term" id="term">
+ <input id="search-submit" type="submit" name="submit"
+ i18n-values="value:searchbutton">
+ </form>
+ </div>
+ <div class="main">
+ <div id="downloads-summary">
+ <span id="downloads-summary-text" i18n-content="downloads"></span>
+ <span id="downloads-actions">
+ <a id="open-downloads-folder" href=""
+ i18n-content="open_downloads_folder">
+ </a>
+ <a id="clear-all" href="" i18n-content="clear_all"></a>
+ </span>
+ </div>
+ <div id="downloads-display"></div>
+ </div>
+ <script src="chrome://downloads/strings.js"></script>
+ <script src="chrome://resources/js/i18n_template.js"></script>
+ <script src="chrome://resources/js/i18n_process.js"></script>
+</body>
+</html>
diff --git a/chrome/browser/resources/downloads.js b/chrome/browser/resources/downloads/downloads.js
index 43023cf..a4daf91 100644
--- a/chrome/browser/resources/downloads.js
+++ b/chrome/browser/resources/downloads/downloads.js
@@ -2,9 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-///////////////////////////////////////////////////////////////////////////////
-// Helper functions
-function $(o) {return document.getElementById(o);}
+// TODO(jhawkins): Use hidden instead of showInline* and display:none.
/**
* Sets the display style of a node.
@@ -59,6 +57,7 @@ function createButton(onclick, value) {
// Downloads
/**
* Class to hold all the information about the visible downloads.
+ * @constructor
*/
function Downloads() {
this.downloads_ = {};
@@ -97,7 +96,7 @@ Downloads.prototype.updated = function(download) {
}
this.updateDateDisplay_();
}
-}
+};
/**
* Set our display search text.
@@ -105,7 +104,7 @@ Downloads.prototype.updated = function(download) {
*/
Downloads.prototype.setSearchText = function(searchText) {
this.searchText_ = searchText;
-}
+};
/**
* Update the summary block above the results
@@ -127,11 +126,12 @@ Downloads.prototype.updateSummary = function() {
if (!hasDownloads) {
this.node_.textContent = localStrings.getString('noresults');
}
-}
+};
/**
* Update the date visibility in our nodes so that no date is
* repeated.
+ * @private
*/
Downloads.prototype.updateDateDisplay_ = function() {
var dateContainers = document.getElementsByClassName('date-container');
@@ -145,7 +145,7 @@ Downloads.prototype.updateDateDisplay_ = function() {
container.style.display = 'block';
}
}
-}
+};
/**
* Remove a download.
@@ -155,7 +155,7 @@ Downloads.prototype.remove = function(id) {
this.node_.removeChild(this.downloads_[id].node);
delete this.downloads_[id];
this.updateDateDisplay_();
-}
+};
/**
* Clear all downloads and reset us back to a null state.
@@ -165,7 +165,7 @@ Downloads.prototype.clear = function() {
this.downloads_[id].clear();
this.remove(id);
}
-}
+};
/**
* Schedule icon load.
@@ -198,18 +198,19 @@ Downloads.prototype.scheduleIconLoad = function(elem, iconURL) {
// Start loading if none scheduled yet
if (!this.isIconLoading_)
loadNext();
-}
+};
///////////////////////////////////////////////////////////////////////////////
// Download
/**
* A download and the DOM representation for that download.
* @param {Object} download A backend download object (see downloads_ui.cc)
+ * @constructor
*/
function Download(download) {
// Create DOM
- this.node = createElementWithClassName('div','download' +
- (download.otr ? ' otr' : ''));
+ this.node = createElementWithClassName(
+ 'div', 'download' + (download.otr ? ' otr' : ''));
// Dates
this.dateContainer_ = createElementWithClassName('div', 'date-container');
@@ -238,7 +239,7 @@ function Download(download) {
this.nodeProgressForeground_ =
createElementWithClassName('div', 'progress foreground');
this.nodeProgressForeground_.style.webkitMask =
- '-webkit-canvas(canvas_'+download.id+')';
+ '-webkit-canvas(canvas_' + download.id + ')';
this.safe_.appendChild(this.nodeProgressForeground_);
}
@@ -265,14 +266,14 @@ function Download(download) {
this.safe_.appendChild(nodeURLDiv);
this.nodeURL_ = createElementWithClassName('a', 'src-url');
- this.nodeURL_.target = "_blank";
+ this.nodeURL_.target = '_blank';
nodeURLDiv.appendChild(this.nodeURL_);
// Controls.
this.nodeControls_ = createElementWithClassName('div', 'controls');
this.safe_.appendChild(this.nodeControls_);
- // We don't need "show in folder" in chromium os. See download_ui.cc and
+ // We don't need 'show in folder' in chromium os. See download_ui.cc and
// http://code.google.com/p/chromium-os/issues/detail?id=916.
var showinfolder = localStrings.getString('control_showinfolder');
if (showinfolder) {
@@ -327,36 +328,36 @@ function Download(download) {
* DownloadsDOMHandler::CreateDownloadItemValue
*/
Download.States = {
- IN_PROGRESS : "IN_PROGRESS",
- CANCELLED : "CANCELLED",
- COMPLETE : "COMPLETE",
- PAUSED : "PAUSED",
- DANGEROUS : "DANGEROUS",
- INTERRUPTED : "INTERRUPTED",
-}
+ IN_PROGRESS: 'IN_PROGRESS',
+ CANCELLED: 'CANCELLED',
+ COMPLETE: 'COMPLETE',
+ PAUSED: 'PAUSED',
+ DANGEROUS: 'DANGEROUS',
+ INTERRUPTED: 'INTERRUPTED',
+};
/**
* Explains why a download is in DANGEROUS state.
*/
Download.DangerType = {
- NOT_DANGEROUS: "NOT_DANGEROUS",
- DANGEROUS_FILE: "DANGEROUS_FILE",
- DANGEROUS_URL: "DANGEROUS_URL",
- DANGEROUS_CONTENT: "DANGEROUS_CONTENT"
-}
+ NOT_DANGEROUS: 'NOT_DANGEROUS',
+ DANGEROUS_FILE: 'DANGEROUS_FILE',
+ DANGEROUS_URL: 'DANGEROUS_URL',
+ DANGEROUS_CONTENT: 'DANGEROUS_CONTENT'
+};
/**
* Constants for the progress meter.
*/
Download.Progress = {
- width : 48,
- height : 48,
- radius : 24,
- centerX : 24,
- centerY : 24,
- base : -0.5 * Math.PI,
- dir : false,
-}
+ width: 48,
+ height: 48,
+ radius: 24,
+ centerX: 24,
+ centerY: 24,
+ base: -0.5 * Math.PI,
+ dir: false,
+};
/**
* Updates the download to reflect new data.
@@ -474,7 +475,7 @@ Download.prototype.update = function(download) {
this.danger_.style.display = 'none';
this.safe_.style.display = 'block';
}
-}
+};
/**
* Removes applicable bits from the DOM in preparation for deletion.
@@ -491,9 +492,10 @@ Download.prototype.clear = function() {
this.dangerDiscard_.onclick = null;
this.node.innerHTML = '';
-}
+};
/**
+ * @private
* @return {string} User-visible status update text.
*/
Download.prototype.getStatusText_ = function() {
@@ -515,74 +517,82 @@ Download.prototype.getStatusText_ = function() {
return this.fileExternallyRemoved_ ?
localStrings.getString('status_removed') : '';
}
-}
+};
/**
* Tells the backend to initiate a drag, allowing users to drag
* files from the download page and have them appear as native file
* drags.
+ * @private
*/
Download.prototype.drag_ = function() {
chrome.send('drag', [this.id_.toString()]);
return false;
-}
+};
/**
* Tells the backend to open this file.
+ * @private
*/
Download.prototype.openFile_ = function() {
chrome.send('openFile', [this.id_.toString()]);
return false;
-}
+};
/**
* Tells the backend that the user chose to save a dangerous file.
+ * @private
*/
Download.prototype.saveDangerous_ = function() {
chrome.send('saveDangerous', [this.id_.toString()]);
return false;
-}
+};
/**
* Tells the backend that the user chose to discard a dangerous file.
+ * @private
*/
Download.prototype.discardDangerous_ = function() {
chrome.send('discardDangerous', [this.id_.toString()]);
downloads.remove(this.id_);
return false;
-}
+};
/**
* Tells the backend to show the file in explorer.
+ * @private
*/
Download.prototype.show_ = function() {
chrome.send('show', [this.id_.toString()]);
return false;
-}
+};
/**
* Tells the backend to pause this download.
+ * @private
*/
Download.prototype.togglePause_ = function() {
chrome.send('togglepause', [this.id_.toString()]);
return false;
-}
+};
/**
* Tells the backend to remove this download from history and download shelf.
+ * @private
*/
Download.prototype.remove_ = function() {
chrome.send('remove', [this.id_.toString()]);
return false;
-}
+};
/**
* Tells the backend to cancel this download.
+ * @private
*/
Download.prototype.cancel_ = function() {
chrome.send('cancel', [this.id_.toString()]);
return false;
-}
+};
///////////////////////////////////////////////////////////////////////////////
// Page:
@@ -607,6 +617,28 @@ function load() {
$('term').focus();
$('term').setAttribute('aria-labelledby', 'search-submit');
setSearch('');
+
+ var clearAllLink = $('clear-all');
+ clearAllLink.onclick = clearAll;
+ clearAllLink.oncontextmenu = function() { return false; };
+
+ // TODO(jhawkins): Use a link-button here.
+ var openDownloadsFolderLink = $('open-downloads-folder');
+ openDownloadsFolderLink.onclick =
+ chrome.send.bind(chrome, 'openDownloadsFolder');
+ openDownloadsFolderLink.oncontextmenu = function() { return false; };
+
+ $('search-link').onclick = function(e) {
+ setSearch('');
+ e.preventDefault();
+ return false;
+ };
+
+ $('search-form').onsubmit = function(e) {
+ setSearch(this.term.value);
+ e.preventDefault();
+ return false;
+ };
}
function setSearch(searchText) {
@@ -620,13 +652,7 @@ function clearAll() {
fifo_results.length = 0;
downloads.clear();
downloads.setSearchText('');
- chrome.send('clearAll', []);
- return false;
-}
-
-function openDownloadsFolder() {
- chrome.send('openDownloadsFolder');
- return false;
+ chrome.send('clearAll');
}
///////////////////////////////////////////////////////////////////////////////
@@ -676,20 +702,3 @@ function tryDownloadUpdatedPeriodically() {
// Add handlers to HTML elements.
window.addEventListener('DOMContentLoaded', load);
-
-var clearAllLink = $('clear-all');
-clearAllLink.onclick = function () { clearAll(''); };
-clearAllLink.oncontextmenu = function() { return false; };
-
-var openDownloadsFolderLink = $('open-downloads-folder');
-openDownloadsFolderLink.onclick = openDownloadsFolder;
-openDownloadsFolderLink.oncontextmenu = function() { return false; };
-
-$('search-link').onclick = function () {
- setSearch('');
- return false;
-};
-$('search-form').onsubmit = function () {
- setSearch(this.term.value);
- return false;
-};
diff --git a/chrome/browser/ui/webui/downloads_ui.cc b/chrome/browser/ui/webui/downloads_ui.cc
index 8bc5d86..18c4809 100644
--- a/chrome/browser/ui/webui/downloads_ui.cc
+++ b/chrome/browser/ui/webui/downloads_ui.cc
@@ -71,6 +71,7 @@ ChromeWebUIDataSource* CreateDownloadsUIHTMLSource() {
IDS_DOWNLOAD_LINK_REMOVE);
source->set_json_path("strings.js");
+ source->add_resource_path("downloads.css", IDR_DOWNLOADS_CSS);
source->add_resource_path("downloads.js", IDR_DOWNLOADS_JS);
source->set_default_resource(IDR_DOWNLOADS_HTML);