summaryrefslogtreecommitdiffstats
path: root/chrome/browser/infobars/infobar_delegate.cc
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-30 15:07:08 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-30 15:07:08 +0000
commit95a33ed6cb8688573249f7cd7032d23518879c6d (patch)
tree77c2f8d28412caa3aeb6cdb94de420bb811113d6 /chrome/browser/infobars/infobar_delegate.cc
parent14ea9bf12826e740fd77fda742e67605df06ce4a (diff)
downloadchromium_src-95a33ed6cb8688573249f7cd7032d23518879c6d.zip
chromium_src-95a33ed6cb8688573249f7cd7032d23518879c6d.tar.gz
chromium_src-95a33ed6cb8688573249f7cd7032d23518879c6d.tar.bz2
Move infobar handling to a tab helper.
Part 2: - Removed TabContentsWrapper from core infobar classes - Made InfoBarTabHelper the owner of the infobar delegates - Removed all owner references from the delegate subclasses BUG=94741 TEST=no visible change Review URL: http://codereview.chromium.org/7862003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103463 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/infobars/infobar_delegate.cc')
-rw-r--r--chrome/browser/infobars/infobar_delegate.cc101
1 files changed, 101 insertions, 0 deletions
diff --git a/chrome/browser/infobars/infobar_delegate.cc b/chrome/browser/infobars/infobar_delegate.cc
new file mode 100644
index 0000000..0f13590
--- /dev/null
+++ b/chrome/browser/infobars/infobar_delegate.cc
@@ -0,0 +1,101 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/infobars/infobar_delegate.h"
+
+#include "base/logging.h"
+#include "build/build_config.h"
+#include "chrome/browser/infobars/infobar_tab_helper.h"
+#include "content/browser/tab_contents/navigation_details.h"
+#include "content/browser/tab_contents/navigation_entry.h"
+#include "content/browser/tab_contents/tab_contents.h"
+
+// InfoBarDelegate ------------------------------------------------------------
+
+InfoBarDelegate::~InfoBarDelegate() {
+}
+
+bool InfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const {
+ return false;
+}
+
+bool InfoBarDelegate::ShouldExpire(
+ const content::LoadCommittedDetails& details) const {
+ if (!details.is_navigation_to_different_page())
+ return false;
+
+ return ShouldExpireInternal(details);
+}
+
+void InfoBarDelegate::InfoBarDismissed() {
+}
+
+void InfoBarDelegate::InfoBarClosed() {
+ delete this;
+}
+
+gfx::Image* InfoBarDelegate::GetIcon() const {
+ return NULL;
+}
+
+InfoBarDelegate::Type InfoBarDelegate::GetInfoBarType() const {
+ return WARNING_TYPE;
+}
+
+ConfirmInfoBarDelegate* InfoBarDelegate::AsConfirmInfoBarDelegate() {
+ return NULL;
+}
+
+ExtensionInfoBarDelegate* InfoBarDelegate::AsExtensionInfoBarDelegate() {
+ return NULL;
+}
+
+InsecureContentInfoBarDelegate*
+ InfoBarDelegate::AsInsecureContentInfoBarDelegate() {
+ return NULL;
+}
+
+LinkInfoBarDelegate* InfoBarDelegate::AsLinkInfoBarDelegate() {
+ return NULL;
+}
+
+PluginInstallerInfoBarDelegate*
+ InfoBarDelegate::AsPluginInstallerInfoBarDelegate() {
+ return NULL;
+}
+
+ThemeInstalledInfoBarDelegate*
+ InfoBarDelegate::AsThemePreviewInfobarDelegate() {
+ return NULL;
+}
+
+TranslateInfoBarDelegate* InfoBarDelegate::AsTranslateInfoBarDelegate() {
+ return NULL;
+}
+
+InfoBarDelegate::InfoBarDelegate(InfoBarTabHelper* infobar_helper)
+ : contents_unique_id_(0),
+ owner_(infobar_helper) {
+ if (infobar_helper)
+ StoreActiveEntryUniqueID(infobar_helper);
+}
+
+void InfoBarDelegate::StoreActiveEntryUniqueID(
+ InfoBarTabHelper* infobar_helper) {
+ NavigationEntry* active_entry =
+ infobar_helper->tab_contents()->controller().GetActiveEntry();
+ contents_unique_id_ = active_entry ? active_entry->unique_id() : 0;
+}
+
+bool InfoBarDelegate::ShouldExpireInternal(
+ const content::LoadCommittedDetails& details) const {
+ return (contents_unique_id_ != details.entry->unique_id()) ||
+ (PageTransition::StripQualifier(details.entry->transition_type()) ==
+ PageTransition::RELOAD);
+}
+
+void InfoBarDelegate::RemoveSelf() {
+ if (owner_)
+ owner_->RemoveInfoBar(this); // Clears |owner_|.
+}