blob: e5dc325d4ca2850f19465786fb1d1eebaf1c396e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/download/download_request_infobar_delegate.h"
#include "chrome/browser/api/infobars/infobar_service.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
DownloadRequestInfoBarDelegate::~DownloadRequestInfoBarDelegate() {
if (host_)
host_->Cancel();
}
// static
void DownloadRequestInfoBarDelegate::Create(
InfoBarService* infobar_service,
base::WeakPtr<DownloadRequestLimiter::TabDownloadState> host) {
infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
new DownloadRequestInfoBarDelegate(infobar_service, host)));
}
DownloadRequestInfoBarDelegate::DownloadRequestInfoBarDelegate(
InfoBarService* infobar_service,
base::WeakPtr<DownloadRequestLimiter::TabDownloadState> host)
: ConfirmInfoBarDelegate(infobar_service),
host_(host) {
}
gfx::Image* DownloadRequestInfoBarDelegate::GetIcon() const {
return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
IDR_INFOBAR_MULTIPLE_DOWNLOADS);
}
string16 DownloadRequestInfoBarDelegate::GetMessageText() const {
return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING);
}
string16 DownloadRequestInfoBarDelegate::GetButtonLabel(
InfoBarButton button) const {
return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
IDS_MULTI_DOWNLOAD_WARNING_ALLOW : IDS_MULTI_DOWNLOAD_WARNING_DENY);
}
bool DownloadRequestInfoBarDelegate::Accept() {
if (host_) {
// Accept() call will invalidate host_ weak pointer if no further
// prompts are required.
host_->Accept();
}
return !host_;
}
|