Home | History | Annotate | Download | only in infobars
      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 
     11 ConfirmInfoBarDelegate::~ConfirmInfoBarDelegate() {
     12 }
     13 
     14 InfoBarDelegate::InfoBarAutomationType
     15     ConfirmInfoBarDelegate::GetInfoBarAutomationType() const {
     16   return CONFIRM_INFOBAR;
     17 }
     18 
     19 int ConfirmInfoBarDelegate::GetButtons() const {
     20   return BUTTON_OK | BUTTON_CANCEL;
     21 }
     22 
     23 base::string16 ConfirmInfoBarDelegate::GetButtonLabel(
     24     InfoBarButton button) const {
     25   return l10n_util::GetStringUTF16((button == BUTTON_OK) ? IDS_OK : IDS_CANCEL);
     26 }
     27 
     28 bool ConfirmInfoBarDelegate::NeedElevation(InfoBarButton button) const {
     29   return false;
     30 }
     31 
     32 bool ConfirmInfoBarDelegate::Accept() {
     33   return true;
     34 }
     35 
     36 bool ConfirmInfoBarDelegate::Cancel() {
     37   return true;
     38 }
     39 
     40 base::string16 ConfirmInfoBarDelegate::GetLinkText() const {
     41   return base::string16();
     42 }
     43 
     44 bool ConfirmInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
     45   return true;
     46 }
     47 
     48 ConfirmInfoBarDelegate::ConfirmInfoBarDelegate()
     49     : InfoBarDelegate() {
     50 }
     51 
     52 bool 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 
     61 bool ConfirmInfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const {
     62   ConfirmInfoBarDelegate* confirm_delegate =
     63       delegate->AsConfirmInfoBarDelegate();
     64   return confirm_delegate &&
     65       (confirm_delegate->GetMessageText() == GetMessageText());
     66 }
     67 
     68 ConfirmInfoBarDelegate* ConfirmInfoBarDelegate::AsConfirmInfoBarDelegate() {
     69   return this;
     70 }
     71