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
3// found in the LICENSE file.
4
5#include "chrome/browser/infobars/confirm_infobar_delegate.h"
6
7#include "content/public/browser/navigation_details.h"
8#include "grit/generated_resources.h"
9#include "ui/base/l10n/l10n_util.h"
10
11ConfirmInfoBarDelegate::~ConfirmInfoBarDelegate() {
12}
13
14InfoBarDelegate::InfoBarAutomationType
15    ConfirmInfoBarDelegate::GetInfoBarAutomationType() const {
16  return CONFIRM_INFOBAR;
17}
18
19int ConfirmInfoBarDelegate::GetButtons() const {
20  return BUTTON_OK | BUTTON_CANCEL;
21}
22
23base::string16 ConfirmInfoBarDelegate::GetButtonLabel(
24    InfoBarButton button) const {
25  return l10n_util::GetStringUTF16((button == BUTTON_OK) ? IDS_OK : IDS_CANCEL);
26}
27
28bool ConfirmInfoBarDelegate::NeedElevation(InfoBarButton button) const {
29  return false;
30}
31
32bool ConfirmInfoBarDelegate::Accept() {
33  return true;
34}
35
36bool ConfirmInfoBarDelegate::Cancel() {
37  return true;
38}
39
40base::string16 ConfirmInfoBarDelegate::GetLinkText() const {
41  return base::string16();
42}
43
44bool ConfirmInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
45  return true;
46}
47
48ConfirmInfoBarDelegate::ConfirmInfoBarDelegate()
49    : InfoBarDelegate() {
50}
51
52bool ConfirmInfoBarDelegate::ShouldExpireInternal(
53    const content::LoadCommittedDetails& details) const {
54  return !details.did_replace_entry &&
55      InfoBarDelegate::ShouldExpireInternal(details);
56}
57
58// ConfirmInfoBarDelegate::CreateInfoBar() is implemented in platform-specific
59// files.
60
61bool ConfirmInfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const {
62  ConfirmInfoBarDelegate* confirm_delegate =
63      delegate->AsConfirmInfoBarDelegate();
64  return confirm_delegate &&
65      (confirm_delegate->GetMessageText() == GetMessageText());
66}
67
68ConfirmInfoBarDelegate* ConfirmInfoBarDelegate::AsConfirmInfoBarDelegate() {
69  return this;
70}
71