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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS); | 365 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS); |
366 content::DownloadItem* file = GetDownloadByValue(args); | 366 content::DownloadItem* file = GetDownloadByValue(args); |
367 if (file) | 367 if (file) |
368 ShowDangerPrompt(file); | 368 ShowDangerPrompt(file); |
369 } | 369 } |
370 | 370 |
371 void DownloadsDOMHandler::HandleDiscardDangerous(const base::ListValue* args) { | 371 void DownloadsDOMHandler::HandleDiscardDangerous(const base::ListValue* args) { |
372 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_DISCARD_DANGEROUS); | 372 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_DISCARD_DANGEROUS); |
373 content::DownloadItem* file = GetDownloadByValue(args); | 373 content::DownloadItem* file = GetDownloadByValue(args); |
374 if (file) | 374 if (file) |
375 file->Delete(content::DownloadItem::DELETE_DUE_TO_USER_DISCARD); | 375 file->DiscardDangerousDownload( |
| 376 content::DownloadItem::DELETE_DUE_TO_USER_DISCARD, |
| 377 content::DownloadItem::AcquireFileCallback()); |
376 } | 378 } |
377 | 379 |
378 void DownloadsDOMHandler::HandleShow(const base::ListValue* args) { | 380 void DownloadsDOMHandler::HandleShow(const base::ListValue* args) { |
379 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SHOW); | 381 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SHOW); |
380 content::DownloadItem* file = GetDownloadByValue(args); | 382 content::DownloadItem* file = GetDownloadByValue(args); |
381 if (file) | 383 if (file) |
382 file->ShowDownloadInShell(); | 384 file->ShowDownloadInShell(); |
383 } | 385 } |
384 | 386 |
385 void DownloadsDOMHandler::HandlePause(const base::ListValue* args) { | 387 void DownloadsDOMHandler::HandlePause(const base::ListValue* args) { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 | 508 |
507 void DownloadsDOMHandler::DangerPromptAccepted(int download_id) { | 509 void DownloadsDOMHandler::DangerPromptAccepted(int download_id) { |
508 content::DownloadItem* item = NULL; | 510 content::DownloadItem* item = NULL; |
509 if (main_notifier_.GetManager()) | 511 if (main_notifier_.GetManager()) |
510 item = main_notifier_.GetManager()->GetDownload(download_id); | 512 item = main_notifier_.GetManager()->GetDownload(download_id); |
511 if (!item && original_notifier_.get() && original_notifier_->GetManager()) | 513 if (!item && original_notifier_.get() && original_notifier_->GetManager()) |
512 item = original_notifier_->GetManager()->GetDownload(download_id); | 514 item = original_notifier_->GetManager()->GetDownload(download_id); |
513 if (!item || (item->GetState() != content::DownloadItem::IN_PROGRESS)) | 515 if (!item || (item->GetState() != content::DownloadItem::IN_PROGRESS)) |
514 return; | 516 return; |
515 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS); | 517 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS); |
516 item->DangerousDownloadValidated(); | 518 item->ValidateDangerousDownload(); |
517 } | 519 } |
518 | 520 |
519 bool DownloadsDOMHandler::IsDeletingHistoryAllowed() { | 521 bool DownloadsDOMHandler::IsDeletingHistoryAllowed() { |
520 content::DownloadManager* manager = main_notifier_.GetManager(); | 522 content::DownloadManager* manager = main_notifier_.GetManager(); |
521 return (manager && | 523 return (manager && |
522 Profile::FromBrowserContext(manager->GetBrowserContext())-> | 524 Profile::FromBrowserContext(manager->GetBrowserContext())-> |
523 GetPrefs()->GetBoolean(prefs::kAllowDeletingBrowserHistory)); | 525 GetPrefs()->GetBoolean(prefs::kAllowDeletingBrowserHistory)); |
524 } | 526 } |
525 | 527 |
526 content::DownloadItem* DownloadsDOMHandler::GetDownloadByValue( | 528 content::DownloadItem* DownloadsDOMHandler::GetDownloadByValue( |
(...skipping 14 matching lines...) Expand all Loading... |
541 } | 543 } |
542 | 544 |
543 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { | 545 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { |
544 web_ui()->CallJavascriptFunction("downloadsList", downloads); | 546 web_ui()->CallJavascriptFunction("downloadsList", downloads); |
545 } | 547 } |
546 | 548 |
547 void DownloadsDOMHandler::CallDownloadUpdated( | 549 void DownloadsDOMHandler::CallDownloadUpdated( |
548 const base::ListValue& download_item) { | 550 const base::ListValue& download_item) { |
549 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); | 551 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); |
550 } | 552 } |
OLD | NEW |