| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/md_downloads/downloads_list_tracker.h" | 5 #include "chrome/browser/ui/webui/md_downloads/downloads_list_tracker.h" |
| 6 | 6 |
| 7 #include <iterator> | 7 #include <iterator> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
| 12 #include "base/i18n/unicodestring.h" |
| 12 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 15 #include "base/value_conversions.h" | 16 #include "base/value_conversions.h" |
| 16 #include "base/values.h" | 17 #include "base/values.h" |
| 17 #include "chrome/browser/download/all_download_item_notifier.h" | 18 #include "chrome/browser/download/all_download_item_notifier.h" |
| 18 #include "chrome/browser/download/download_crx_util.h" | 19 #include "chrome/browser/download/download_crx_util.h" |
| 19 #include "chrome/browser/download/download_item_model.h" | 20 #include "chrome/browser/download/download_item_model.h" |
| 20 #include "chrome/browser/download/download_query.h" | 21 #include "chrome/browser/download/download_query.h" |
| 21 #include "chrome/browser/extensions/api/downloads/downloads_api.h" | 22 #include "chrome/browser/extensions/api/downloads/downloads_api.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 NOTREACHED(); | 68 NOTREACHED(); |
| 68 return ""; | 69 return ""; |
| 69 } | 70 } |
| 70 | 71 |
| 71 // TODO(dbeam): if useful elsewhere, move to base/i18n/time_formatting.h? | 72 // TODO(dbeam): if useful elsewhere, move to base/i18n/time_formatting.h? |
| 72 base::string16 TimeFormatLongDate(const base::Time& time) { | 73 base::string16 TimeFormatLongDate(const base::Time& time) { |
| 73 std::unique_ptr<icu::DateFormat> formatter( | 74 std::unique_ptr<icu::DateFormat> formatter( |
| 74 icu::DateFormat::createDateInstance(icu::DateFormat::kLong)); | 75 icu::DateFormat::createDateInstance(icu::DateFormat::kLong)); |
| 75 icu::UnicodeString date_string; | 76 icu::UnicodeString date_string; |
| 76 formatter->format(static_cast<UDate>(time.ToDoubleT() * 1000), date_string); | 77 formatter->format(static_cast<UDate>(time.ToDoubleT() * 1000), date_string); |
| 77 return base::string16(date_string.getBuffer(), | 78 return base::i18n::UnicodeStringToString16(date_string); |
| 78 static_cast<size_t>(date_string.length())); | |
| 79 } | 79 } |
| 80 | 80 |
| 81 } // namespace | 81 } // namespace |
| 82 | 82 |
| 83 DownloadsListTracker::DownloadsListTracker( | 83 DownloadsListTracker::DownloadsListTracker( |
| 84 DownloadManager* download_manager, | 84 DownloadManager* download_manager, |
| 85 content::WebUI* web_ui) | 85 content::WebUI* web_ui) |
| 86 : main_notifier_(download_manager, this), | 86 : main_notifier_(download_manager, this), |
| 87 web_ui_(web_ui), | 87 web_ui_(web_ui), |
| 88 should_show_(base::Bind(&DownloadsListTracker::ShouldShow, | 88 should_show_(base::Bind(&DownloadsListTracker::ShouldShow, |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 if (sending_updates_) { | 415 if (sending_updates_) { |
| 416 size_t index = GetIndex(remove); | 416 size_t index = GetIndex(remove); |
| 417 if (index < sent_to_page_) { | 417 if (index < sent_to_page_) { |
| 418 web_ui_->CallJavascriptFunctionUnsafe( | 418 web_ui_->CallJavascriptFunctionUnsafe( |
| 419 "downloads.Manager.removeItem", base::Value(static_cast<int>(index))); | 419 "downloads.Manager.removeItem", base::Value(static_cast<int>(index))); |
| 420 sent_to_page_--; | 420 sent_to_page_--; |
| 421 } | 421 } |
| 422 } | 422 } |
| 423 sorted_items_.erase(remove); | 423 sorted_items_.erase(remove); |
| 424 } | 424 } |
| OLD | NEW |