diff options
author | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-03 23:00:09 +0000 |
---|---|---|
committer | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-03 23:00:09 +0000 |
commit | 41291b0e3555aa77d3501c02a75679b1d734d4ee (patch) | |
tree | 07a73989105d161f7a02cd7f9d87ca14827005a3 /chrome/browser/views/browser_bubble.cc | |
parent | 5e9877eb405ec97622d419a146b9b7c331568bf6 (diff) | |
download | chromium_src-41291b0e3555aa77d3501c02a75679b1d734d4ee.zip chromium_src-41291b0e3555aa77d3501c02a75679b1d734d4ee.tar.gz chromium_src-41291b0e3555aa77d3501c02a75679b1d734d4ee.tar.bz2 |
Part 1 of dragging extensions on the shelf. This part was just about getting the mechanics of the shelf handle and the dragging correct. Part 2 will actually allow the order to be changed.TEST=hover over an extension toolstrip, grab the handle and drag. release.
Review URL: http://codereview.chromium.org/119103
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17559 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/browser_bubble.cc')
-rw-r--r-- | chrome/browser/views/browser_bubble.cc | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/chrome/browser/views/browser_bubble.cc b/chrome/browser/views/browser_bubble.cc index cfab7ca..1df878d 100644 --- a/chrome/browser/views/browser_bubble.cc +++ b/chrome/browser/views/browser_bubble.cc @@ -5,6 +5,7 @@ #include "chrome/browser/views/browser_bubble.h" #include "app/l10n_util.h" +#include "chrome/browser/views/frame/browser_view.h" #include "views/widget/root_view.h" BrowserBubble::BrowserBubble(views::View* view, views::Widget* frame, @@ -12,14 +13,47 @@ BrowserBubble::BrowserBubble(views::View* view, views::Widget* frame, : frame_(frame), view_(view), visible_(false), - delegate_(NULL) { + delegate_(NULL), + attached_(false) { + frame_native_view_ = frame_->GetNativeView(); gfx::Size size = view->GetPreferredSize(); bounds_.SetRect(origin.x(), origin.y(), size.width(), size.height()); InitPopup(); } BrowserBubble::~BrowserBubble() { - DestroyPopup(); + DCHECK(!attached_); + popup_->CloseNow(); + // Don't call DetachFromBrowser from here. It needs to talk to the + // BrowserView to deregister itself, and if BrowserBubble is owned + // by a child of BrowserView, then it's possible that this stack frame + // is a descendant of BrowserView's destructor, which leads to problems. + // In that case, Detach doesn't need to get called anyway since BrowserView + // will do the necessary cleanup. +} + +void BrowserBubble::DetachFromBrowser() { + DCHECK(attached_); + if (!attached_) + return; + attached_ = false; + BrowserView* browser_view = + BrowserView::GetBrowserViewForNativeWindow(frame_native_view_); + if (browser_view) + browser_view->DetachBrowserBubble(this); +} + +void BrowserBubble::AttachToBrowser() { + DCHECK(!attached_); + if (attached_) + return; + BrowserView* browser_view = + BrowserView::GetBrowserViewForNativeWindow(frame_native_view_); + DCHECK(browser_view); + if (browser_view) { + browser_view->AttachBrowserBubble(this); + attached_ = true; + } } void BrowserBubble::BrowserWindowMoved() { @@ -48,6 +82,10 @@ void BrowserBubble::SetBounds(int x, int y, int w, int h) { Reposition(); } +void BrowserBubble::MoveTo(int x, int y) { + SetBounds(x, y, bounds_.width(), bounds_.height()); +} + void BrowserBubble::Reposition() { gfx::Point top_left; views::View::ConvertPointToScreen(frame_->GetRootView(), &top_left); @@ -56,3 +94,9 @@ void BrowserBubble::Reposition() { bounds_.width(), bounds_.height()); } + +void BrowserBubble::ResizeToView() { + gfx::Size size = view_->GetPreferredSize(); + SetBounds(bounds_.x(), bounds_.y(), size.width(), size.height()); +} + |