| 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" |
| 11 #include "ui/base/resource/resource_bundle.h" | |
| 12 | 11 |
| 13 DownloadRequestInfoBarDelegate::FakeCreateCallback* | 12 DownloadRequestInfoBarDelegate::FakeCreateCallback* |
| 14 DownloadRequestInfoBarDelegate::callback_ = NULL; | 13 DownloadRequestInfoBarDelegate::callback_ = NULL; |
| 15 | 14 |
| 16 DownloadRequestInfoBarDelegate::~DownloadRequestInfoBarDelegate() { | 15 DownloadRequestInfoBarDelegate::~DownloadRequestInfoBarDelegate() { |
| 17 if (host_) | 16 if (host_) |
| 18 host_->Cancel(); | 17 host_->Cancel(); |
| 19 } | 18 } |
| 20 | 19 |
| 21 // static | 20 // static |
| (...skipping 25 matching lines...) Expand all Loading... |
| 47 DownloadRequestInfoBarDelegate::callback_ = callback; | 46 DownloadRequestInfoBarDelegate::callback_ = callback; |
| 48 } | 47 } |
| 49 | 48 |
| 50 DownloadRequestInfoBarDelegate::DownloadRequestInfoBarDelegate( | 49 DownloadRequestInfoBarDelegate::DownloadRequestInfoBarDelegate( |
| 51 InfoBarService* infobar_service, | 50 InfoBarService* infobar_service, |
| 52 base::WeakPtr<DownloadRequestLimiter::TabDownloadState> host) | 51 base::WeakPtr<DownloadRequestLimiter::TabDownloadState> host) |
| 53 : ConfirmInfoBarDelegate(infobar_service), | 52 : ConfirmInfoBarDelegate(infobar_service), |
| 54 host_(host) { | 53 host_(host) { |
| 55 } | 54 } |
| 56 | 55 |
| 57 gfx::Image* DownloadRequestInfoBarDelegate::GetIcon() const { | 56 int DownloadRequestInfoBarDelegate::GetIconID() const { |
| 58 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 57 return IDR_INFOBAR_MULTIPLE_DOWNLOADS; |
| 59 IDR_INFOBAR_MULTIPLE_DOWNLOADS); | |
| 60 } | 58 } |
| 61 | 59 |
| 62 string16 DownloadRequestInfoBarDelegate::GetMessageText() const { | 60 string16 DownloadRequestInfoBarDelegate::GetMessageText() const { |
| 63 return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING); | 61 return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING); |
| 64 } | 62 } |
| 65 | 63 |
| 66 string16 DownloadRequestInfoBarDelegate::GetButtonLabel( | 64 string16 DownloadRequestInfoBarDelegate::GetButtonLabel( |
| 67 InfoBarButton button) const { | 65 InfoBarButton button) const { |
| 68 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 66 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
| 69 IDS_MULTI_DOWNLOAD_WARNING_ALLOW : IDS_MULTI_DOWNLOAD_WARNING_DENY); | 67 IDS_MULTI_DOWNLOAD_WARNING_ALLOW : IDS_MULTI_DOWNLOAD_WARNING_DENY); |
| 70 } | 68 } |
| 71 | 69 |
| 72 bool DownloadRequestInfoBarDelegate::Accept() { | 70 bool DownloadRequestInfoBarDelegate::Accept() { |
| 73 if (host_) { | 71 if (host_) { |
| 74 // Accept() call will invalidate host_ weak pointer if no further | 72 // Accept() call will invalidate host_ weak pointer if no further |
| 75 // prompts are required. | 73 // prompts are required. |
| 76 host_->Accept(); | 74 host_->Accept(); |
| 77 } | 75 } |
| 78 | 76 |
| 79 return !host_; | 77 return !host_; |
| 80 } | 78 } |
| OLD | NEW |