| 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->Remove(); |
| 376 } | 376 } |
| 377 | 377 |
| 378 void DownloadsDOMHandler::HandleShow(const base::ListValue* args) { | 378 void DownloadsDOMHandler::HandleShow(const base::ListValue* args) { |
| 379 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SHOW); | 379 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SHOW); |
| 380 content::DownloadItem* file = GetDownloadByValue(args); | 380 content::DownloadItem* file = GetDownloadByValue(args); |
| 381 if (file) | 381 if (file) |
| 382 file->ShowDownloadInShell(); | 382 file->ShowDownloadInShell(); |
| 383 } | 383 } |
| 384 | 384 |
| 385 void DownloadsDOMHandler::HandlePause(const base::ListValue* args) { | 385 void DownloadsDOMHandler::HandlePause(const base::ListValue* args) { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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->GetState() != content::DownloadItem::IN_PROGRESS)) |
| 514 return; | 514 return; |
| 515 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS); | 515 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS); |
| 516 item->DangerousDownloadValidated(); | 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)); |
| 524 } | 524 } |
| 525 | 525 |
| 526 content::DownloadItem* DownloadsDOMHandler::GetDownloadByValue( | 526 content::DownloadItem* DownloadsDOMHandler::GetDownloadByValue( |
| (...skipping 14 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 |