| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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_ui.h" | 5 #include "chrome/browser/dom_ui/downloads_ui.h" |
| 6 | 6 |
| 7 #include "base/gfx/png_encoder.h" | 7 #include "base/gfx/png_encoder.h" |
| 8 #include "base/string_piece.h" | 8 #include "base/string_piece.h" |
| 9 #include "base/thread.h" | 9 #include "base/thread.h" |
| 10 #include "base/time_format.h" | 10 #include "base/time_format.h" |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 std::wstring amount = received_size; | 468 std::wstring amount = received_size; |
| 469 | 469 |
| 470 // Adjust both strings for the locale direction since we don't yet know which | 470 // Adjust both strings for the locale direction since we don't yet know which |
| 471 // string we'll end up using for constructing the final progress string. | 471 // string we'll end up using for constructing the final progress string. |
| 472 std::wstring amount_localized; | 472 std::wstring amount_localized; |
| 473 if (l10n_util::AdjustStringForLocaleDirection(amount, &amount_localized)) { | 473 if (l10n_util::AdjustStringForLocaleDirection(amount, &amount_localized)) { |
| 474 amount.assign(amount_localized); | 474 amount.assign(amount_localized); |
| 475 received_size.assign(amount_localized); | 475 received_size.assign(amount_localized); |
| 476 } | 476 } |
| 477 | 477 |
| 478 amount_units = GetByteDisplayUnits(total); | 478 if (total) { |
| 479 std::wstring total_text = FormatBytes(total, amount_units, true); | 479 amount_units = GetByteDisplayUnits(total); |
| 480 std::wstring total_text_localized; | 480 std::wstring total_text = FormatBytes(total, amount_units, true); |
| 481 if (l10n_util::AdjustStringForLocaleDirection(total_text, | 481 std::wstring total_text_localized; |
| 482 &total_text_localized)) | 482 if (l10n_util::AdjustStringForLocaleDirection(total_text, |
| 483 total_text.assign(total_text_localized); | 483 &total_text_localized)) |
| 484 total_text.assign(total_text_localized); |
| 484 | 485 |
| 485 amount = l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_SIZE, | 486 amount = l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_SIZE, |
| 486 received_size, | 487 received_size, |
| 487 total_text); | 488 total_text); |
| 488 | 489 } else { |
| 490 amount.assign(received_size); |
| 491 } |
| 489 amount_units = GetByteDisplayUnits(download->CurrentSpeed()); | 492 amount_units = GetByteDisplayUnits(download->CurrentSpeed()); |
| 490 std::wstring speed_text = FormatSpeed(download->CurrentSpeed(), | 493 std::wstring speed_text = FormatSpeed(download->CurrentSpeed(), |
| 491 amount_units, true); | 494 amount_units, true); |
| 492 std::wstring speed_text_localized; | 495 std::wstring speed_text_localized; |
| 493 if (l10n_util::AdjustStringForLocaleDirection(speed_text, | 496 if (l10n_util::AdjustStringForLocaleDirection(speed_text, |
| 494 &speed_text_localized)) | 497 &speed_text_localized)) |
| 495 speed_text.assign(speed_text_localized); | 498 speed_text.assign(speed_text_localized); |
| 496 | 499 |
| 497 return l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_SPEED, | 500 return l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_SPEED, |
| 498 speed_text, | 501 speed_text, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 515 handler->Init(); | 518 handler->Init(); |
| 516 | 519 |
| 517 DownloadsUIHTMLSource* html_source = new DownloadsUIHTMLSource(); | 520 DownloadsUIHTMLSource* html_source = new DownloadsUIHTMLSource(); |
| 518 | 521 |
| 519 // Set up the chrome-ui://downloads/ source. | 522 // Set up the chrome-ui://downloads/ source. |
| 520 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, | 523 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, |
| 521 NewRunnableMethod(&chrome_url_data_manager, | 524 NewRunnableMethod(&chrome_url_data_manager, |
| 522 &ChromeURLDataManager::AddDataSource, | 525 &ChromeURLDataManager::AddDataSource, |
| 523 html_source)); | 526 html_source)); |
| 524 } | 527 } |
| OLD | NEW |