| 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" |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 void DownloadsListTracker::SetChunkSizeForTesting(size_t chunk_size) { | 333 void DownloadsListTracker::SetChunkSizeForTesting(size_t chunk_size) { |
| 334 CHECK_EQ(0u, sent_to_page_); | 334 CHECK_EQ(0u, sent_to_page_); |
| 335 chunk_size_ = chunk_size; | 335 chunk_size_ = chunk_size; |
| 336 } | 336 } |
| 337 | 337 |
| 338 bool DownloadsListTracker::ShouldShow(const DownloadItem& item) const { | 338 bool DownloadsListTracker::ShouldShow(const DownloadItem& item) const { |
| 339 return !download_crx_util::IsExtensionDownload(item) && | 339 return !download_crx_util::IsExtensionDownload(item) && |
| 340 !item.IsTemporary() && | 340 !item.IsTemporary() && |
| 341 !item.GetFileNameToReportUser().empty() && | 341 !item.GetFileNameToReportUser().empty() && |
| 342 !item.GetTargetFilePath().empty() && | 342 !item.GetTargetFilePath().empty() && |
| 343 !item.GetURL().is_empty() && |
| 343 DownloadItemModel(const_cast<DownloadItem*>(&item)).ShouldShowInShelf() && | 344 DownloadItemModel(const_cast<DownloadItem*>(&item)).ShouldShowInShelf() && |
| 344 DownloadQuery::MatchesQuery(search_terms_, item); | 345 DownloadQuery::MatchesQuery(search_terms_, item); |
| 345 } | 346 } |
| 346 | 347 |
| 347 bool DownloadsListTracker::StartTimeComparator::operator() ( | 348 bool DownloadsListTracker::StartTimeComparator::operator() ( |
| 348 const content::DownloadItem* a, const content::DownloadItem* b) const { | 349 const content::DownloadItem* a, const content::DownloadItem* b) const { |
| 349 return a->GetStartTime() > b->GetStartTime(); | 350 return a->GetStartTime() > b->GetStartTime(); |
| 350 } | 351 } |
| 351 | 352 |
| 352 void DownloadsListTracker::Init() { | 353 void DownloadsListTracker::Init() { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 size_t index = GetIndex(remove); | 416 size_t index = GetIndex(remove); |
| 416 if (index < sent_to_page_) { | 417 if (index < sent_to_page_) { |
| 417 web_ui_->CallJavascriptFunctionUnsafe( | 418 web_ui_->CallJavascriptFunctionUnsafe( |
| 418 "downloads.Manager.removeItem", | 419 "downloads.Manager.removeItem", |
| 419 base::FundamentalValue(static_cast<int>(index))); | 420 base::FundamentalValue(static_cast<int>(index))); |
| 420 sent_to_page_--; | 421 sent_to_page_--; |
| 421 } | 422 } |
| 422 } | 423 } |
| 423 sorted_items_.erase(remove); | 424 sorted_items_.erase(remove); |
| 424 } | 425 } |
| OLD | NEW |