| 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_request_infobar_delegate.h" | 5 #include "chrome/browser/download/download_request_infobar_delegate.h" |
| 6 | 6 |
| 7 #include "chrome/browser/infobars/infobar_service.h" | 7 #include "chrome/browser/infobars/infobar_service.h" |
| 8 #include "grit/generated_resources.h" | 8 #include "grit/generated_resources.h" |
| 9 #include "grit/theme_resources.h" | 9 #include "grit/theme_resources.h" |
| 10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 base::WeakPtr<DownloadRequestLimiter::TabDownloadState> host) | 51 base::WeakPtr<DownloadRequestLimiter::TabDownloadState> host) |
| 52 : ConfirmInfoBarDelegate(infobar_service), | 52 : ConfirmInfoBarDelegate(infobar_service), |
| 53 responded_(false), | 53 responded_(false), |
| 54 host_(host) { | 54 host_(host) { |
| 55 } | 55 } |
| 56 | 56 |
| 57 int DownloadRequestInfoBarDelegate::GetIconID() const { | 57 int DownloadRequestInfoBarDelegate::GetIconID() const { |
| 58 return IDR_INFOBAR_MULTIPLE_DOWNLOADS; | 58 return IDR_INFOBAR_MULTIPLE_DOWNLOADS; |
| 59 } | 59 } |
| 60 | 60 |
| 61 string16 DownloadRequestInfoBarDelegate::GetMessageText() const { | 61 base::string16 DownloadRequestInfoBarDelegate::GetMessageText() const { |
| 62 return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING); | 62 return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING); |
| 63 } | 63 } |
| 64 | 64 |
| 65 string16 DownloadRequestInfoBarDelegate::GetButtonLabel( | 65 base::string16 DownloadRequestInfoBarDelegate::GetButtonLabel( |
| 66 InfoBarButton button) const { | 66 InfoBarButton button) const { |
| 67 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 67 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
| 68 IDS_MULTI_DOWNLOAD_WARNING_ALLOW : IDS_MULTI_DOWNLOAD_WARNING_DENY); | 68 IDS_MULTI_DOWNLOAD_WARNING_ALLOW : IDS_MULTI_DOWNLOAD_WARNING_DENY); |
| 69 } | 69 } |
| 70 | 70 |
| 71 bool DownloadRequestInfoBarDelegate::Accept() { | 71 bool DownloadRequestInfoBarDelegate::Accept() { |
| 72 DCHECK(!responded_); | 72 DCHECK(!responded_); |
| 73 responded_ = true; | 73 responded_ = true; |
| 74 if (host_) { | 74 if (host_) { |
| 75 // This may invalidate |host_|. | 75 // This may invalidate |host_|. |
| 76 host_->Accept(); | 76 host_->Accept(); |
| 77 } | 77 } |
| 78 return !host_; | 78 return !host_; |
| 79 } | 79 } |
| 80 | 80 |
| 81 bool DownloadRequestInfoBarDelegate::Cancel() { | 81 bool DownloadRequestInfoBarDelegate::Cancel() { |
| 82 DCHECK(!responded_); | 82 DCHECK(!responded_); |
| 83 responded_ = true; | 83 responded_ = true; |
| 84 if (host_) { | 84 if (host_) { |
| 85 // This may invalidate |host_|. | 85 // This may invalidate |host_|. |
| 86 host_->Cancel(); | 86 host_->Cancel(); |
| 87 } | 87 } |
| 88 return !host_; | 88 return !host_; |
| 89 } | 89 } |
| OLD | NEW |