| OLD | NEW |
| (Empty) |
| 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/infobar_delegate.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "build/build_config.h" | |
| 9 #include "chrome/browser/infobars/infobar_tab_helper.h" | |
| 10 #include "content/public/browser/navigation_controller.h" | |
| 11 #include "content/public/browser/navigation_details.h" | |
| 12 #include "content/public/browser/navigation_entry.h" | |
| 13 #include "content/public/browser/web_contents.h" | |
| 14 | |
| 15 using content::NavigationEntry; | |
| 16 | |
| 17 // InfoBarDelegate ------------------------------------------------------------ | |
| 18 | |
| 19 InfoBarDelegate::~InfoBarDelegate() { | |
| 20 } | |
| 21 | |
| 22 InfoBarDelegate::InfoBarAutomationType | |
| 23 InfoBarDelegate::GetInfoBarAutomationType() const { | |
| 24 return UNKNOWN_INFOBAR; | |
| 25 } | |
| 26 | |
| 27 bool InfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const { | |
| 28 return false; | |
| 29 } | |
| 30 | |
| 31 bool InfoBarDelegate::ShouldExpire( | |
| 32 const content::LoadCommittedDetails& details) const { | |
| 33 if (!details.is_navigation_to_different_page()) | |
| 34 return false; | |
| 35 | |
| 36 return ShouldExpireInternal(details); | |
| 37 } | |
| 38 | |
| 39 void InfoBarDelegate::InfoBarDismissed() { | |
| 40 } | |
| 41 | |
| 42 void InfoBarDelegate::InfoBarClosed() { | |
| 43 delete this; | |
| 44 } | |
| 45 | |
| 46 gfx::Image* InfoBarDelegate::GetIcon() const { | |
| 47 return NULL; | |
| 48 } | |
| 49 | |
| 50 InfoBarDelegate::Type InfoBarDelegate::GetInfoBarType() const { | |
| 51 return WARNING_TYPE; | |
| 52 } | |
| 53 | |
| 54 AutoLoginInfoBarDelegate* InfoBarDelegate::AsAutoLoginInfoBarDelegate() { | |
| 55 return NULL; | |
| 56 } | |
| 57 | |
| 58 ConfirmInfoBarDelegate* InfoBarDelegate::AsConfirmInfoBarDelegate() { | |
| 59 return NULL; | |
| 60 } | |
| 61 | |
| 62 ExtensionInfoBarDelegate* InfoBarDelegate::AsExtensionInfoBarDelegate() { | |
| 63 return NULL; | |
| 64 } | |
| 65 | |
| 66 InsecureContentInfoBarDelegate* | |
| 67 InfoBarDelegate::AsInsecureContentInfoBarDelegate() { | |
| 68 return NULL; | |
| 69 } | |
| 70 | |
| 71 LinkInfoBarDelegate* InfoBarDelegate::AsLinkInfoBarDelegate() { | |
| 72 return NULL; | |
| 73 } | |
| 74 | |
| 75 MediaStreamInfoBarDelegate* InfoBarDelegate::AsMediaStreamInfoBarDelegate() { | |
| 76 return NULL; | |
| 77 } | |
| 78 | |
| 79 RegisterProtocolHandlerInfoBarDelegate* | |
| 80 InfoBarDelegate::AsRegisterProtocolHandlerInfoBarDelegate() { | |
| 81 return NULL; | |
| 82 } | |
| 83 | |
| 84 ThemeInstalledInfoBarDelegate* | |
| 85 InfoBarDelegate::AsThemePreviewInfobarDelegate() { | |
| 86 return NULL; | |
| 87 } | |
| 88 | |
| 89 TranslateInfoBarDelegate* InfoBarDelegate::AsTranslateInfoBarDelegate() { | |
| 90 return NULL; | |
| 91 } | |
| 92 | |
| 93 InfoBarDelegate::InfoBarDelegate(InfoBarTabHelper* infobar_helper) | |
| 94 : contents_unique_id_(0), | |
| 95 owner_(infobar_helper) { | |
| 96 if (infobar_helper) | |
| 97 StoreActiveEntryUniqueID(infobar_helper); | |
| 98 } | |
| 99 | |
| 100 void InfoBarDelegate::StoreActiveEntryUniqueID( | |
| 101 InfoBarTabHelper* infobar_helper) { | |
| 102 NavigationEntry* active_entry = | |
| 103 infobar_helper->web_contents()->GetController().GetActiveEntry(); | |
| 104 contents_unique_id_ = active_entry ? active_entry->GetUniqueID() : 0; | |
| 105 } | |
| 106 | |
| 107 bool InfoBarDelegate::ShouldExpireInternal( | |
| 108 const content::LoadCommittedDetails& details) const { | |
| 109 return (contents_unique_id_ != details.entry->GetUniqueID()) || | |
| 110 (content::PageTransitionStripQualifier( | |
| 111 details.entry->GetTransitionType()) == | |
| 112 content::PAGE_TRANSITION_RELOAD); | |
| 113 } | |
| 114 | |
| 115 void InfoBarDelegate::RemoveSelf() { | |
| 116 if (owner_) | |
| 117 owner_->RemoveInfoBar(this); // Clears |owner_|. | |
| 118 } | |
| OLD | NEW |