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 string16 ConfirmInfoBarDelegate::GetButtonLabel(InfoBarButton button) const {
     24   return l10n_util::GetStringUTF16((button == BUTTON_OK) ? IDS_OK : IDS_CANCEL);
     25 }
     26 
     27 bool ConfirmInfoBarDelegate::NeedElevation(InfoBarButton button) const {
     28   return false;
     29 }
     30 
     31 bool ConfirmInfoBarDelegate::Accept() {
     32   return true;
     33 }
     34 
     35 bool ConfirmInfoBarDelegate::Cancel() {
     36   return true;
     37 }
     38 
     39 string16 ConfirmInfoBarDelegate::GetLinkText() const {
     40   return string16();
     41 }
     42 
     43 bool ConfirmInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
     44   return true;
     45 }
     46 
     47 ConfirmInfoBarDelegate::ConfirmInfoBarDelegate(
     48     InfoBarService* infobar_service)
     49     : InfoBarDelegate(infobar_service) {
     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