| OLD | NEW |
| (Empty) |
| 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/infobar_delegate.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "build/build_config.h" | |
| 9 #include "content/browser/tab_contents/navigation_entry.h" | |
| 10 #include "content/browser/tab_contents/navigation_controller.h" | |
| 11 #include "content/browser/tab_contents/tab_contents.h" | |
| 12 #include "grit/generated_resources.h" | |
| 13 #include "ui/base/l10n/l10n_util.h" | |
| 14 | |
| 15 // LinkInfoBarDelegate -------------------------------------------------------- | |
| 16 | |
| 17 bool LinkInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { | |
| 18 return true; | |
| 19 } | |
| 20 | |
| 21 LinkInfoBarDelegate::LinkInfoBarDelegate(TabContents* contents) | |
| 22 : InfoBarDelegate(contents) { | |
| 23 } | |
| 24 | |
| 25 LinkInfoBarDelegate::~LinkInfoBarDelegate() { | |
| 26 } | |
| 27 | |
| 28 LinkInfoBarDelegate* LinkInfoBarDelegate::AsLinkInfoBarDelegate() { | |
| 29 return this; | |
| 30 } | |
| 31 | |
| 32 | |
| 33 // ConfirmInfoBarDelegate ----------------------------------------------------- | |
| 34 | |
| 35 int ConfirmInfoBarDelegate::GetButtons() const { | |
| 36 return BUTTON_OK | BUTTON_CANCEL; | |
| 37 } | |
| 38 | |
| 39 string16 ConfirmInfoBarDelegate::GetButtonLabel(InfoBarButton button) const { | |
| 40 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? IDS_OK : IDS_CANCEL); | |
| 41 } | |
| 42 | |
| 43 bool ConfirmInfoBarDelegate::NeedElevation(InfoBarButton button) const { | |
| 44 return false; | |
| 45 } | |
| 46 | |
| 47 bool ConfirmInfoBarDelegate::Accept() { | |
| 48 return true; | |
| 49 } | |
| 50 | |
| 51 bool ConfirmInfoBarDelegate::Cancel() { | |
| 52 return true; | |
| 53 } | |
| 54 | |
| 55 string16 ConfirmInfoBarDelegate::GetLinkText() { | |
| 56 return string16(); | |
| 57 } | |
| 58 | |
| 59 bool ConfirmInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { | |
| 60 return true; | |
| 61 } | |
| 62 | |
| 63 ConfirmInfoBarDelegate::ConfirmInfoBarDelegate(TabContents* contents) | |
| 64 : InfoBarDelegate(contents) { | |
| 65 } | |
| 66 | |
| 67 ConfirmInfoBarDelegate::~ConfirmInfoBarDelegate() { | |
| 68 } | |
| 69 | |
| 70 bool ConfirmInfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const { | |
| 71 ConfirmInfoBarDelegate* confirm_delegate = | |
| 72 delegate->AsConfirmInfoBarDelegate(); | |
| 73 return confirm_delegate && | |
| 74 (confirm_delegate->GetMessageText() == GetMessageText()); | |
| 75 } | |
| 76 | |
| 77 ConfirmInfoBarDelegate* ConfirmInfoBarDelegate::AsConfirmInfoBarDelegate() { | |
| 78 return this; | |
| 79 } | |
| 80 | |
| 81 | |
| 82 // SimpleAlertInfoBarDelegate ------------------------------------------------- | |
| 83 | |
| 84 SimpleAlertInfoBarDelegate::SimpleAlertInfoBarDelegate( | |
| 85 TabContents* contents, | |
| 86 SkBitmap* icon, | |
| 87 const string16& message, | |
| 88 bool auto_expire) | |
| 89 : ConfirmInfoBarDelegate(contents), | |
| 90 icon_(icon), | |
| 91 message_(message), | |
| 92 auto_expire_(auto_expire) { | |
| 93 } | |
| 94 | |
| 95 SimpleAlertInfoBarDelegate::~SimpleAlertInfoBarDelegate() { | |
| 96 } | |
| 97 | |
| 98 bool SimpleAlertInfoBarDelegate::ShouldExpire( | |
| 99 const NavigationController::LoadCommittedDetails& details) const { | |
| 100 return auto_expire_ && ConfirmInfoBarDelegate::ShouldExpire(details); | |
| 101 } | |
| 102 | |
| 103 void SimpleAlertInfoBarDelegate::InfoBarClosed() { | |
| 104 delete this; | |
| 105 } | |
| 106 | |
| 107 SkBitmap* SimpleAlertInfoBarDelegate::GetIcon() const { | |
| 108 return icon_; | |
| 109 } | |
| 110 | |
| 111 string16 SimpleAlertInfoBarDelegate::GetMessageText() const { | |
| 112 return message_; | |
| 113 } | |
| 114 | |
| 115 int SimpleAlertInfoBarDelegate::GetButtons() const { | |
| 116 return BUTTON_NONE; | |
| 117 } | |
| OLD | NEW |