summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-03 16:56:38 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-03 16:56:38 +0000
commit0c9ee9904acbfe0766f488edb207ff232635efd3 (patch)
tree5118e9af778ed35f8a68490171a75676ce202c4d /chrome/browser/tab_contents
parentbbf87943104ec3343bd93152500fdb0bf81ee563 (diff)
downloadchromium_src-0c9ee9904acbfe0766f488edb207ff232635efd3.zip
chromium_src-0c9ee9904acbfe0766f488edb207ff232635efd3.tar.gz
chromium_src-0c9ee9904acbfe0766f488edb207ff232635efd3.tar.bz2
Revert "This is the first of probably several patches trying to clean up the BlockedPopupContainer
into something that can be cross-platform." This reverts commit 0247f4d628f8f56c0a42ab44efd1d29058167a11 (r17483). Review URL: http://codereview.chromium.org/118166 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17485 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc40
-rw-r--r--chrome/browser/tab_contents/tab_contents.h12
-rw-r--r--chrome/browser/tab_contents/tab_contents_view_win.cc2
3 files changed, 32 insertions, 22 deletions
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 509b38f..db05c00 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -11,7 +11,6 @@
#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"
@@ -58,6 +57,7 @@
#if defined(OS_WIN)
// 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
@@ -315,9 +315,6 @@ 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,
@@ -827,10 +824,12 @@ 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);
@@ -1007,12 +1006,18 @@ void TabContents::WillClose(ConstrainedWindow* window) {
find(child_windows_.begin(), child_windows_.end(), window);
if (it != child_windows_.end())
child_windows_.erase(it);
-}
-void TabContents::WillCloseBlockedPopupContainer(
- BlockedPopupContainer* container) {
- DCHECK(blocked_popups_ == container);
- blocked_popups_ = NULL;
+#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::DidMoveOrResize(ConstrainedWindow* window) {
@@ -1176,6 +1181,7 @@ 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,
@@ -1184,18 +1190,28 @@ 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() {
+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());
+
if (blocked_popups_)
- blocked_popups_->RepositionBlockedPopupContainer(GetNativeView());
+ blocked_popups_->RepositionConstrainedWindowTo(anchor_position);
}
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 c766f56..c43a919 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -432,9 +432,6 @@ 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);
@@ -577,10 +574,6 @@ 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
@@ -641,7 +634,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();
+ void RepositionSupressedPopupsToFit(const gfx::Size& new_size);
// 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
@@ -1006,7 +999,8 @@ class TabContents : public PageNavigator,
bool shelf_visible_;
// ConstrainedWindow with additional methods for managing blocked
- // popups.
+ // popups. This pointer also goes in |child_windows_| for ownership,
+ // repositioning, etc.
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 6b673e8..fac170d 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();
+ tab_contents()->RepositionSupressedPopupsToFit(size);
}
bool TabContentsViewWin::ScrollZoom(int scroll_type) {