confirm_infobar_delegate.cc revision dc0f95d653279beabeb9817299e2902918ba123e
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/tab_contents/confirm_infobar_delegate.h"
6
7#include "content/browser/tab_contents/tab_contents.h"
8#include "grit/generated_resources.h"
9#include "ui/base/l10n/l10n_util.h"
10
11int ConfirmInfoBarDelegate::GetButtons() const {
12  return BUTTON_OK | BUTTON_CANCEL;
13}
14
15string16 ConfirmInfoBarDelegate::GetButtonLabel(InfoBarButton button) const {
16  return l10n_util::GetStringUTF16((button == BUTTON_OK) ? IDS_OK : IDS_CANCEL);
17}
18
19bool ConfirmInfoBarDelegate::NeedElevation(InfoBarButton button) const {
20  return false;
21}
22
23bool ConfirmInfoBarDelegate::Accept() {
24  return true;
25}
26
27bool ConfirmInfoBarDelegate::Cancel() {
28  return true;
29}
30
31string16 ConfirmInfoBarDelegate::GetLinkText() {
32  return string16();
33}
34
35bool ConfirmInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
36  return true;
37}
38
39ConfirmInfoBarDelegate::ConfirmInfoBarDelegate(TabContents* contents)
40    : InfoBarDelegate(contents) {
41}
42
43ConfirmInfoBarDelegate::~ConfirmInfoBarDelegate() {
44}
45
46bool ConfirmInfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const {
47  ConfirmInfoBarDelegate* confirm_delegate =
48      delegate->AsConfirmInfoBarDelegate();
49  return confirm_delegate &&
50      (confirm_delegate->GetMessageText() == GetMessageText());
51}
52
53ConfirmInfoBarDelegate* ConfirmInfoBarDelegate::AsConfirmInfoBarDelegate() {
54  return this;
55}
56