OLD | NEW |
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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 main_notifier_.GetManager()->GetAllDownloads(&downloads); | 536 main_notifier_.GetManager()->GetAllDownloads(&downloads); |
537 if (original_notifier_ && original_notifier_->GetManager()) | 537 if (original_notifier_ && original_notifier_->GetManager()) |
538 original_notifier_->GetManager()->GetAllDownloads(&downloads); | 538 original_notifier_->GetManager()->GetAllDownloads(&downloads); |
539 RemoveDownloads(downloads); | 539 RemoveDownloads(downloads); |
540 } | 540 } |
541 | 541 |
542 void DownloadsDOMHandler::RemoveDownloads( | 542 void DownloadsDOMHandler::RemoveDownloads( |
543 const std::vector<content::DownloadItem*>& to_remove) { | 543 const std::vector<content::DownloadItem*>& to_remove) { |
544 std::set<uint32> ids; | 544 std::set<uint32> ids; |
545 for (auto* download : to_remove) { | 545 for (auto* download : to_remove) { |
546 if (IsRemoved(*download)) | 546 if (IsRemoved(*download) || |
| 547 download->GetState() == content::DownloadItem::IN_PROGRESS) { |
547 continue; | 548 continue; |
| 549 } |
548 | 550 |
549 DownloadsDOMHandlerData::Create(download)->set_is_removed(true); | 551 DownloadsDOMHandlerData::Create(download)->set_is_removed(true); |
550 ids.insert(download->GetId()); | 552 ids.insert(download->GetId()); |
551 download->UpdateObservers(); | 553 download->UpdateObservers(); |
552 } | 554 } |
553 removes_.push_back(ids); | 555 removes_.push_back(ids); |
554 } | 556 } |
555 | 557 |
556 void DownloadsDOMHandler::HandleOpenDownloadsFolder( | 558 void DownloadsDOMHandler::HandleOpenDownloadsFolder( |
557 const base::ListValue* args) { | 559 const base::ListValue* args) { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 } | 678 } |
677 | 679 |
678 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { | 680 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { |
679 web_ui()->CallJavascriptFunction("downloadsList", downloads); | 681 web_ui()->CallJavascriptFunction("downloadsList", downloads); |
680 } | 682 } |
681 | 683 |
682 void DownloadsDOMHandler::CallDownloadUpdated( | 684 void DownloadsDOMHandler::CallDownloadUpdated( |
683 const base::ListValue& download_item) { | 685 const base::ListValue& download_item) { |
684 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); | 686 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); |
685 } | 687 } |
OLD | NEW |