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