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