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
3// found in the LICENSE file.
4
5#include "chrome/browser/download/download_request_infobar_delegate.h"
6
7#include "content/browser/tab_contents/tab_contents.h"
8#include "grit/generated_resources.h"
9#include "grit/theme_resources.h"
10#include "ui/base/l10n/l10n_util.h"
11#include "ui/base/resource/resource_bundle.h"
12
13DownloadRequestInfoBarDelegate::DownloadRequestInfoBarDelegate(
14    TabContents* tab,
15    DownloadRequestLimiter::TabDownloadState* host)
16    : ConfirmInfoBarDelegate(tab),
17      host_(host) {
18}
19
20DownloadRequestInfoBarDelegate::~DownloadRequestInfoBarDelegate() {
21}
22
23void DownloadRequestInfoBarDelegate::InfoBarClosed() {
24  if (host_)
25    host_->Cancel();
26  delete this;
27}
28
29SkBitmap* DownloadRequestInfoBarDelegate::GetIcon() const {
30  return ResourceBundle::GetSharedInstance().GetBitmapNamed(
31      IDR_INFOBAR_MULTIPLE_DOWNLOADS);
32}
33
34string16 DownloadRequestInfoBarDelegate::GetMessageText() const {
35  return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING);
36}
37
38string16 DownloadRequestInfoBarDelegate::GetButtonLabel(
39    InfoBarButton button) const {
40  return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
41      IDS_MULTI_DOWNLOAD_WARNING_ALLOW : IDS_MULTI_DOWNLOAD_WARNING_DENY);
42}
43
44bool DownloadRequestInfoBarDelegate::Accept() {
45  if (host_) {
46    // Accept() call will nullify host_ if no further prompts are required.
47    host_->Accept();
48  }
49
50  return !host_;
51}
52