Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: chrome/browser/ui/views/tabs/dragged_tab_controller.cc

Issue 8068020: Converts usage of GetBrowserViewForNativeWindow to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporate review feedback, and make ShowPageInfo platform specific Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/views/tabs/dragged_tab_controller.h" 5 #include "chrome/browser/ui/views/tabs/dragged_tab_controller.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <set> 8 #include <set>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 // think we could just convert them to screen coordinates, however in the 642 // think we could just convert them to screen coordinates, however in the
643 // situation where we're dragging the last tab in a window when multiple 643 // situation where we're dragging the last tab in a window when multiple
644 // windows are open, the coordinates of |source_tab_| are way off in 644 // windows are open, the coordinates of |source_tab_| are way off in
645 // hyperspace since the window was moved there instead of being closed so 645 // hyperspace since the window was moved there instead of being closed so
646 // that we'd keep receiving events. And our ConvertPointToScreen methods 646 // that we'd keep receiving events. And our ConvertPointToScreen methods
647 // aren't really multi-screen aware. So really it's just safer to get the 647 // aren't really multi-screen aware. So really it's just safer to get the
648 // actual position of the mouse cursor directly from Windows here, which is 648 // actual position of the mouse cursor directly from Windows here, which is
649 // guaranteed to be correct regardless of monitor config. 649 // guaranteed to be correct regardless of monitor config.
650 gfx::Point screen_point = GetCursorScreenPoint(); 650 gfx::Point screen_point = GetCursorScreenPoint();
651 651
652 #if defined(OS_LINUX) 652 #if defined(OS_WIN) && !defined(USE_AURA)
653 // We don't allow detaching in chrome os. 653 // Currently only allowed on windows (and not aura).
654 BaseTabStrip* target_tabstrip = source_tabstrip_;
655 #else
656 // Determine whether or not we have dragged over a compatible TabStrip in 654 // Determine whether or not we have dragged over a compatible TabStrip in
657 // another browser window. If we have, we should attach to it and start 655 // another browser window. If we have, we should attach to it and start
658 // dragging within it. 656 // dragging within it.
659 BaseTabStrip* target_tabstrip = GetTabStripForPoint(screen_point); 657 BaseTabStrip* target_tabstrip = GetTabStripForPoint(screen_point);
658 #else
659 BaseTabStrip* target_tabstrip = source_tabstrip_;
660 #endif 660 #endif
661 if (target_tabstrip != attached_tabstrip_) { 661 if (target_tabstrip != attached_tabstrip_) {
662 // Make sure we're fully detached from whatever TabStrip we're attached to 662 // Make sure we're fully detached from whatever TabStrip we're attached to
663 // (if any). 663 // (if any).
664 if (attached_tabstrip_) 664 if (attached_tabstrip_)
665 Detach(); 665 Detach();
666 if (target_tabstrip) 666 if (target_tabstrip)
667 Attach(target_tabstrip, screen_point); 667 Attach(target_tabstrip, screen_point);
668 } 668 }
669 if (!target_tabstrip) { 669 if (!target_tabstrip) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 return dock_info_; 767 return dock_info_;
768 } 768 }
769 769
770 gfx::NativeView dragged_hwnd = view_->GetWidget()->GetNativeView(); 770 gfx::NativeView dragged_hwnd = view_->GetWidget()->GetNativeView();
771 dock_windows_.insert(dragged_hwnd); 771 dock_windows_.insert(dragged_hwnd);
772 DockInfo info = DockInfo::GetDockInfoAtPoint(screen_point, dock_windows_); 772 DockInfo info = DockInfo::GetDockInfoAtPoint(screen_point, dock_windows_);
773 dock_windows_.erase(dragged_hwnd); 773 dock_windows_.erase(dragged_hwnd);
774 return info; 774 return info;
775 } 775 }
776 776
777 #if defined(OS_WIN) && !defined(USE_AURA)
777 BaseTabStrip* DraggedTabController::GetTabStripForPoint( 778 BaseTabStrip* DraggedTabController::GetTabStripForPoint(
778 const gfx::Point& screen_point) { 779 const gfx::Point& screen_point) {
779 gfx::NativeView dragged_view = NULL; 780 gfx::NativeView dragged_view = NULL;
780 if (view_.get()) { 781 if (view_.get()) {
781 dragged_view = view_->GetWidget()->GetNativeView(); 782 dragged_view = view_->GetWidget()->GetNativeView();
782 dock_windows_.insert(dragged_view); 783 dock_windows_.insert(dragged_view);
783 } 784 }
784 gfx::NativeWindow local_window = 785 gfx::NativeWindow local_window =
785 DockInfo::GetLocalProcessWindowAtPoint(screen_point, dock_windows_); 786 DockInfo::GetLocalProcessWindowAtPoint(screen_point, dock_windows_);
786 if (dragged_view) 787 if (dragged_view)
787 dock_windows_.erase(dragged_view); 788 dock_windows_.erase(dragged_view);
788 if (!local_window) 789 if (!local_window)
789 return NULL; 790 return NULL;
790 BrowserView* browser = 791 BrowserView* browser =
791 BrowserView::GetBrowserViewForNativeWindow(local_window); 792 BrowserView::GetBrowserViewForNativeWindow(local_window);
792 // We don't allow drops on windows that don't have tabstrips. 793 // We don't allow drops on windows that don't have tabstrips.
793 if (!browser || 794 if (!browser ||
794 !browser->browser()->SupportsWindowFeature(Browser::FEATURE_TABSTRIP)) 795 !browser->browser()->SupportsWindowFeature(Browser::FEATURE_TABSTRIP))
795 return NULL; 796 return NULL;
796 797
797 // This cast seems ugly, but the controller and the view are tighly coupled at 798 // This cast seems ugly, but the controller and the view are tighly coupled at
798 // creation time, so it will be okay. 799 // creation time, so it will be okay.
799 BaseTabStrip* other_tabstrip = 800 BaseTabStrip* other_tabstrip =
800 static_cast<BaseTabStrip*>(browser->tabstrip()); 801 static_cast<BaseTabStrip*>(browser->tabstrip());
801 802
802 if (!other_tabstrip->controller()->IsCompatibleWith(source_tabstrip_)) 803 if (!other_tabstrip->controller()->IsCompatibleWith(source_tabstrip_))
803 return NULL; 804 return NULL;
804 return GetTabStripIfItContains(other_tabstrip, screen_point); 805 return GetTabStripIfItContains(other_tabstrip, screen_point);
805 } 806 }
807 #endif
806 808
807 BaseTabStrip* DraggedTabController::GetTabStripIfItContains( 809 BaseTabStrip* DraggedTabController::GetTabStripIfItContains(
808 BaseTabStrip* tabstrip, 810 BaseTabStrip* tabstrip,
809 const gfx::Point& screen_point) const { 811 const gfx::Point& screen_point) const {
810 static const int kVerticalDetachMagnetism = 15; 812 static const int kVerticalDetachMagnetism = 15;
811 static const int kHorizontalDetachMagnetism = 15; 813 static const int kHorizontalDetachMagnetism = 15;
812 // Make sure the specified screen point is actually within the bounds of the 814 // Make sure the specified screen point is actually within the bounds of the
813 // specified tabstrip... 815 // specified tabstrip...
814 gfx::Rect tabstrip_bounds = GetViewScreenBounds(tabstrip); 816 gfx::Rect tabstrip_bounds = GetViewScreenBounds(tabstrip);
815 if (tabstrip->type() == BaseTabStrip::HORIZONTAL_TAB_STRIP) { 817 if (tabstrip->type() == BaseTabStrip::HORIZONTAL_TAB_STRIP) {
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 1440
1439 bool DraggedTabController::AreTabsConsecutive() { 1441 bool DraggedTabController::AreTabsConsecutive() {
1440 for (size_t i = 1; i < drag_data_.size(); ++i) { 1442 for (size_t i = 1; i < drag_data_.size(); ++i) {
1441 if (drag_data_[i - 1].source_model_index + 1 != 1443 if (drag_data_[i - 1].source_model_index + 1 !=
1442 drag_data_[i].source_model_index) { 1444 drag_data_[i].source_model_index) {
1443 return false; 1445 return false;
1444 } 1446 }
1445 } 1447 }
1446 return true; 1448 return true;
1447 } 1449 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698