OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/tab_drag_controller.h" | 5 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // close enough to trigger moving. | 80 // close enough to trigger moving. |
81 const int kStackedDistance = 36; | 81 const int kStackedDistance = 36; |
82 | 82 |
83 // A dragged window is forced to be a bit smaller than maximized bounds during a | 83 // A dragged window is forced to be a bit smaller than maximized bounds during a |
84 // drag. This prevents the dragged browser widget from getting maximized at | 84 // drag. This prevents the dragged browser widget from getting maximized at |
85 // creation and makes it easier to drag tabs out of a restored window that had | 85 // creation and makes it easier to drag tabs out of a restored window that had |
86 // maximized size. | 86 // maximized size. |
87 const int kMaximizedWindowInset = 10; // DIPs. | 87 const int kMaximizedWindowInset = 10; // DIPs. |
88 | 88 |
89 #if defined(USE_ASH) | 89 #if defined(USE_ASH) |
90 // Returns true if |tab_strip| browser window is docked. | 90 // Returns true if |tab_strip| browser window is snapped. |
91 bool IsDockedOrSnapped(const TabStrip* tab_strip) { | 91 bool IsSnapped(const TabStrip* tab_strip) { |
92 DCHECK(tab_strip); | 92 DCHECK(tab_strip); |
93 ash::wm::WindowState* window_state = | 93 ash::wm::WindowState* window_state = |
94 ash::wm::GetWindowState(tab_strip->GetWidget()->GetNativeWindow()); | 94 ash::wm::GetWindowState(tab_strip->GetWidget()->GetNativeWindow()); |
95 return window_state->IsDocked() || window_state->IsSnapped(); | 95 return window_state->IsSnapped(); |
96 } | 96 } |
97 #else | 97 #else |
98 bool IsDockedOrSnapped(const TabStrip* tab_strip) { | 98 bool IsSnapped(const TabStrip* tab_strip) { |
99 return false; | 99 return false; |
100 } | 100 } |
101 #endif | 101 #endif |
102 | 102 |
103 #if defined(USE_AURA) | 103 #if defined(USE_AURA) |
104 gfx::NativeWindow GetModalTransient(gfx::NativeWindow window) { | 104 gfx::NativeWindow GetModalTransient(gfx::NativeWindow window) { |
105 return wm::GetModalTransient(window); | 105 return wm::GetModalTransient(window); |
106 } | 106 } |
107 #else | 107 #else |
108 gfx::NativeWindow GetModalTransient(gfx::NativeWindow window) { | 108 gfx::NativeWindow GetModalTransient(gfx::NativeWindow window) { |
(...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1469 data->source_model_index, data->contents, | 1469 data->source_model_index, data->contents, |
1470 (data->pinned ? TabStripModel::ADD_PINNED : 0)); | 1470 (data->pinned ? TabStripModel::ADD_PINNED : 0)); |
1471 } | 1471 } |
1472 } | 1472 } |
1473 | 1473 |
1474 void TabDragController::CompleteDrag() { | 1474 void TabDragController::CompleteDrag() { |
1475 DCHECK(started_drag_); | 1475 DCHECK(started_drag_); |
1476 | 1476 |
1477 if (attached_tabstrip_) { | 1477 if (attached_tabstrip_) { |
1478 if (is_dragging_new_browser_ || did_restore_window_) { | 1478 if (is_dragging_new_browser_ || did_restore_window_) { |
1479 if (IsDockedOrSnapped(attached_tabstrip_)) { | 1479 if (IsSnapped(attached_tabstrip_)) { |
1480 was_source_maximized_ = false; | 1480 was_source_maximized_ = false; |
1481 was_source_fullscreen_ = false; | 1481 was_source_fullscreen_ = false; |
1482 } | 1482 } |
1483 | 1483 |
1484 // If source window was maximized - maximize the new window as well. | 1484 // If source window was maximized - maximize the new window as well. |
1485 if (was_source_maximized_ || was_source_fullscreen_) | 1485 if (was_source_maximized_ || was_source_fullscreen_) |
1486 MaximizeAttachedWindow(); | 1486 MaximizeAttachedWindow(); |
1487 } | 1487 } |
1488 attached_tabstrip_->StoppedDraggingTabs( | 1488 attached_tabstrip_->StoppedDraggingTabs( |
1489 GetTabsMatchingDraggedContents(attached_tabstrip_), | 1489 GetTabsMatchingDraggedContents(attached_tabstrip_), |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1795 // TODO(pkotwicz): Fix this properly (crbug.com/358482) | 1795 // TODO(pkotwicz): Fix this properly (crbug.com/358482) |
1796 for (auto* browser : *BrowserList::GetInstance()) { | 1796 for (auto* browser : *BrowserList::GetInstance()) { |
1797 if (browser->tab_strip_model()->empty()) | 1797 if (browser->tab_strip_model()->empty()) |
1798 exclude.insert(browser->window()->GetNativeWindow()); | 1798 exclude.insert(browser->window()->GetNativeWindow()); |
1799 } | 1799 } |
1800 #endif | 1800 #endif |
1801 base::WeakPtr<TabDragController> ref(weak_factory_.GetWeakPtr()); | 1801 base::WeakPtr<TabDragController> ref(weak_factory_.GetWeakPtr()); |
1802 *window = window_finder_->GetLocalProcessWindowAtPoint(screen_point, exclude); | 1802 *window = window_finder_->GetLocalProcessWindowAtPoint(screen_point, exclude); |
1803 return ref ? Liveness::ALIVE : Liveness::DELETED; | 1803 return ref ? Liveness::ALIVE : Liveness::DELETED; |
1804 } | 1804 } |
OLD | NEW |