| 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 | 11 |
| 12 DownloadRequestInfoBarDelegate::FakeCreateCallback* | 12 DownloadRequestInfoBarDelegate::FakeCreateCallback* |
| 13 DownloadRequestInfoBarDelegate::callback_ = NULL; | 13 DownloadRequestInfoBarDelegate::callback_ = NULL; |
| 14 | 14 |
| 15 DownloadRequestInfoBarDelegate::~DownloadRequestInfoBarDelegate() { | 15 DownloadRequestInfoBarDelegate::~DownloadRequestInfoBarDelegate() { |
| 16 if (host_) | 16 if (host_.get()) |
| 17 host_->Cancel(); | 17 host_->Cancel(); |
| 18 } | 18 } |
| 19 | 19 |
| 20 // static | 20 // static |
| 21 void DownloadRequestInfoBarDelegate::Create( | 21 void DownloadRequestInfoBarDelegate::Create( |
| 22 InfoBarService* infobar_service, | 22 InfoBarService* infobar_service, |
| 23 base::WeakPtr<DownloadRequestLimiter::TabDownloadState> host) { | 23 base::WeakPtr<DownloadRequestLimiter::TabDownloadState> host) { |
| 24 if (DownloadRequestInfoBarDelegate::callback_ && | 24 if (DownloadRequestInfoBarDelegate::callback_ && |
| 25 !DownloadRequestInfoBarDelegate::callback_->is_null()) { | 25 !DownloadRequestInfoBarDelegate::callback_->is_null()) { |
| 26 DownloadRequestInfoBarDelegate::callback_->Run(infobar_service, host); | 26 DownloadRequestInfoBarDelegate::callback_->Run(infobar_service, host); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING); | 61 return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING); |
| 62 } | 62 } |
| 63 | 63 |
| 64 string16 DownloadRequestInfoBarDelegate::GetButtonLabel( | 64 string16 DownloadRequestInfoBarDelegate::GetButtonLabel( |
| 65 InfoBarButton button) const { | 65 InfoBarButton button) const { |
| 66 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 66 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
| 67 IDS_MULTI_DOWNLOAD_WARNING_ALLOW : IDS_MULTI_DOWNLOAD_WARNING_DENY); | 67 IDS_MULTI_DOWNLOAD_WARNING_ALLOW : IDS_MULTI_DOWNLOAD_WARNING_DENY); |
| 68 } | 68 } |
| 69 | 69 |
| 70 bool DownloadRequestInfoBarDelegate::Accept() { | 70 bool DownloadRequestInfoBarDelegate::Accept() { |
| 71 if (host_) { | 71 if (host_.get()) { |
| 72 // Accept() call will invalidate host_ weak pointer if no further | 72 // Accept() call will invalidate host_ weak pointer if no further |
| 73 // prompts are required. | 73 // prompts are required. |
| 74 host_->Accept(); | 74 host_->Accept(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 return !host_; | 77 return !host_.get(); |
| 78 } | 78 } |
| OLD | NEW |