Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: chrome/browser/download/download_request_infobar_delegate.cc

Issue 11644059: Change infobar creation to use a public static Create() method on the infobar delegate classes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/api/infobars/infobar_service.h" 7 #include "chrome/browser/api/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" 11 #include "ui/base/resource/resource_bundle.h"
12 12
13 DownloadRequestInfoBarDelegate::~DownloadRequestInfoBarDelegate() {
14 if (host_)
15 host_->Cancel();
16 }
17
18 // static
19 void DownloadRequestInfoBarDelegate::Create(
20 InfoBarService* infobar_service,
21 DownloadRequestLimiter::TabDownloadState* host) {
22 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
23 new DownloadRequestInfoBarDelegate(infobar_service, host)));
24 }
25
13 DownloadRequestInfoBarDelegate::DownloadRequestInfoBarDelegate( 26 DownloadRequestInfoBarDelegate::DownloadRequestInfoBarDelegate(
14 InfoBarService* infobar_service, 27 InfoBarService* infobar_service,
15 DownloadRequestLimiter::TabDownloadState* host) 28 DownloadRequestLimiter::TabDownloadState* host)
16 : ConfirmInfoBarDelegate(infobar_service), 29 : ConfirmInfoBarDelegate(infobar_service),
17 host_(host) { 30 host_(host) {
18 } 31 }
19 32
20 DownloadRequestInfoBarDelegate::~DownloadRequestInfoBarDelegate() {
21 if (host_)
22 host_->Cancel();
23 }
24
25 gfx::Image* DownloadRequestInfoBarDelegate::GetIcon() const { 33 gfx::Image* DownloadRequestInfoBarDelegate::GetIcon() const {
26 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( 34 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
27 IDR_INFOBAR_MULTIPLE_DOWNLOADS); 35 IDR_INFOBAR_MULTIPLE_DOWNLOADS);
28 } 36 }
29 37
30 string16 DownloadRequestInfoBarDelegate::GetMessageText() const { 38 string16 DownloadRequestInfoBarDelegate::GetMessageText() const {
31 return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING); 39 return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING);
32 } 40 }
33 41
34 string16 DownloadRequestInfoBarDelegate::GetButtonLabel( 42 string16 DownloadRequestInfoBarDelegate::GetButtonLabel(
35 InfoBarButton button) const { 43 InfoBarButton button) const {
36 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? 44 return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
37 IDS_MULTI_DOWNLOAD_WARNING_ALLOW : IDS_MULTI_DOWNLOAD_WARNING_DENY); 45 IDS_MULTI_DOWNLOAD_WARNING_ALLOW : IDS_MULTI_DOWNLOAD_WARNING_DENY);
38 } 46 }
39 47
40 bool DownloadRequestInfoBarDelegate::Accept() { 48 bool DownloadRequestInfoBarDelegate::Accept() {
41 if (host_) { 49 if (host_) {
42 // Accept() call will nullify host_ if no further prompts are required. 50 // Accept() call will nullify host_ if no further prompts are required.
43 host_->Accept(); 51 host_->Accept();
44 } 52 }
45 53
46 return !host_; 54 return !host_;
47 } 55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698