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

Side by Side Diff: chrome/browser/ui/webui/downloads_dom_handler.cc

Issue 14958003: [Resumption 12/12] Support resuming interrupted downloads from the downloads page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | « chrome/browser/resources/downloads/downloads.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/downloads_dom_handler.h" 5 #include "chrome/browser/ui/webui/downloads_dom_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 download_item->GetFileNameToReportUser().LossyDisplayName(); 138 download_item->GetFileNameToReportUser().LossyDisplayName();
139 file_name = base::i18n::GetDisplayStringInLTRDirectionality(file_name); 139 file_name = base::i18n::GetDisplayStringInLTRDirectionality(file_name);
140 file_value->SetString("file_name", file_name); 140 file_value->SetString("file_name", file_name);
141 file_value->SetString("url", download_item->GetURL().spec()); 141 file_value->SetString("url", download_item->GetURL().spec());
142 file_value->SetBoolean("otr", incognito); 142 file_value->SetBoolean("otr", incognito);
143 file_value->SetInteger("total", static_cast<int>( 143 file_value->SetInteger("total", static_cast<int>(
144 download_item->GetTotalBytes())); 144 download_item->GetTotalBytes()));
145 file_value->SetBoolean("file_externally_removed", 145 file_value->SetBoolean("file_externally_removed",
146 download_item->GetFileExternallyRemoved()); 146 download_item->GetFileExternallyRemoved());
147 file_value->SetBoolean("retry", false); // Overridden below if needed. 147 file_value->SetBoolean("retry", false); // Overridden below if needed.
148 file_value->SetBoolean("resume", download_item->CanResume());
148 149
149 if (download_item->IsInProgress()) { 150 if (download_item->IsInProgress()) {
150 if (download_item->IsDangerous()) { 151 if (download_item->IsDangerous()) {
151 file_value->SetString("state", "DANGEROUS"); 152 file_value->SetString("state", "DANGEROUS");
152 // These are the only danger states that the UI is equipped to handle. 153 // These are the only danger states that the UI is equipped to handle.
153 DCHECK(download_item->GetDangerType() == 154 DCHECK(download_item->GetDangerType() ==
154 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE || 155 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE ||
155 download_item->GetDangerType() == 156 download_item->GetDangerType() ==
156 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL || 157 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL ||
157 download_item->GetDangerType() == 158 download_item->GetDangerType() ==
(...skipping 24 matching lines...) Expand all
182 file_value->SetString("progress_status_text", 183 file_value->SetString("progress_status_text",
183 download_util::GetProgressStatusText(download_item)); 184 download_util::GetProgressStatusText(download_item));
184 185
185 file_value->SetInteger("percent", 186 file_value->SetInteger("percent",
186 static_cast<int>(download_item->PercentComplete())); 187 static_cast<int>(download_item->PercentComplete()));
187 file_value->SetInteger("received", 188 file_value->SetInteger("received",
188 static_cast<int>(download_item->GetReceivedBytes())); 189 static_cast<int>(download_item->GetReceivedBytes()));
189 file_value->SetString("last_reason_text", 190 file_value->SetString("last_reason_text",
190 download_model.GetInterruptReasonText()); 191 download_model.GetInterruptReasonText());
191 if (content::DOWNLOAD_INTERRUPT_REASON_CRASH == 192 if (content::DOWNLOAD_INTERRUPT_REASON_CRASH ==
192 download_item->GetLastReason()) 193 download_item->GetLastReason() && !download_item->CanResume())
193 file_value->SetBoolean("retry", true); 194 file_value->SetBoolean("retry", true);
194 } else if (download_item->IsCancelled()) { 195 } else if (download_item->IsCancelled()) {
195 file_value->SetString("state", "CANCELLED"); 196 file_value->SetString("state", "CANCELLED");
196 file_value->SetBoolean("retry", true); 197 file_value->SetBoolean("retry", true);
197 } else if (download_item->IsComplete()) { 198 } else if (download_item->IsComplete()) {
198 DCHECK(!download_item->IsDangerous()); 199 DCHECK(!download_item->IsDangerous());
199 file_value->SetString("state", "COMPLETE"); 200 file_value->SetString("state", "COMPLETE");
200 } else { 201 } else {
201 NOTREACHED() << "state undefined"; 202 NOTREACHED() << "state undefined";
202 } 203 }
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 } 542 }
542 543
543 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { 544 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) {
544 web_ui()->CallJavascriptFunction("downloadsList", downloads); 545 web_ui()->CallJavascriptFunction("downloadsList", downloads);
545 } 546 }
546 547
547 void DownloadsDOMHandler::CallDownloadUpdated( 548 void DownloadsDOMHandler::CallDownloadUpdated(
548 const base::ListValue& download_item) { 549 const base::ListValue& download_item) {
549 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); 550 web_ui()->CallJavascriptFunction("downloadUpdated", download_item);
550 } 551 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/downloads/downloads.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698