OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/gtk/tabs/dragged_tab_controller_gtk.h" | 5 #include "chrome/browser/gtk/tabs/dragged_tab_controller_gtk.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 int index = attached_model->GetIndexOfTabContents(dragged_contents_); | 411 int index = attached_model->GetIndexOfTabContents(dragged_contents_); |
412 if (index >= 0 && index < attached_model->count()) { | 412 if (index >= 0 && index < attached_model->count()) { |
413 // Sometimes, DetachTabContentsAt has consequences that result in | 413 // Sometimes, DetachTabContentsAt has consequences that result in |
414 // attached_tabstrip_ being set to NULL, so we need to save it first. | 414 // attached_tabstrip_ being set to NULL, so we need to save it first. |
415 TabStripGtk* attached_tabstrip = attached_tabstrip_; | 415 TabStripGtk* attached_tabstrip = attached_tabstrip_; |
416 attached_model->DetachTabContentsAt(index); | 416 attached_model->DetachTabContentsAt(index); |
417 attached_tabstrip->SchedulePaint(); | 417 attached_tabstrip->SchedulePaint(); |
418 } | 418 } |
419 | 419 |
420 // If we've removed the last tab from the tabstrip, hide the frame now. | 420 // If we've removed the last tab from the tabstrip, hide the frame now. |
421 if (!attached_model->HasNonPhantomTabs()) | 421 if (attached_model->empty()) |
422 HideWindow(); | 422 HideWindow(); |
423 | 423 |
424 // Update the dragged tab. This NULL check is necessary apparently in some | 424 // Update the dragged tab. This NULL check is necessary apparently in some |
425 // conditions during automation where the view_ is destroyed inside a | 425 // conditions during automation where the view_ is destroyed inside a |
426 // function call preceding this point but after it is created. | 426 // function call preceding this point but after it is created. |
427 if (dragged_tab_.get()) { | 427 if (dragged_tab_.get()) { |
428 dragged_tab_->Detach(); | 428 dragged_tab_->Detach(); |
429 } | 429 } |
430 | 430 |
431 // Detaching resets the delegate, but we still want to be the delegate. | 431 // Detaching resets the delegate, but we still want to be the delegate. |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 | 719 |
720 void DraggedTabControllerGtk::ShowWindow() { | 720 void DraggedTabControllerGtk::ShowWindow() { |
721 GtkWidget* tabstrip = source_tabstrip_->widget(); | 721 GtkWidget* tabstrip = source_tabstrip_->widget(); |
722 GtkWindow* window = platform_util::GetTopLevel(tabstrip); | 722 GtkWindow* window = platform_util::GetTopLevel(tabstrip); |
723 gtk_window_present(window); | 723 gtk_window_present(window); |
724 } | 724 } |
725 | 725 |
726 void DraggedTabControllerGtk::CleanUpHiddenFrame() { | 726 void DraggedTabControllerGtk::CleanUpHiddenFrame() { |
727 // If the model we started dragging from is now empty, we must ask the | 727 // If the model we started dragging from is now empty, we must ask the |
728 // delegate to close the frame. | 728 // delegate to close the frame. |
729 if (!source_tabstrip_->model()->HasNonPhantomTabs()) | 729 if (source_tabstrip_->model()->empty()) |
730 source_tabstrip_->model()->delegate()->CloseFrameAfterDragSession(); | 730 source_tabstrip_->model()->delegate()->CloseFrameAfterDragSession(); |
731 } | 731 } |
732 | 732 |
733 void DraggedTabControllerGtk::CleanUpSourceTab() { | 733 void DraggedTabControllerGtk::CleanUpSourceTab() { |
734 // If we were attached to the source tabstrip, source tab will be in use | 734 // If we were attached to the source tabstrip, source tab will be in use |
735 // as the tab. If we were detached or attached to another tabstrip, we can | 735 // as the tab. If we were detached or attached to another tabstrip, we can |
736 // safely remove this item and delete it now. | 736 // safely remove this item and delete it now. |
737 if (attached_tabstrip_ != source_tabstrip_) { | 737 if (attached_tabstrip_ != source_tabstrip_) { |
738 source_tabstrip_->DestroyDraggedSourceTab(source_tab_); | 738 source_tabstrip_->DestroyDraggedSourceTab(source_tab_); |
739 source_tab_ = NULL; | 739 source_tab_ = NULL; |
(...skipping 26 matching lines...) Expand all Loading... |
766 gfx::NativeView dragged_tab = dragged_tab_->widget(); | 766 gfx::NativeView dragged_tab = dragged_tab_->widget(); |
767 dock_windows_.insert(dragged_tab); | 767 dock_windows_.insert(dragged_tab); |
768 window = DockInfo::GetLocalProcessWindowAtPoint(GetCursorScreenPoint(), | 768 window = DockInfo::GetLocalProcessWindowAtPoint(GetCursorScreenPoint(), |
769 dock_windows_); | 769 dock_windows_); |
770 dock_windows_.erase(dragged_tab); | 770 dock_windows_.erase(dragged_tab); |
771 } | 771 } |
772 | 772 |
773 if (window) | 773 if (window) |
774 gtk_window_present(GTK_WINDOW(window)); | 774 gtk_window_present(GTK_WINDOW(window)); |
775 } | 775 } |
OLD | NEW |