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

Unified Diff: chrome/browser/dom_ui/downloads_ui.cc

Issue 40047: Make the download page focus the input field onload.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/downloads.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/dom_ui/downloads_ui.cc
===================================================================
--- chrome/browser/dom_ui/downloads_ui.cc (revision 10778)
+++ chrome/browser/dom_ui/downloads_ui.cc (working copy)
@@ -25,6 +25,10 @@
// DownloadsUI is accessible from chrome-ui://downloads.
static const char kDownloadsHost[] = "downloads";
+// Maximum number of downloads to show. TODO(glen): Remove this and instead
Dan Beam 2015/12/11 00:25:47 well, that only took 6.75 years :) https://codere
+// stuff the downloads down the pipe slowly.
+static const int kMaxDownloads = 150;
+
///////////////////////////////////////////////////////////////////////////////
//
// DownloadsHTMLSource
@@ -98,7 +102,7 @@
bool> {
public:
bool operator()(const DownloadItem* lhs, const DownloadItem* rhs) {
- return lhs->start_time() < rhs->start_time();
+ return lhs->start_time() > rhs->start_time();
}
};
@@ -120,8 +124,10 @@
NewCallback(this, &DownloadsDOMHandler::HandleDiscardDangerous));
dom_ui_->RegisterMessageCallback("show",
NewCallback(this, &DownloadsDOMHandler::HandleShow));
- dom_ui_->RegisterMessageCallback("pause",
+ dom_ui_->RegisterMessageCallback("togglepause",
NewCallback(this, &DownloadsDOMHandler::HandlePause));
+ dom_ui_->RegisterMessageCallback("resume",
+ NewCallback(this, &DownloadsDOMHandler::HandlePause));
dom_ui_->RegisterMessageCallback("cancel",
NewCallback(this, &DownloadsDOMHandler::HandleCancel));
@@ -179,6 +185,9 @@
// Scan for any in progress downloads and add ourself to them as an observer.
for (OrderedDownloads::iterator it = download_items_.begin();
it != download_items_.end(); ++it) {
+ if (static_cast<int>(it - download_items_.begin()) > kMaxDownloads)
+ break;
+
DownloadItem* download = *it;
if (download->state() == DownloadItem::IN_PROGRESS) {
// We want to know what happens as the download progresses.
@@ -253,11 +262,12 @@
void DownloadsDOMHandler::SendCurrentDownloads() {
ListValue results_value;
-
for (OrderedDownloads::iterator it = download_items_.begin();
- it != download_items_.end(); ++it) {
- results_value.Append(CreateDownloadItemValue(*it,
- static_cast<int>(it - download_items_.begin())));
+ it != download_items_.end(); ++it) {
+ int index = static_cast<int>(it - download_items_.begin());
+ if (index > kMaxDownloads)
+ break;
+ results_value.Append(CreateDownloadItemValue(*it,index));
}
dom_ui_->CallJavascriptFunction(L"downloadsList", results_value);
@@ -267,7 +277,7 @@
DownloadItem* download, int id) {
DictionaryValue* file_value = new DictionaryValue();
- file_value->SetInteger(L"time",
+ file_value->SetInteger(L"started",
static_cast<int>(download->start_time().ToTimeT()));
file_value->SetInteger(L"id", id);
file_value->SetString(L"file_path", download->full_path().ToWStringHack());
« no previous file with comments | « no previous file | chrome/browser/resources/downloads.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698