| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/dom_ui/downloads_dom_handler.h" | 5 #include "chrome/browser/dom_ui/downloads_dom_handler.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/i18n/time_formatting.h" | 9 #include "base/i18n/time_formatting.h" |
| 10 #include "base/string_piece.h" | 10 #include "base/string_piece.h" |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 216 |
| 217 // DownloadsDOMHandler, private: ---------------------------------------------- | 217 // DownloadsDOMHandler, private: ---------------------------------------------- |
| 218 | 218 |
| 219 void DownloadsDOMHandler::SendCurrentDownloads() { | 219 void DownloadsDOMHandler::SendCurrentDownloads() { |
| 220 ListValue results_value; | 220 ListValue results_value; |
| 221 for (OrderedDownloads::iterator it = download_items_.begin(); | 221 for (OrderedDownloads::iterator it = download_items_.begin(); |
| 222 it != download_items_.end(); ++it) { | 222 it != download_items_.end(); ++it) { |
| 223 int index = static_cast<int>(it - download_items_.begin()); | 223 int index = static_cast<int>(it - download_items_.begin()); |
| 224 if (index > kMaxDownloads) | 224 if (index > kMaxDownloads) |
| 225 break; | 225 break; |
| 226 results_value.Append(CreateDownloadItemValue(*it,index)); | 226 results_value.Append(CreateDownloadItemValue(*it, index)); |
| 227 } | 227 } |
| 228 | 228 |
| 229 dom_ui_->CallJavascriptFunction(L"downloadsList", results_value); | 229 dom_ui_->CallJavascriptFunction(L"downloadsList", results_value); |
| 230 } | 230 } |
| 231 | 231 |
| 232 DictionaryValue* DownloadsDOMHandler::CreateDownloadItemValue( | 232 DictionaryValue* DownloadsDOMHandler::CreateDownloadItemValue( |
| 233 DownloadItem* download, int id) { | 233 DownloadItem* download, int id) { |
| 234 DictionaryValue* file_value = new DictionaryValue(); | 234 DictionaryValue* file_value = new DictionaryValue(); |
| 235 | 235 |
| 236 file_value->SetInteger(L"started", | 236 file_value->SetInteger(L"started", |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 else if (download->TimeRemaining(&remaining)) | 353 else if (download->TimeRemaining(&remaining)) |
| 354 time_remaining = TimeFormat::TimeRemaining(remaining); | 354 time_remaining = TimeFormat::TimeRemaining(remaining); |
| 355 | 355 |
| 356 if (time_remaining.empty()) { | 356 if (time_remaining.empty()) { |
| 357 return l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_STATUS_TIME_UNKNOWN, | 357 return l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_STATUS_TIME_UNKNOWN, |
| 358 speed_text, amount); | 358 speed_text, amount); |
| 359 } | 359 } |
| 360 return l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_STATUS, speed_text, | 360 return l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_STATUS, speed_text, |
| 361 amount, time_remaining); | 361 amount, time_remaining); |
| 362 } | 362 } |
| OLD | NEW |