summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-22 23:22:12 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-22 23:22:12 +0000
commit2996231cee980f67ec8c0b10d12fda9599521062 (patch)
treea2c570673c108ee4e72f23b0d313decd24a325c0
parent1f7a2d10e98bcb84e9d74f6c0f38b0f4dbfbd4fc (diff)
downloadchromium_src-2996231cee980f67ec8c0b10d12fda9599521062.zip
chromium_src-2996231cee980f67ec8c0b10d12fda9599521062.tar.gz
chromium_src-2996231cee980f67ec8c0b10d12fda9599521062.tar.bz2
Hide the window frame when the last tab is dragged out of a tabstrip.
BUG=13838 TEST=Open two browser windows. Drag one of the tabs into the other tabstrip. The first browser window should disappear and the browser should not crash. Review URL: http://codereview.chromium.org/145019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18981 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc9
-rw-r--r--chrome/browser/gtk/browser_window_gtk.h4
-rw-r--r--chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc23
-rw-r--r--chrome/browser/gtk/tabs/dragged_tab_controller_gtk.h7
4 files changed, 29 insertions, 14 deletions
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index 372599b..dba4d27 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -336,7 +336,6 @@ std::map<XID, GtkWindow*> BrowserWindowGtk::xid_map_;
BrowserWindowGtk::BrowserWindowGtk(Browser* browser)
: browser_(browser),
full_screen_(false),
- drag_active_(false),
frame_cursor_(NULL) {
use_custom_frame_.Init(prefs::kUseCustomChromeFrame,
browser_->profile()->GetPrefs(), this);
@@ -806,14 +805,10 @@ void BrowserWindowGtk::OnStateChanged(GdkWindowState state) {
}
bool BrowserWindowGtk::CanClose() const {
- if (drag_active_)
- return false;
-
- // TODO(tc): We don't have tab dragging yet.
// You cannot close a frame for which there is an active originating drag
// session.
- // if (tabstrip_->IsDragSessionActive())
- // return false;
+ if (tabstrip_->IsDragSessionActive())
+ return false;
// Give beforeunload handlers the chance to cancel the close before we hide
// the window below.
diff --git a/chrome/browser/gtk/browser_window_gtk.h b/chrome/browser/gtk/browser_window_gtk.h
index 249c695..e0bbc47 100644
--- a/chrome/browser/gtk/browser_window_gtk.h
+++ b/chrome/browser/gtk/browser_window_gtk.h
@@ -124,10 +124,6 @@ class BrowserWindowGtk : public BrowserWindow,
// Add the find bar widget to the window hierarchy.
void AddFindBar(FindBarGtk* findbar);
- // Sets whether a drag is active. If a drag is active the window will not
- // close.
- void set_drag_active(bool drag_active) { drag_active_ = drag_active; }
-
// Reset the mouse cursor to the default cursor if it was set to something
// else for the custom frame.
void ResetCustomFrameCursor();
diff --git a/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc b/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc
index ed6d511..3b3c1f4 100644
--- a/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc
+++ b/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc
@@ -380,8 +380,6 @@ void DraggedTabControllerGtk::Attach(TabStripGtk* attached_tabstrip,
}
void DraggedTabControllerGtk::Detach() {
- if (attached_tabstrip_->GetTabCount() <= 1) return;
-
// Update the Model.
TabStripModel* attached_model = attached_tabstrip_->model();
int index = attached_model->GetIndexOfTabContents(dragged_contents_);
@@ -393,7 +391,9 @@ void DraggedTabControllerGtk::Detach() {
attached_tabstrip->SchedulePaint();
}
- // TODO(jhawkins): Hide the window if we're removing the last tab.
+ // If we've removed the last tab from the tabstrip, hide the frame now.
+ if (attached_model->empty())
+ HideFrame();
// Update the dragged tab. This NULL check is necessary apparently in some
// conditions during automation where the view_ is destroyed inside a
@@ -559,6 +559,7 @@ bool DraggedTabControllerGtk::EndDragImpl(EndDragType type) {
}
void DraggedTabControllerGtk::RevertDrag() {
+ // TODO(jhawkins): Restore the window frame.
// We save this here because code below will modify |attached_tabstrip_|.
if (attached_tabstrip_) {
int index = attached_tabstrip_->model()->GetIndexOfTabContents(
@@ -617,6 +618,7 @@ bool DraggedTabControllerGtk::CompleteDrag() {
source_tabstrip_->model()->delegate()->CreateNewStripWithContents(
dragged_contents_, window_bounds, dock_info_);
new_browser->window()->Show();
+ CleanUpHiddenFrame();
}
return destroy_immediately;
@@ -661,6 +663,19 @@ gfx::Rect DraggedTabControllerGtk::GetTabScreenBounds(TabGtk* tab) {
return gfx::Rect(x, y, widget->allocation.width, widget->allocation.height);
}
+void DraggedTabControllerGtk::HideFrame() {
+ GtkWidget* tabstrip = source_tabstrip_->widget();
+ GtkWindow* window = platform_util::GetTopLevel(tabstrip);
+ gtk_widget_hide(GTK_WIDGET(window));
+}
+
+void DraggedTabControllerGtk::CleanUpHiddenFrame() {
+ // If the model we started dragging from is now empty, we must ask the
+ // delegate to close the frame.
+ if (source_tabstrip_->model()->empty())
+ source_tabstrip_->model()->delegate()->CloseFrameAfterDragSession();
+}
+
void DraggedTabControllerGtk::CleanUpSourceTab() {
// If we were attached to the source tabstrip, source tab will be in use
// as the tab. If we were detached or attached to another tabstrip, we can
@@ -684,6 +699,8 @@ void DraggedTabControllerGtk::OnAnimateToBoundsComplete() {
}
}
+ CleanUpHiddenFrame();
+
if (!in_destructor_)
source_tabstrip_->DestroyDragController();
}
diff --git a/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.h b/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.h
index 87ef243..45a669d 100644
--- a/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.h
+++ b/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.h
@@ -167,6 +167,13 @@ class DraggedTabControllerGtk : public NotificationObserver,
// for the attached TabStrip.
int NormalizeIndexToAttachedTabStrip(int index) const;
+ // Hides the frame for the window that contains the TabStrip the current
+ // drag session was initiated from.
+ void HideFrame();
+
+ // Closes a hidden frame at the end of a drag session.
+ void CleanUpHiddenFrame();
+
// Cleans up a source tab that is no longer used.
void CleanUpSourceTab();