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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 // danger_prompt will delete itself. | 503 // danger_prompt will delete itself. |
504 DCHECK(danger_prompt); | 504 DCHECK(danger_prompt); |
505 } | 505 } |
506 | 506 |
507 void DownloadsDOMHandler::DangerPromptAccepted(int download_id) { | 507 void DownloadsDOMHandler::DangerPromptAccepted(int download_id) { |
508 content::DownloadItem* item = NULL; | 508 content::DownloadItem* item = NULL; |
509 if (main_notifier_.GetManager()) | 509 if (main_notifier_.GetManager()) |
510 item = main_notifier_.GetManager()->GetDownload(download_id); | 510 item = main_notifier_.GetManager()->GetDownload(download_id); |
511 if (!item && original_notifier_.get() && original_notifier_->GetManager()) | 511 if (!item && original_notifier_.get() && original_notifier_->GetManager()) |
512 item = original_notifier_->GetManager()->GetDownload(download_id); | 512 item = original_notifier_->GetManager()->GetDownload(download_id); |
513 if (!item || (item->GetState() != content::DownloadItem::IN_PROGRESS)) | 513 if (!item || item->IsDone()) |
514 return; | 514 return; |
515 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS); | 515 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS); |
516 item->ValidateDangerousDownload(); | 516 item->ValidateDangerousDownload(); |
517 } | 517 } |
518 | 518 |
519 bool DownloadsDOMHandler::IsDeletingHistoryAllowed() { | 519 bool DownloadsDOMHandler::IsDeletingHistoryAllowed() { |
520 content::DownloadManager* manager = main_notifier_.GetManager(); | 520 content::DownloadManager* manager = main_notifier_.GetManager(); |
521 return (manager && | 521 return (manager && |
522 Profile::FromBrowserContext(manager->GetBrowserContext())-> | 522 Profile::FromBrowserContext(manager->GetBrowserContext())-> |
523 GetPrefs()->GetBoolean(prefs::kAllowDeletingBrowserHistory)); | 523 GetPrefs()->GetBoolean(prefs::kAllowDeletingBrowserHistory)); |
(...skipping 17 matching lines...) Expand all Loading... |
541 } | 541 } |
542 | 542 |
543 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { | 543 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { |
544 web_ui()->CallJavascriptFunction("downloadsList", downloads); | 544 web_ui()->CallJavascriptFunction("downloadsList", downloads); |
545 } | 545 } |
546 | 546 |
547 void DownloadsDOMHandler::CallDownloadUpdated( | 547 void DownloadsDOMHandler::CallDownloadUpdated( |
548 const base::ListValue& download_item) { | 548 const base::ListValue& download_item) { |
549 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); | 549 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); |
550 } | 550 } |
OLD | NEW |