| 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/download/download_danger_prompt.h" | 5 #include "chrome/browser/download/download_danger_prompt.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 8 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| 9 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" | 9 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" |
| 10 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" | 10 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 void DownloadDangerPromptImpl::InvokeActionForTesting(Action action) { | 87 void DownloadDangerPromptImpl::InvokeActionForTesting(Action action) { |
| 88 if (action == ACCEPT) | 88 if (action == ACCEPT) |
| 89 Accept(); | 89 Accept(); |
| 90 else | 90 else |
| 91 Cancel(); | 91 Cancel(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void DownloadDangerPromptImpl::OnDownloadUpdated( | 94 void DownloadDangerPromptImpl::OnDownloadUpdated( |
| 95 content::DownloadItem* download) { | 95 content::DownloadItem* download) { |
| 96 // If the download is nolonger dangerous (accepted externally) or the download | 96 // If the download is nolonger dangerous (accepted externally) or the download |
| 97 // doesn't exist anymore, the download danger prompt is no longer necessary. | 97 // is not going to complete, then the download danger prompt is no longer |
| 98 if ((download->GetState() != content::DownloadItem::IN_PROGRESS) | 98 // necessary. |
| 99 || !download->IsDangerous()) | 99 if (!download->IsDangerous() || !download->IsPartialDownload()) |
| 100 Cancel(); | 100 Cancel(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void DownloadDangerPromptImpl::OnDownloadOpened( | 103 void DownloadDangerPromptImpl::OnDownloadOpened( |
| 104 content::DownloadItem* download) { | 104 content::DownloadItem* download) { |
| 105 } | 105 } |
| 106 | 106 |
| 107 string16 DownloadDangerPromptImpl::GetTitle() { | 107 string16 DownloadDangerPromptImpl::GetTitle() { |
| 108 return l10n_util::GetStringUTF16(IDS_CONFIRM_KEEP_DANGEROUS_DOWNLOAD_TITLE); | 108 return l10n_util::GetStringUTF16(IDS_CONFIRM_KEEP_DANGEROUS_DOWNLOAD_TITLE); |
| 109 } | 109 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 content::WebContents* web_contents, | 173 content::WebContents* web_contents, |
| 174 bool show_context, | 174 bool show_context, |
| 175 const base::Closure& accepted, | 175 const base::Closure& accepted, |
| 176 const base::Closure& canceled) { | 176 const base::Closure& canceled) { |
| 177 DownloadDangerPromptImpl* prompt = new DownloadDangerPromptImpl( | 177 DownloadDangerPromptImpl* prompt = new DownloadDangerPromptImpl( |
| 178 item, web_contents, show_context, accepted, canceled); | 178 item, web_contents, show_context, accepted, canceled); |
| 179 // |prompt| will be deleted when the dialog is done. | 179 // |prompt| will be deleted when the dialog is done. |
| 180 TabModalConfirmDialog::Create(prompt, web_contents); | 180 TabModalConfirmDialog::Create(prompt, web_contents); |
| 181 return prompt; | 181 return prompt; |
| 182 } | 182 } |
| OLD | NEW |