| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "chrome/browser/tab_contents/tab_contents.h" | 9 #include "chrome/browser/tab_contents/tab_contents.h" |
| 10 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
| 11 #include "grit/theme_resources.h" | 11 #include "grit/theme_resources.h" |
| 12 | 12 |
| 13 DownloadRequestInfoBarDelegate::DownloadRequestInfoBarDelegate(TabContents* tab, | 13 DownloadRequestInfoBarDelegate::DownloadRequestInfoBarDelegate( |
| 14 TabContents* tab, |
| 14 DownloadRequestLimiter::TabDownloadState* host) | 15 DownloadRequestLimiter::TabDownloadState* host) |
| 15 : ConfirmInfoBarDelegate(tab), | 16 : ConfirmInfoBarDelegate(tab), |
| 16 host_(host) { | 17 host_(host) { |
| 17 if (tab) | 18 if (tab) |
| 18 tab->AddInfoBar(this); | 19 tab->AddInfoBar(this); |
| 19 } | 20 } |
| 20 | 21 |
| 21 DownloadRequestInfoBarDelegate::~DownloadRequestInfoBarDelegate() { | 22 DownloadRequestInfoBarDelegate::~DownloadRequestInfoBarDelegate() { |
| 22 } | 23 } |
| 23 | 24 |
| 24 void DownloadRequestInfoBarDelegate::InfoBarClosed() { | 25 void DownloadRequestInfoBarDelegate::InfoBarClosed() { |
| 25 Cancel(); | 26 Cancel(); |
| 26 // This will delete us. | 27 // This will delete us. |
| 27 ConfirmInfoBarDelegate::InfoBarClosed(); | 28 ConfirmInfoBarDelegate::InfoBarClosed(); |
| 28 } | 29 } |
| 29 | 30 |
| 30 string16 DownloadRequestInfoBarDelegate::GetMessageText() const { | |
| 31 return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING); | |
| 32 } | |
| 33 | |
| 34 SkBitmap* DownloadRequestInfoBarDelegate::GetIcon() const { | 31 SkBitmap* DownloadRequestInfoBarDelegate::GetIcon() const { |
| 35 return ResourceBundle::GetSharedInstance().GetBitmapNamed( | 32 return ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 36 IDR_INFOBAR_MULTIPLE_DOWNLOADS); | 33 IDR_INFOBAR_MULTIPLE_DOWNLOADS); |
| 37 } | 34 } |
| 38 | 35 |
| 36 string16 DownloadRequestInfoBarDelegate::GetMessageText() const { |
| 37 return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING); |
| 38 } |
| 39 |
| 39 int DownloadRequestInfoBarDelegate::GetButtons() const { | 40 int DownloadRequestInfoBarDelegate::GetButtons() const { |
| 40 return BUTTON_OK | BUTTON_CANCEL; | 41 return BUTTON_OK | BUTTON_CANCEL; |
| 41 } | 42 } |
| 42 | 43 |
| 43 string16 DownloadRequestInfoBarDelegate::GetButtonLabel( | 44 string16 DownloadRequestInfoBarDelegate::GetButtonLabel( |
| 44 ConfirmInfoBarDelegate::InfoBarButton button) const { | 45 InfoBarButton button) const { |
| 45 if (button == BUTTON_OK) | 46 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
| 46 return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING_ALLOW); | 47 IDS_MULTI_DOWNLOAD_WARNING_ALLOW : IDS_MULTI_DOWNLOAD_WARNING_DENY); |
| 47 else | |
| 48 return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING_DENY); | |
| 49 } | 48 } |
| 50 | 49 |
| 51 bool DownloadRequestInfoBarDelegate::Accept() { | 50 bool DownloadRequestInfoBarDelegate::Accept() { |
| 52 if (host_) { | 51 if (host_) { |
| 53 // Accept() call will nullify host_ if no further prompts are required. | 52 // Accept() call will nullify host_ if no further prompts are required. |
| 54 host_->Accept(); | 53 host_->Accept(); |
| 55 } | 54 } |
| 56 | 55 |
| 57 return !host_; | 56 return !host_; |
| 58 } | 57 } |
| 59 | 58 |
| 60 bool DownloadRequestInfoBarDelegate::Cancel() { | 59 bool DownloadRequestInfoBarDelegate::Cancel() { |
| 61 if (host_) { | 60 if (host_) { |
| 62 host_->Cancel(); | 61 host_->Cancel(); |
| 63 host_ = NULL; | 62 host_ = NULL; |
| 64 } | 63 } |
| 65 return true; | 64 return true; |
| 66 } | 65 } |
| OLD | NEW |