diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-04 19:22:13 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-04 19:22:13 +0000 |
commit | 66ba493b842d92a7d9e515302d585d1c56848ee0 (patch) | |
tree | 59f303d8f54c0447268302fdabce7c873fe2c09b /chrome/browser/tab_contents | |
parent | 33b28a75192e79cff41ecbe82defd65ad5da9535 (diff) | |
download | chromium_src-66ba493b842d92a7d9e515302d585d1c56848ee0.zip chromium_src-66ba493b842d92a7d9e515302d585d1c56848ee0.tar.gz chromium_src-66ba493b842d92a7d9e515302d585d1c56848ee0.tar.bz2 |
Relanding the first of probably several patches trying to clean up the BlockedPopupContainer into something that can be cross-platform.
- BlokedPopupContainers are no longer ConstrainedWindows.
- There is now a cross platform base class that contains most of the model/controller logic. The view now inherits from it. This is an improvement.
This version has minor windows compile fixes that changed from under me.
Original Review URL: http://codereview.chromium.org/119006
TBR=beng
TEST=Popup notification still works.
Review URL: http://codereview.chromium.org/119107
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17647 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 50 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.h | 12 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_view_win.cc | 2 |
3 files changed, 29 insertions, 35 deletions
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 4bc4366..59034a5 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -11,6 +11,7 @@ #include "base/string16.h" #include "base/time.h" #include "chrome/browser/autofill_manager.h" +#include "chrome/browser/blocked_popup_container.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/cert_store.h" @@ -53,9 +54,10 @@ #include "net/base/registry_controlled_domain.h" #if defined(OS_WIN) +// For CRect +#include <atlmisc.h> // TODO(port): some of these headers should be ported. #include "chrome/browser/modal_html_dialog_delegate.h" -#include "chrome/browser/views/blocked_popup_container.h" #include "views/controls/scrollbar/native_scroll_bar.h" #endif @@ -200,14 +202,16 @@ TabContents::TabContents(Profile* profile, int routing_id, base::WaitableEvent* modal_dialog_event) : delegate_(NULL), - controller_(this, profile), - view_(TabContentsView::Create(static_cast<TabContents*>(this))), + ALLOW_THIS_IN_INITIALIZER_LIST(controller_(this, profile)), + ALLOW_THIS_IN_INITIALIZER_LIST(view_( + TabContentsView::Create(static_cast<TabContents*>(this)))), ALLOW_THIS_IN_INITIALIZER_LIST(render_manager_( static_cast<TabContents*>(this), static_cast<TabContents*>(this))), property_bag_(), registrar_(), - printing_(*static_cast<TabContents*>(this)), + ALLOW_THIS_IN_INITIALIZER_LIST(printing_( + *static_cast<TabContents*>(this))), save_package_(), cancelable_consumer_(), autofill_manager_(), @@ -306,6 +310,9 @@ TabContents::~TabContents() { window->CloseConstrainedWindow(); } + if (blocked_popups_) + blocked_popups_->Destroy(); + // Notify any observer that have a reference on this tab contents. NotificationService::current()->Notify( NotificationType::TAB_CONTENTS_DESTROYED, @@ -815,12 +822,10 @@ void TabContents::AddNewContents(TabContents* new_contents, #endif } -#if defined(OS_WIN) void TabContents::CloseAllSuppressedPopups() { if (blocked_popups_) blocked_popups_->CloseAll(); } -#endif void TabContents::PopupNotificationVisibilityChanged(bool visible) { render_view_host()->PopupNotificationVisibilityChanged(visible); @@ -937,18 +942,12 @@ void TabContents::WillClose(ConstrainedWindow* window) { find(child_windows_.begin(), child_windows_.end(), window); if (it != child_windows_.end()) child_windows_.erase(it); +} -#if defined(OS_WIN) - if (window == blocked_popups_) - blocked_popups_ = NULL; - - if (::IsWindow(GetNativeView())) { - CRect client_rect; - GetClientRect(GetNativeView(), &client_rect); - RepositionSupressedPopupsToFit( - gfx::Size(client_rect.Width(), client_rect.Height())); - } -#endif +void TabContents::WillCloseBlockedPopupContainer( + BlockedPopupContainer* container) { + DCHECK(blocked_popups_ == container); + blocked_popups_ = NULL; } void TabContents::DidMoveOrResize(ConstrainedWindow* window) { @@ -1112,7 +1111,6 @@ void TabContents::CreateBlockedPopupContainerIfNecessary() { client_rect.Height()); blocked_popups_ = BlockedPopupContainer::Create(this, profile(), anchor_position); - child_windows_.push_back(blocked_popups_); } void TabContents::AddPopup(TabContents* new_contents, @@ -1121,28 +1119,18 @@ void TabContents::AddPopup(TabContents* new_contents, CreateBlockedPopupContainerIfNecessary(); blocked_popups_->AddTabContents(new_contents, initial_pos, host); } +#endif // TODO(brettw) This should be on the TabContentsView. -void TabContents::RepositionSupressedPopupsToFit(const gfx::Size& new_size) { - // TODO(erg): There's no way to detect whether scroll bars are - // visible, so for beta, we're just going to assume that the - // vertical scroll bar is visible, and not care about covering up - // the horizontal scroll bar. Fixing this is half of - // http://b/1118139. - gfx::Point anchor_position( - new_size.width() - - views::NativeScrollBar::GetVerticalScrollBarWidth(), - new_size.height()); - +void TabContents::RepositionSupressedPopupsToFit() { if (blocked_popups_) - blocked_popups_->RepositionConstrainedWindowTo(anchor_position); + blocked_popups_->RepositionBlockedPopupContainer(GetNativeView()); } bool TabContents::ShowingBlockedPopupNotification() const { return blocked_popups_ != NULL && blocked_popups_->GetBlockedPopupCount() != 0; } -#endif // defined(OS_WIN) namespace { bool TransitionIsReload(PageTransition::Type transition) { diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index 026cf3d..2853ceb 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -413,6 +413,9 @@ class TabContents : public PageNavigator, // Called when a ConstrainedWindow we own is about to be closed. void WillClose(ConstrainedWindow* window); + // Called when a BlockedPopupContainer we own is about to be closed. + void WillCloseBlockedPopupContainer(BlockedPopupContainer* container); + // Called when a ConstrainedWindow we own is moved or resized. void DidMoveOrResize(ConstrainedWindow* window); @@ -555,6 +558,10 @@ class TabContents : public PageNavigator, render_view_host()->WindowMoveOrResizeStarted(); } + BlockedPopupContainer* blocked_popup_container() const { + return blocked_popups_; + } + private: friend class NavigationController; // Used to access the child_windows_ (ConstrainedWindowList) for testing @@ -615,7 +622,7 @@ class TabContents : public PageNavigator, // Called by a derived class when the TabContents is resized, causing // suppressed constrained web popups to be repositioned to the new bounds // if necessary. - void RepositionSupressedPopupsToFit(const gfx::Size& new_size); + void RepositionSupressedPopupsToFit(); // Whether we have a notification AND the notification owns popups windows. // (We keep the notification object around even when it's not shown since it @@ -971,8 +978,7 @@ class TabContents : public PageNavigator, // Data for shelves and stuff ------------------------------------------------ // ConstrainedWindow with additional methods for managing blocked - // popups. This pointer also goes in |child_windows_| for ownership, - // repositioning, etc. + // popups. BlockedPopupContainer* blocked_popups_; // Delegates for InfoBars associated with this TabContents. diff --git a/chrome/browser/tab_contents/tab_contents_view_win.cc b/chrome/browser/tab_contents/tab_contents_view_win.cc index 15481b5..a5ec7f4 100644 --- a/chrome/browser/tab_contents/tab_contents_view_win.cc +++ b/chrome/browser/tab_contents/tab_contents_view_win.cc @@ -570,7 +570,7 @@ void TabContentsViewWin::WasSized(const gfx::Size& size) { tab_contents()->render_widget_host_view()->SetSize(size); // TODO(brettw) this function can probably be moved to this class. - tab_contents()->RepositionSupressedPopupsToFit(size); + tab_contents()->RepositionSupressedPopupsToFit(); } bool TabContentsViewWin::ScrollZoom(int scroll_type) { |