summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-18 00:18:09 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-18 00:18:09 +0000
commit7abc95294fd6bfd2bdd60733fa24de640b9f0bb2 (patch)
tree9ee1f42e6a0b4405b6f26957e0ec9514a3eb6ac3 /content/browser
parent41b946d3b39411c505f66a9dba6dc052d80dde88 (diff)
downloadchromium_src-7abc95294fd6bfd2bdd60733fa24de640b9f0bb2.zip
chromium_src-7abc95294fd6bfd2bdd60733fa24de640b9f0bb2.tar.gz
chromium_src-7abc95294fd6bfd2bdd60733fa24de640b9f0bb2.tar.bz2
Move the little infobar code from TabContents to TabContentsWrapper.
BUG=76792 Review URL: http://codereview.chromium.org/7010017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85703 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/tab_contents/tab_contents.cc128
-rw-r--r--content/browser/tab_contents/tab_contents.h32
-rw-r--r--content/browser/tab_contents/tab_contents_delegate.cc4
-rw-r--r--content/browser/tab_contents/tab_contents_delegate.h3
4 files changed, 0 insertions, 167 deletions
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index bf511cf..6e60971 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -30,7 +30,6 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_host/web_cache_manager.h"
#include "chrome/browser/renderer_preferences_util.h"
-#include "chrome/browser/tab_contents/infobar_delegate.h"
#include "chrome/browser/tab_contents/tab_contents_ssl_helper.h"
#include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h"
#include "chrome/browser/ui/browser_dialogs.h"
@@ -299,19 +298,6 @@ TabContents::~TabContents() {
Source<TabContents>(this),
NotificationService::NoDetails());
- // Notify any lasting InfobarDelegates that have not yet been removed that
- // whatever infobar they were handling in this TabContents has closed,
- // because the TabContents is going away entirely.
- // This must happen after the TAB_CONTENTS_DESTROYED notification as the
- // notification may trigger infobars calls that access their delegate. (and
- // some implementations of InfoBarDelegate do delete themselves on
- // InfoBarClosed()).
- for (size_t i = 0; i < infobar_count(); ++i) {
- InfoBarDelegate* delegate = GetInfoBarDelegateAt(i);
- delegate->InfoBarClosed();
- }
- infobar_delegates_.clear();
-
// TODO(brettw) this should be moved to the view.
#if defined(OS_WIN)
// If we still have a window handle, destroy it. GetNativeView can return
@@ -744,89 +730,6 @@ void TabContents::SetFocusToLocationBar(bool select_all) {
delegate()->SetFocusToLocationBar(select_all);
}
-void TabContents::AddInfoBar(InfoBarDelegate* delegate) {
- if (delegate_ && !delegate_->infobars_enabled()) {
- delegate->InfoBarClosed();
- return;
- }
-
- // Look through the existing InfoBarDelegates we have for a match. If we've
- // already got one that matches, then we don't add the new one.
- for (size_t i = 0; i < infobar_count(); ++i) {
- if (GetInfoBarDelegateAt(i)->EqualsDelegate(delegate)) {
- // Tell the new infobar to close so that it can clean itself up.
- delegate->InfoBarClosed();
- return;
- }
- }
-
- infobar_delegates_.push_back(delegate);
- NotificationService::current()->Notify(
- NotificationType::TAB_CONTENTS_INFOBAR_ADDED, Source<TabContents>(this),
- Details<InfoBarDelegate>(delegate));
-
- // Add ourselves as an observer for navigations the first time a delegate is
- // added. We use this notification to expire InfoBars that need to expire on
- // page transitions.
- if (infobar_delegates_.size() == 1) {
- registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED,
- Source<NavigationController>(&controller_));
- }
-}
-
-void TabContents::RemoveInfoBar(InfoBarDelegate* delegate) {
- if (delegate_ && !delegate_->infobars_enabled()) {
- return;
- }
-
- std::vector<InfoBarDelegate*>::iterator it =
- find(infobar_delegates_.begin(), infobar_delegates_.end(), delegate);
- if (it != infobar_delegates_.end()) {
- InfoBarDelegate* delegate = *it;
- NotificationService::current()->Notify(
- NotificationType::TAB_CONTENTS_INFOBAR_REMOVED,
- Source<TabContents>(this),
- Details<InfoBarDelegate>(delegate));
-
- infobar_delegates_.erase(it);
- // Remove ourselves as an observer if we are tracking no more InfoBars.
- if (infobar_delegates_.empty()) {
- registrar_.Remove(this, NotificationType::NAV_ENTRY_COMMITTED,
- Source<NavigationController>(&controller_));
- }
- }
-}
-
-void TabContents::ReplaceInfoBar(InfoBarDelegate* old_delegate,
- InfoBarDelegate* new_delegate) {
- if (delegate_ && !delegate_->infobars_enabled()) {
- new_delegate->InfoBarClosed();
- return;
- }
-
- std::vector<InfoBarDelegate*>::iterator it =
- find(infobar_delegates_.begin(), infobar_delegates_.end(), old_delegate);
- DCHECK(it != infobar_delegates_.end());
-
- // Notify the container about the change of plans.
- scoped_ptr<std::pair<InfoBarDelegate*, InfoBarDelegate*> > details(
- new std::pair<InfoBarDelegate*, InfoBarDelegate*>(
- old_delegate, new_delegate));
- NotificationService::current()->Notify(
- NotificationType::TAB_CONTENTS_INFOBAR_REPLACED,
- Source<TabContents>(this),
- Details<std::pair<InfoBarDelegate*, InfoBarDelegate*> >(details.get()));
-
- // Remove the old one.
- infobar_delegates_.erase(it);
-
- // Add the new one.
- DCHECK(find(infobar_delegates_.begin(),
- infobar_delegates_.end(), new_delegate) ==
- infobar_delegates_.end());
- infobar_delegates_.push_back(new_delegate);
-}
-
bool TabContents::ShouldShowBookmarkBar() {
if (showing_interstitial_page())
return false;
@@ -1205,24 +1108,6 @@ void TabContents::SetIsLoading(bool is_loading,
det);
}
-void TabContents::ExpireInfoBars(
- const NavigationController::LoadCommittedDetails& details) {
- // Only hide InfoBars when the user has done something that makes the main
- // frame load. We don't want various automatic or subframe navigations making
- // it disappear.
- if (!details.is_user_initiated_main_frame_load())
- return;
-
- // NOTE: It is not safe to change the following code to count upwards or use
- // iterators, as the RemoveInfoBar() call synchronously modifies our delegate
- // list.
- for (size_t i = infobar_count(); i > 0; --i) {
- InfoBarDelegate* delegate = GetInfoBarDelegateAt(i - 1);
- if (delegate->ShouldExpire(details))
- RemoveInfoBar(delegate);
- }
-}
-
WebUI* TabContents::GetWebUIForCurrentState() {
// When there is a pending navigation entry, we want to use the pending WebUI
// that goes along with it to control the basic flags. For example, we want to
@@ -1584,10 +1469,6 @@ void TabContents::RenderViewGone(RenderViewHost* rvh,
NotifyDisconnected();
SetIsCrashed(status, error_code);
- // Remove all infobars.
- while (!infobar_delegates_.empty())
- RemoveInfoBar(GetInfoBarDelegateAt(infobar_count() - 1));
-
// Tell the view that we've crashed so it can prepare the sad tab page.
// Only do this if we're not in browser shutdown, so that TabContents
// objects that are not in a browser (e.g., HTML dialogs) and thus are
@@ -2146,15 +2027,6 @@ void TabContents::Observe(NotificationType type,
view_->RenderWidgetHostDestroyed(Source<RenderWidgetHost>(source).ptr());
break;
- case NotificationType::NAV_ENTRY_COMMITTED: {
- DCHECK(&controller_ == Source<NavigationController>(source).ptr());
-
- NavigationController::LoadCommittedDetails& committed_details =
- *(Details<NavigationController::LoadCommittedDetails>(details).ptr());
- ExpireInfoBars(committed_details);
- break;
- }
-
#if defined(OS_LINUX)
case NotificationType::BROWSER_THEME_CHANGED: {
renderer_preferences_util::UpdateFromSystemSettings(
diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h
index c3e5544..56980fb 100644
--- a/content/browser/tab_contents/tab_contents.h
+++ b/content/browser/tab_contents/tab_contents.h
@@ -9,7 +9,6 @@
#include <deque>
#include <map>
#include <string>
-#include <vector>
#include "base/basictypes.h"
#include "base/gtest_prod_util.h"
@@ -47,7 +46,6 @@ class HistoryAddPageArgs;
class WebUI;
class DownloadItem;
class Extension;
-class InfoBarDelegate;
class LoadNotificationDetails;
class PluginObserver;
class Profile;
@@ -365,25 +363,6 @@ class TabContents : public PageNavigator,
// Creates a view and sets the size for the specified RVH.
virtual void CreateViewAndSetSizeForRVH(RenderViewHost* rvh);
- // Infobars ------------------------------------------------------------------
-
- // Adds an InfoBar for the specified |delegate|.
- void AddInfoBar(InfoBarDelegate* delegate);
-
- // Removes the InfoBar for the specified |delegate|.
- void RemoveInfoBar(InfoBarDelegate* delegate);
-
- // Replaces one infobar with another, without any animation in between.
- void ReplaceInfoBar(InfoBarDelegate* old_delegate,
- InfoBarDelegate* new_delegate);
-
- // Enumeration and access functions.
- size_t infobar_count() const { return infobar_delegates_.size(); }
- // WARNING: This does not sanity-check |index|!
- InfoBarDelegate* GetInfoBarDelegateAt(size_t index) {
- return infobar_delegates_[index];
- }
-
// Toolbars and such ---------------------------------------------------------
// Returns true if a Bookmark Bar should be shown for this tab.
@@ -636,12 +615,6 @@ class TabContents : public PageNavigator,
ConstrainedWindowList child_windows_;
- // Expires InfoBars that need to be expired, according to the state carried
- // in |details|, in response to a new NavigationEntry being committed (the
- // user navigated to another page).
- void ExpireInfoBars(
- const NavigationController::LoadCommittedDetails& details);
-
// Navigation helpers --------------------------------------------------------
//
// These functions are helpers for Navigate() and DidNavigate().
@@ -903,11 +876,6 @@ class TabContents : public PageNavigator,
// True if this is a secure page which displayed insecure content.
bool displayed_insecure_content_;
- // Data for shelves and stuff ------------------------------------------------
-
- // Delegates for InfoBars associated with this TabContents.
- std::vector<InfoBarDelegate*> infobar_delegates_;
-
// Data for misc internal state ----------------------------------------------
// See capturing_contents() above.
diff --git a/content/browser/tab_contents/tab_contents_delegate.cc b/content/browser/tab_contents/tab_contents_delegate.cc
index 9eb58df..7c9d9e7 100644
--- a/content/browser/tab_contents/tab_contents_delegate.cc
+++ b/content/browser/tab_contents/tab_contents_delegate.cc
@@ -180,10 +180,6 @@ gfx::NativeWindow TabContentsDelegate::GetFrameNativeWindow() {
void TabContentsDelegate::TabContentsCreated(TabContents* new_contents) {
}
-bool TabContentsDelegate::infobars_enabled() {
- return true;
-}
-
bool TabContentsDelegate::ShouldEnablePreferredSizeNotifications() {
return false;
}
diff --git a/content/browser/tab_contents/tab_contents_delegate.h b/content/browser/tab_contents/tab_contents_delegate.h
index c0c0b61..4be48d4 100644
--- a/content/browser/tab_contents/tab_contents_delegate.h
+++ b/content/browser/tab_contents/tab_contents_delegate.h
@@ -265,9 +265,6 @@ class TabContentsDelegate {
// typically happens when popups are created.
virtual void TabContentsCreated(TabContents* new_contents);
- // Returns whether infobars are enabled. Overrideable by child classes.
- virtual bool infobars_enabled();
-
// Whether the renderer should report its preferred size when it changes by
// calling UpdatePreferredSize().
// Note that this is set when the RenderViewHost is created and cannot be